-
-
Notifications
You must be signed in to change notification settings - Fork 817
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#5493 use ClassScanner to find Api4 entities in ActionObjectProvider #31198
dev/core#5493 use ClassScanner to find Api4 entities in ActionObjectProvider #31198
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
@@ -48,6 +50,10 @@ public static function getSubscribedEvents() { | |||
public function onApiResolve(ResolveEvent $event) { | |||
$apiRequest = $event->getApiRequest(); | |||
if ($apiRequest instanceof AbstractAction) { | |||
if (!isset($this->getEntities()[$apiRequest->getEntityName()])) { |
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.
This gives a slightly more informative warning if the mismatch occurs. You get Api not implemented
rather than DB table does not exist
.
Possibly we could throw the error right here - I wasn't sure if there are legitimate cases where something else might provide the Api.
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.
Nope, that's it. That function invokes 'civi.api4.entityTypes'
which is the only way to add extra entities, so this is good.
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.
Changed this from a log message to an exception and... it "fixes" a bunch of fails in the upgrade test, because Exceptions get swallowed e.g. when reconciling ManagedEntities
Which isn't totally satisfactory, but I guess maybe why it's not failing more currently
good = upgrade test passes on Mysql8! |
*/ | ||
interface AbstractEntityInterface { | ||
|
||
// TODO: flesh out the interface |
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.
Basically all the public functions in AbstractEntity
should go here.
2d2099d
to
8901921
Compare
So my read of the new test fails: 1. OAuth doesn't currently have Makes me realise that this change wouldn't be totally backward compatible -- if you have an extension with Api4 entity classes you now require To me this seems reasonable semantically (basically the old 2. Mock Api4 entities in the tests not getting picked up by class scanner Have amended ClassScanner to fix this. 3. There's an upgrade step that seems to use This causes a problem because under that entity now lives in |
28ca4d2
to
17404b7
Compare
Two new fails that look relatively easy fixes: CRM_Financial_Form_PaymentFormsTest::testEventPaymentForms - https://test.civicrm.org/job/CiviCRM-Test/27404/testReport/ api\v4\Entity\ConformanceTest::testConformance with data set "MockBasicEntity" ('MockBasicEntity') - https://test.civicrm.org/job/CiviCRM-Test/27400/testReport/ But not sure what to do about the main upgrade test fails. Some upgrade steps are calling Apis that are (now) provided by extensions, but the upgrade dispatch policy means extensions aren't "all there" during the main part of the upgrade. It feels like these upgrade steps become extension upgrade steps - but that creates a resequencing issue. Some way to explicitly allow those hooks / apis temporarily for just the upgrade steps that require them? |
17404b7
to
8244361
Compare
@@ -89,7 +90,8 @@ public function upgradePermissions($permissions) { | |||
if (empty($permissions)) { | |||
throw new CRM_Core_Exception("Cannot upgrade permissions: permission list missing"); | |||
} | |||
if (class_exists(Role::class)) { | |||
// sometimes during upgrade the extension entities aren't available | |||
if (CoreUtil::entityExists('User')) { |
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.
Well that sucks
Sorry this isnt really Ready for Review. I will work on it some more today but would appreciate your 2 cents if you have a minute @colemanw or @totten From my investigation I think the top line is "there is inconsistency in how the dispatch policy during upgrade impacts what low level things are brought in from extensions". It started with a mismatch between entityrepository entities (not loaded from ext) and api entities. I've now found a case it seems to extend to SpecProviders. Looking at the LegacySpecProvider - I'm thinking we essentially need to do something similar with how Api4 entities are loaded from extensions (namely: make it go through scan-clases, but probably add a LegacyEntityProvider that doesn't require scan-classes, but does respect the dispatch policy). (I also think it could be good to teach the LegacySpecProvider gatherer to respect the dispatch policy?) Does that sound reasonable approach? Any memories from the LegacySpecProvider transition that would be relevant? Alternative, cheekier approach could be to just permit |
In the last commit here I mpved the SearchSegment spec thing from legacy to new model, in order to be more respectful. But that's treating the symptom (loading that was throwing exception during one of the upgrader steps) rather than the cause. |
(Aside: with new approach I'm seeing some issues in |
ee3a72c
to
798138c
Compare
A bit of scrabbling around in ConformanceTest at the end there - but I think this should be passing / working now. |
Big picture - I think it could be really helpful for this stuff if ClassScanner::get could distinguish between core classes and extension classes from |
(Expecting an outstanding upgrade fail for standalone php74m56 because of civicrm/civicrm-upgrade-test#14) |
* This is currently a null interface - it allows picking | ||
* up AbstractEntities via the ClassScanner | ||
*/ | ||
interface EntityInterface { |
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.
Oh, yeah, moving toward a straight-up interface
would be a silver-lining. (Tho obviously not the main goal.)
Test updated and passing here now 🎉 (vs still failing on master) |
All the extended test failures look pre-existing to me (tokens and group management) |
Just noting here I can reproduce the crash on D10 on 5.79RC so its potentially a broader regression |
@ufundo I just tried changing the base of this PR to 5.79, which I think is correct since this is an unreleased regression, but it looks like you've recently (perhaps accidentally) rebased it agains |
798138c
to
5a61c11
Compare
5a61c11
to
2f880fd
Compare
@colemanw - I've rebased, and tried to take out a few commits that make sense in the long run but aren't strictly essential. Hopefully that hasn't broken any tests, but worth seeing. Will put up separate PRs against |
@ufundo to clarify what this PR does, is the |
Not there yet. With this change they come through scanClasses . At the moment the ClassScanner doesn't distinguish core and extension classes once it's got them, so they end up bundled together at that point. I think it could be nice to find a way to separate them out and feed the extension ones through the |
Passing as before (minus preexisting fails on tokens / groups in the extended) Not sure how people approach RC testing, but would think good to merge ASAP to catch as much of remaining RC testing period as possible. |
ping @totten in case any final thoughts? |
I just tried the rc with this PR merged & our custom extension no longer installs - I have logged as a regression at https://lab.civicrm.org/dev/core/-/issues/5533 |
Change-Id: Ic187afdf33be725200d5c51ba90eed66b89b09e2
…undraising/crm into deployment + aeec552 Might be a more flexible place to define the setting + 598d9cc PHpoffice update (partial of civi security update) + d72d016 Security update -minus changes from civicrm/civicrm-core#31198 Change-Id: Ib96e8267b3e98f027debcdbec7efd26e756a8368
Overview
Attempt 2 to find a way to fix https://lab.civicrm.org/dev/core/-/issues/5493
Before
After
CRM_Core_Permission_Standalone
where this was causing an issue