ECA Content knocks out "Promote content to front page" and "Make content sticky" Admin actions

Created on 17 February 2024, 4 months ago
Updated 8 March 2024, 4 months ago

Problem/Motivation

While building some ECA models today I notice by chance today that the following Bulk actions from the Content (/admin/content) page were simply doing nothing when applied:

  1. Promote content to front page
  2. Remove content from front page
  3. Make content sticky
  4. Make content Unsticky

This seemed to the same on several of my sites so I starting look for a culprit as I really didn't think it could be a core bug.

The sites where I saw the symptom were all using ECA.

After quite some time experimenting, I think that I have proved that the root of the problem is the ECA Content module. Eventually what I did was go back to a completely fresh Drupal 10.2.3 site and one-by-one I enabled the ECA modules until I the bug reared its head.

In short the results were...

ECA Core - All still OK
ECA Base - All still OK
ECA Content - Installing this stops both 4 of the above bulk actions from having any effect.

I repeated this again just to check and verified the behaviour.

System

Drupal 10.2.3
Web Server
Apache/2.4.33 (Win64) OpenSSL/1.0.2u mod_fcgid/2.3.9 PHP/8.2.2
PHP 8.1.15
Database
MySQL 5.7.24
PHP Caching module: OpCache

Thanks all.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom SirClickALot Somerset

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @SirClickALot
  • 🇬🇧United Kingdom SirClickALot Somerset
  • 🇩🇪Germany jurgenhaas Gottmadingen

    I can confirm this behaviour. This happens in \Drupal\eca_content\Plugin\Action\FieldUpdateActionBase::save where ECA tries to determine with empty($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 4 months ago
  • 🇩🇪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.

  • Status changed to Needs work 4 months ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Hmm, a test is broken, will have a look.

  • Pipeline finished with Failed
    4 months ago
    Total: 414s
    #101539
  • Pipeline finished with Success
    4 months ago
    Total: 467s
    #101594
  • Status changed to Needs review 4 months ago
  • 🇩🇪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 4 months ago
  • 🇩🇪Germany danielspeicher Steisslingen

    Yes, that sounds reasonable. Code looks fine as well.

  • Pipeline finished with Skipped
    4 months ago
    #102478
    • jurgenhaas committed b41fb449 on 2.0.x
      Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
    • jurgenhaas committed 4943b4e5 on 1.1.x
      Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
  • Status changed to Fixed 4 months ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Merged and back ported to 1.1.x

    • jurgenhaas committed 58724b89 on 1.1.x
      Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
    • jurgenhaas committed 792967cd on 1.1.x
      Issue #3422101 by jurgenhaas, SirClickalot, danielspeicher: ECA Content...
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Pipeline finished with Success
    3 months ago
    #138124
  • Pipeline finished with Success
    3 months ago
    Total: 275s
    #142917
Production build 0.69.0 2024