Problem/Motivation

The layout_builder test module no_transitions_css has an invalid hook_page_attachments definition.

/**
 * Implements hook_page_attachments().
 */
function settings_tray_test_css_page_attachments(array &$attachments) {
  // Unconditionally attach an asset to the page.
  $attachments['#attached']['library'][] = 'settings_tray_test_css/drupal.css_fix';
}

The test which uses it has a "@todo" to remove it after #2901792: Disable all animations in Javascript testing. However, its library never runs. It doesn't even load the settings_tray_test to accidentally load the library.

I discovered while working on a PHPStan extension to perform some analysis on Drupal core.

Note: Using configuration file /Users/mglaman/Drupal/sites/commerce2x/phpstan.neon.
PHP Fatal error:  Cannot redeclare settings_tray_test_css_page_attachments() (previously declared in /Users/mglaman/Drupal/sites/commerce2x/web/core/modules/layout_builder/tests/modules/no_transitions_css/no_transitions_css.module:13) in /Users/mglaman/Drupal/sites/commerce2x/web/core/modules/settings_tray/tests/modules/settings_tray_test_css/settings_tray_test_css.module on line 16

Fatal error: Cannot redeclare settings_tray_test_css_page_attachments() (previously declared in /Users/mglaman/Drupal/sites/commerce2x/web/core/modules/layout_builder/tests/modules/no_transitions_css/no_transitions_css.module:13) in /Users/mglaman/Drupal/sites/commerce2x/web/core/modules/settings_tray/tests/modules/settings_tray_test_css/settings_tray_test_css.module on line 16

Proposed resolution

Fix the hook name

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review
FileSize
841 bytes

Patch. PHPStan did not explode once this was applied.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Yep! This makes sense. I think it means that the test using this module is probably not good enough. We can look at that in a followup though. This already make the current (broken) situation better.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2901792: Disable all animations in Javascript testing

Given that the only thing this module does is supposed to implement this hook I think it must not be needed. Rather than fixing this and thereby changing the tests I think we should discuss completely removing this module. I think CSS transitions were more problematic in the PhantomJS days but the issue we need to look at is #2901792: Disable all animations in Javascript testing which seems to be based disabling all transitions.

Anyhow, no_css_transitions is enabled in \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTestBase which is used by \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTest and \Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockPrivateFilesTest and I've not seen random fails in these tests.

tedbow’s picture

I would say it could be removed. If we haven't got random failures in the test in all this time with the CSS not be active.

mglaman’s picture

Works for me to remove the test module. Wanted to make a patch fixing it first. Maybe a follow up can be made to remove the settings tray one after.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
3.37 KB

Agreed.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Removing dead code is always a win, I think.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed c00be4c49c to 8.7.x and 1f4544c992 to 8.6.x. Thanks!

Backported to 8.6.x as the test module is similarly useless there :)

  • alexpott committed c00be4c on 8.7.x
    Issue #3020142 by mglaman, tim.plunkett: Test module no_transitions_css...

  • alexpott committed 1f4544c on 8.6.x
    Issue #3020142 by mglaman, tim.plunkett: Test module no_transitions_css...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tim.plunkett’s picture

Issue tags: +Blocks-Layouts

Retroactively tagging