Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Followup from #3164721: More uses of public static $modules. We have existing patches in the queue that might still use public static $modules, but the property should now be protected instead. We can add a check to do this, as per @mondrake:
We might prevent regressions by adding a check of the visibility of the property in DrupalListener::startTest, and throwing in exception in case it’s public.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#7 | 3165588-7.patch | 707 bytes | longwave |
#7 | 3165588-7-test-only.patch | 3.31 KB | longwave |
Comments
Comment #2
longwaveFirst attempt at this. I tried to write a test but any exception must be thrown by the test method itself, exceptions thrown directly in the listener aren't caught. I also tried using warnings instead of exceptions but that didn't seem to work either. Maybe this is enough on its own?
Comment #3
heddnThis looks good.
Comment #4
mondrakeAdded this issue to the CR https://www.drupal.org/node/2833984
Comment #5
mondrakeMaybe let's just have a test-only patch with a test class failing to have a
protected $modules
property, to demonstrate that we actually get a failure.Comment #6
mondrakeSecond thinking (sorry) - maybe we shoud throw a deprecation error, not an exception - I am afraid many contrib modules would start failing badly.
Comment #7
longwaveAddressed #5/#6. Agree that a deprecation error rather than hard fail is better, for now at least. Maybe we should revisit in Drupal 10.
Reverted #3164721: More uses of public static $modules as the test only patch.
Comment #9
mondrakeThanks @longwave
Comment #11
catchDeprecation is a good idea.
Committed cb0ad5b and pushed to 9.1.x. Thanks!
Comment #13
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThis was only committed to 9.1.x but according to the second CR https://www.drupal.org/node/2909426 $modules should be protected from 9.0.0. So can we either
(a) backport the check to 9.0.0, or
(b) alter the CR to say that it only has to be protected from 9.1.0
It needs to be clear, because I am finalising the coding standards fixes for @trigger_error format on #3048495: Fix Drupal.Semantics.FunctionTriggerError coding standard and the message currently thrown has no versions at all. We can waste developer time if the message is not precise and we have to go hunting to find out what is actually is meant. Thanks.
Comment #14
xjm@jonathan1055 I made this addition to the CR to address that question: https://www.drupal.org/node/2909426/revisions/view/12095831/12104390
This is definitely too disruptive to be backported to the production branch.
Comment #15
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThat's fine. Thanks for the clarification @xjm.