- Issue created by @SirClickALot
- 🇩🇪Germany jurgenhaas Gottmadingen
I can confirm this behaviour. This happens in
\Drupal\eca_content\Plugin\Action\FieldUpdateActionBase::save
where ECA tries to determine withempty($entity->eca_context)
whether the field change was called from within an ECA model or not. When using the bulk form, it appears that$entity->eca_context
equals TRUE, which should not be.Will have to dig deeper to find out what's wrong with this.
- Status changed to Needs review
11 months ago 11:08am 22 February 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
The flag, that an entity was related to an entity event, was set too broadly. Also, the method that was used is deprecated in PHP 8.2 since we used a dynamic property.
This is now replaced by an entity stack that only gets filled, if the entity event really got dispatched. If not, our set field value class can now properly determine, that NO eca model was involved and will correctly save the entity.
- Merge request !405Issue #3422101 by SirClickalot, jurgenhaas: ECA Content knocks out "Promote... → (Merged) created by jurgenhaas
- Status changed to Needs work
11 months ago 11:31am 22 February 2024 - Status changed to Needs review
11 months ago 1:56pm 22 February 2024 - 🇩🇪Germany danielspeicher Steisslingen
jurgenhaas → credited danielspeicher → .
- 🇩🇪Germany jurgenhaas Gottmadingen
I've taken a completely different approach, the entity stack from the first approach didn't work out. The reason is that the action plugins, that set field values on entities behave differently in ECA context than outside: inside ECA, the action plugin can be configured such that the entity should be saved or not when the field value has been set. For action plugins that don't have that configuration option (like core's promote and sticky actions), ECA assumes the default value, i.e. not to save the entity after changing the field value.
However, if those plugins run outside ECA, e.g. as a bulk action, then the entity needs to be saved, otherwise the changes would be saved.
Therefore, I've now added a method
isEcaContext()
in the ECA processor, which can tell if the current stack trace is within an ECA processing event or not. That works 100% reliable in real life.However, this failed for some tests, since they call the set field value action plugin without going through the processor. For that special case I've now also added a state value, which simulates that context for those tests.
@danielspeicher, is that acceptable from your point of view?
- Status changed to RTBC
11 months ago 1:32pm 23 February 2024 - 🇩🇪Germany danielspeicher Steisslingen
Yes, that sounds reasonable. Code looks fine as well.
-
jurgenhaas →
committed b41fb449 on 2.0.x
Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
-
jurgenhaas →
committed b41fb449 on 2.0.x
-
jurgenhaas →
committed 4943b4e5 on 1.1.x
Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
-
jurgenhaas →
committed 4943b4e5 on 1.1.x
- Status changed to Fixed
11 months ago 2:12pm 23 February 2024 -
jurgenhaas →
committed 58724b89 on 1.1.x
Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
-
jurgenhaas →
committed 58724b89 on 1.1.x
-
jurgenhaas →
committed 792967cd on 1.1.x
Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
-
jurgenhaas →
committed 792967cd on 1.1.x
Automatically closed - issue fixed for 2 weeks with no activity.