-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
CRM-14885 - Commit DAO's. Add freshness test. #8769
Conversation
811d7b4
to
38e5861
Compare
Nice! Test fail is unrelated (I'll look into it). It might be worth fixing these patterns before we commit - ie. the &import - I know these threw up so many errors when Chris ran a php7 over the codebase it rendered the tool fairly useless.
Also the caching of a statically declared array is dumb. Does the test protect against someone editing the DAO & not the xml? |
+1 for removing the The test does not protect against someone editing the DAO directly. :( The only way to do that would be to have the test actually generate the full DAO and a comparison of the output. |
"The test does not protect against someone editing the DAO directly. :( The only way to do that would be to have the test actually generate the full DAO and a comparison of the output." Does this mean that becomes the job of human eyes to ensure? What comms do we need? It would be good - but not necessarily worth the effort - for a github hook to add a standard message to any PR that alters xml or DAO files |
…DAO's are current
Changes: * Before, CRM_Core_DAO_AllCoreTables was generated with a mix of logic and data. Now, the class is a static file, and only the data is generated. This makes it easier to develop. * Before, the file was not commited. As with the DAOs, it is now committed.
38e5861
to
437fafc
Compare
Rebased. Patched |
From a QA point of view - assuming the $method() stuff is going to survive this round I feel the tests give a pretty good sanity check. Aside from that I'll pull this PR & do 'my normal dev' on top of it and also try rebasing it into a forked repo & see how that looks |
test this please |
There's repetitive bugginess in these functions. We can reduce SLOC and gain leverage by moving the guts to a central function. QA note: To test that these patches had no functional impact, I used some helper scripts: https://gist.github.com/totten/4473975264fc2a788391d3c5ef5bf18b Fun fact: This is net-reduction of ~6,000 SLOC.
457a033
to
63dfeb0
Compare
Slimmed down |
Random exciting thought -- after we commit more of these generated files, and after some time has passed, we'll be able to run |
The information here is redundant with the information in `fields()`. We can make `fields()` more hookable (and reduce SLOC) by generating this. QA note: To test that these patches had no functional impact, I used some helper scripts: https://gist.github.com/totten/4473975264fc2a788391d3c5ef5bf18b Fun fact: This is net-reduction of ~2,500 SLOC.
63dfeb0
to
3a916ab
Compare
The old check was prone to false-positives if you make unrelated changes in `CRM/Core/CodeGen/*` and false-negatives when some hacks the underlying file. It's now more diligent.
3a916ab
to
72e4d1c
Compare
For CRM-19130, we want all calls to `fields()` to be hookable, which means that `fields()` can only run in a bootstrapped system (where hooks are reliably working). This should be *mostly* OK. However, during bootstrap, we rely on the SQL cache which means that `CRM_Core_BAO_Cache` must be operational -- even if `fields()` cannot be used. Consequently, the DAO-based query-builder cannot be used.
7951d33
to
346aaab
Compare
Hrm... all the build processes already run |
@totten do you have any reservations about this? I'm feeling good to merge it. It's a huge commit so there is a lot to look at but the DAO changes seem fine & I had a quick look at the cache change - it all seems like stuff that would have killed the tests if it were a problem. I'll tinker a bit more but I'm feeling towards merging Note I see you reluctantly didn't us REPLACE or INSERT ON UPDATE - my experience is they are often actually slower anyway....
|
test this please |
(will try to see if I can install on test box) |
@totten I experienced the same error as above on http://core-8769-5bct0.test-ubu1204-5.civicrm.org/civicrm/admin/extensions |
I'm seeing another symptom on this sandbox that I'm NOT seeing on dmaster sandbox. I suspect it's the same underlying issue and sheds like on it. If you go to & click continue you get a fatal. The reason for the fatal is that the rgid is NOT in the url that it re-directs to and the reason for that is that although in CRM_Contact_Form_DedupeFind::preProcess we see
When you get to PostProcess
|
The earlier patch for CRM-19130 broke support for reading individual items from the SQL cache. Although the test-suite hits the cache layer a lot (e.g. CRM_Utils_Cache_SqlGroupTest), the bug wasn't exposed by other tests because (a) caches are replicated in-memory and in SQL (b) caches are often read in batch mode. This explicitly flushes the in-memory cache and reads the SQL cache.
@eileenmcnaughton , thanks for catching it! I cherry-picked your patch and added a test case (64c2ecd) |
@totten I feel OK to merge this on pass now - that was one of very few places outside the DAO where the code changed at all & I haven't hit any other problems. |
@eileenmcnaughton Agree with merging on pass. There is a caveat that this PR doesn't entirely meet the original goal -- e.g. in the current CI configuration, the Despite the caveat, it's still a significant improvement because running |
Based on discussion from Mattermost, this PR adds DAO files to git. To
ensure that the files are kept up-to-date, it also adds a new test class
(
CRM_Core_CodeGen_FreshnessTest
).The freshness test works by adding a checksum to the comments of each DAO.
The checksum is compared against (a) the source code (PHP/tpl) for GenCode(Update) The checksum is compared against the XML schema for the particular table. Additionally, the freshness test prepares a raw, unformatted version of the DAO file and compares it to the actual DAO file (modulo whitespace).and (b) the XML schema for the particular table.
A few workflow notes for devs to be aware of:
commit the updated DAO. (If you neglect to do so, the test suite will
report an error.)
you neglect to do so, the test suite will not report an error.)
If you change any of the logic or templates behind GenCode, then all theDAOs need to be regenerated (even if the change has no functional impact
on DAOs). This is a coarse-grained approach. Looking forward to the
lifecycle (as devs tweak/refactor this code), this seems simpler/safer
than trying to develop (or make mistakes with) fine-grained checks.
(Note: I drafted a patch to replace
PHP_Beautifier
with the slower but more correctphpcbf
, but that would affect typical development dependencies. https://gist.github.com/totten/e76ff4d7243002322ca0d8e49924b5d1 )