- Issue created by @rupertj
- 🇬🇧United Kingdom joachim
> I spotted when looking at the code that it doesn't use constructor property promotion. Is there a reason for that?
That's not in the Drupal coding standards yet AFAIK.
I use DCB for generating DI code, so the the boilerplate isn't a problem to write at least!
> \Drupal::service('cache.discovery')->invalidateAll();
I wonder why the tests don't crash too?
- 🇬🇧United Kingdom rupertj Bristol, UK
From the core discussion ( https://www.drupal.org/project/drupal/issues/3278431 📌 Use PHP 8 constructor property promotion for existing code Needs work ) I took that using constructor property promotion should be encouraged for new code. LGD's code uses it for most classes already.
- 🇳🇱Netherlands ekes
> I took that using constructor property promotion should be encouraged for new code
+1 for that interpretation. We did already make that assumption in LGD code; plus imho it's soooooo much nicer.
- Merge request !3Clear cache discovery during finder creation to avoid a crash. → (Open) created by rupertj
- 🇬🇧United Kingdom rupertj Bristol, UK
I'm also getting this exact error when trying to create a finder from a module's install config. The change in my PR doesn't help in that case though, so I'm thinking it might not be the correct fix.
- 🇬🇧United Kingdom joachim
> Drupal\search_api\SearchApiException: The "date_recur:node__finders_events_date" plugin does not exist. Valid plugin IDs for Drupal\search_api\Datasource\DatasourcePluginManager
I think it might help to draw up a hierarchy of plugin dependencies.
The datasource is derived from the existence of the date_recur field which IIRC the events Finder type plugin will have defined.
Can you debug in DateRecurDatasourceDeriver to see why it's not seen at that point?
- 🇬🇧United Kingdom rupertj Bristol, UK
Ta. That was helpful.
I've figured out that the date_recur field doesn't exist because in Finder::ensureFinderConfig(), getEntryBundles() returns an empty array and then configureAsEntry() isn't called.
Stepping through, it seems that when the entity type is loaded, it's not found. Either this is some cache thing, or the entity type genuinely doesn't exist yet. This is a possibility as that's being created in this same config import.
- 🇬🇧United Kingdom joachim
I can't remember how much work I did on declaring config dependencies, but it's quite likely I was a bit lax about it. If those are in place, Drupal's config install system will know what to install in what order.
On the other hand, ✨ 3rd party should be allowed to add config dependencies Active aaaargh.
- 🇬🇧United Kingdom rupertj Bristol, UK
Adding a couple of dependencies for the content types for my exported finder fixes this issue:
langcode: en status: true dependencies: module: - finders_events config: - node.type.localgov_event - node.type.localgov_event_channel id: localgov_events label: 'LocalGov Events' type: events channels: node: - localgov_event_channel entries: node: - localgov_event
I get another error later in the install process but I'm not sure if it's related yet.
- 🇬🇧United Kingdom joachim
That's promising!
The Finder entity class needs to implement calculateDependencies() to declare these.
- 🇬🇧United Kingdom joachim
Maybe need an issue at date_recur_search_api to do the same to Drupal\date_recur_search_api\Plugin\search_api\datasource\DateRecur
.
- 🇬🇧United Kingdom rupertj Bristol, UK
This looks good to me. With the patch applied and the finder re-saved and exported, I get the same dependencies that I manually inserted.
Automatically closed - issue fixed for 2 weeks with no activity.