-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#4999 - POC CRM_Core_DAO_Base class which reads directly from schema/xml #29424
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/4999 |
Retest this please |
Sorry to be a pain; I'll say this then butt out because this whole thing seemed to be focussed on making developers happier by solving a minor inconvenience and it's kinda doing the opposite to this developer but I'm only one and you do this more than me, but my personal opinion is: I'm still un sold on this. I like the idea of ditching DAO. I don't like the idea of doubling down on XML. There's some great example of the joys of XML parsing in this PR. We want XML (string representations) to describe things to PHP (multi types), since it's PHP that will be translating to SQL (other string representations). XML is not easy to parse by PHP. It's mostly humans who have to write this XML code, yet XML is not easy to write either. Example: the parsing uses Too much talk about nothing (null/falsy/""): Take The weird thing is that default's value goes in the SQL, and needs to be SQL-safe. So 0 is valid but We don't care about PHP NULL because we're not using XML properly (attr Did I say finally? There's another thing which is that we should use
|
See further conversation at https://lab.civicrm.org/dev/core/-/issues/4999 |
|
||
private static function getEntityDefinition(): SimpleXMLElement { | ||
if (!isset(Civi::$statics[static::class][__FUNCTION__])) { | ||
[, $dir, , $name] = explode('_', static::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related edge cases:
CRM_Foo_BAO_Bar extends CRM_Foo_DAO_Bar
==> Would appear as two different classesCRM_Event_Cart_DAO_*
andCRM_Mailing_Event_DAO_*
==> Placement of "DAO"/"BAO" can vary- In a test-suite, the schema/class-structure remains constant, but
Civi::$statics
is reset several thousand times- (
ClassScanner
has a kind of similar consideration where it caches class-structure. It usesstatic::$caches
instead ofCivi::$statics
. Spot-checkingapi_v3_ContactTest
, this saves ~7% on execution-time -- which should translate to 2-3min on each of the bigger suites.)
- (
I suppose it's not complicated to address any of those (though maybe less pretty).
(I think similar notes would apply in this branch or similar variations with different file-formats.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. It looks like we won't be using this code anyway given that the discussion has evolved to favor a different file format & loading mechanism. But still good points.
Closed in favor of #29472 |
Overview
POC for https://lab.civicrm.org/dev/core/-/issues/4999
This allows DAO files to be gutted down to basically nothing, and instead inherit from a new base class which does all the work.
Before
Core + Extensions must generate (and periodically regenerate) their DAO files.
After
This PR plus #29422 would mean that extensions do not have to generate anything.
Comments
As noted in discussion in https://lab.civicrm.org/dev/core/-/issues/4999 parsing XML files is slow, but on the bright side this caches the parsed result so it only needs to happen once per DAO.