Problem/Motivation
Unit tests based on BrowserTestBase and KernelTestBase have a $modules property that allows to specify the modules that should be enabled before executing the tests. This property had always been intended to be protected, and it was declared as such in the two base classes.
However in practice many tests in Drupal core changed the visibility to public. Over time this problem became worse, mainly because some popular base classes (such as EntityKernelTestBase) were changing this property public, forcing all their child classes to make this property public as well. While there is no harm in making this property public, it is useless and the need to check the actual visibility to use when writing a test was resulting in lost developer time.
This property should now always be protected.
Make $modules protected on BrowserTestBase and KernelTestBase.
Use the next script to prepare changes for the patch:
# find PHP files in "tests" or "Tests" or "simpletest" directories
# replace 'public static $modules' with 'protected static $modules'
# replace 'static public $modules' with 'protected static $modules'
find . -path './.git' -prune -o -name '*.php' -type f \( -path '*/tests/*' -or -path '*/Tests/*' -or -path '*/simpletest/*' \) -exec sed -i -e 's/public static $modules/protected static $modules/g; s/static public $modules/protected static $modules/g' {} \;
Proposed resolution
During the RC time window generate the patch using the script and apply changes. Follow #33 #49
Remaining tasks
Prepare script and be sure that it will cover all places where replacements are required.
Do not skip the time window
Current development cycle
Current window is: April 13 to April 17, 2020
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#134 | 2822382-9.0.x-134.patch | 1.18 MB | jungle |
#134 | 2822382-9.1.x-134.patch | 1.18 MB | jungle |
Comments
Comment #2
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedadding patch.
Comment #3
dawehnerThank you!
Comment #5
sidharthapUpdated one.
Comment #7
tim.plunkettComment #8
erozqba CreditAttribution: erozqba commentedThis patch makes every $modules property protected on tests classes not only in on classes extending BrowserTestBase and KernelTestBase.
I don't really know if this applies only to classes that extend BrowserTestBase and KernelTestBase, so I will submit this patch and work in other that only makes every $modules property protected only on classes extending BrowserTestBase and KernelTestBase.
Comment #9
erozqba CreditAttribution: erozqba commentedComment #10
erozqba CreditAttribution: erozqba commentedThis one only makes every $modules property protected only on classes extending BrowserTestBase and KernelTestBase.
Comment #12
erozqba CreditAttribution: erozqba commentedRemaking patch after failing to test after some changes in the classes. This patch one only makes every $modules property protected only on classes extending BrowserTestBase and KernelTestBase.
Comment #13
erozqba CreditAttribution: erozqba commentedComment #15
erozqba CreditAttribution: erozqba commentedReroll patch in #2822382-7.patch
Comment #16
dawehnerFor me this seems to be not complete:
Comment #17
erozqba CreditAttribution: erozqba commentedHi @dawehner, I'm not sure of the scope of the patch, so I have made two possible patch 2822382-6.patch and 2822382-15.patch.
The first one "2822382-6.patch" makes every $modules property protected on tests classes not only in on classes extending BrowserTestBase and KernelTestBase.
The second patch 2822382-15.patch make every $modules property protected only in classes extending BrowserTestBase and KernelTestBase.
Could you please be more clear about wich patch have you tested and why do you thinks is not completed? Maybe a list of files where the change should be made and the current patch is not making it?
Thanks a lot in advance.
Comment #18
klausiAfter applying the last patch for example core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/ContextualFilterTest.php is not changed, so we should also convert all JavascriptTestBase tests here.
Comment #19
dawehnerYeah I think the scope of this issue would be to change everything which extends
\PHPUnit_Framework_TestCase
.Comment #21
erozqba CreditAttribution: erozqba commentedReroll patch in #2822382-6.patch, makes every $modules property protected on tests classes.
Comment #22
catchThis going to introduce a lot of merge conflicts between 8.2.x and 8.3.x tests, so postponing it for some point after beta/rc (and probably after the webtestcase conversions on the assumption there'll be some conflicts there too).
Comment #23
xjmI think the same regex will also fix the former WTB tests after they are converted to BTB, so we should easily be able to schedule this patch for 8.3.x RC once the big important WTB conversion has been done.
Comment #26
pfrenssenWe are now in RC state so I guess this is the right time to reopen this.
Comment #27
dawehnerYou missed two entries:
:)
Otherwise +1 for getting it in. In general I think the amount of patches which add modules to existing tests are manageable.
Comment #28
pfrenssenWell spotted, these had slipped through my regex because the order of the visibility and the static modifier were switched.
Comment #29
dawehnerThat's why I'm too lazy with my regex knowledge and just use grep :P
Comment #31
pfrenssenComment #32
pfrenssenOh sorry this was already RTBC.
Comment #33
xjmYikes, caught myself just before clicking the dreditor button on this one. Massive cleanups like this are ideally rc targets. Tagging for now; haven't reviewed yet.
Comment #34
xjmOkay, unsurprisingly, this thing does not apply. I'm even struggling to find a commit that it does apply to; I thought the CI job would include it (it does for branch tests) but it doesn't here. I finally found 5ce32930 on 8.5.x for the earlier patch in #26.
Untagging 'Novice'; there is no such thing as a 1 MB novice patch.
I strongly recommend putting the commit hash for the thing in the next reroll. I think we should also schedule this change so we can actually get it in. We'll want to have both 8.5.x and 8.4.x versions (they might not be the same) to keep the branches in sync. Ideally we would have done this in beta instead since it's an internal BC break (CR please?) but how about we do it tomorrow or so before the next RC? If we can draft a CR by then and generate a new patch. I'll check back by tomorrow.
Here's a quickly hacked-together porcelain script to check the patch:
porcelain.php
contains:Right now this shows a couple test files with nonstandard-ish names, and (since I used #26) what @dawehner pointed out in #27:
Comment #35
pfrenssenCreated draft CR: https://www.drupal.org/node/2909426
Comment #36
pfrenssenHere are the updated patches. The 8.4.x patch is against commit e77fec14, 8.5.x is against aa7c4ab0.
Comment #37
pfrenssenMind that this is pretty hard work to roll, it's not a matter of simply running a regex like suggested in the issue summary.
Comment #38
pfrenssenI dug in the log files on Jenkins to find the error:
Unfortunately I don't have time to work on this until Drupalcon.
Comment #39
pfrenssenScrew my lack of time, let's keep momentum on this, here is the updated patch!!
Comment #40
borisson_This has slipped trough and wasn't committed on the dates mentioned in the title, should we target this for the next rc phase?
Comment #41
dawehnerYeah I guess we need to wait for another half a year :(
Comment #42
jofitz CreditAttribution: jofitz at ComputerMinds commentedPatch from #39 no longer applies. Copying over (and updating) patch from duplicate issue #2918296: Change all instances of $modules to protected.
Comment #43
dawehnerI think we should ask the release manager about the next slot for this kind of change. I believe it would be a bit of a troll to continuously reroll it.
Comment #44
dawehnerComment #45
xjmWhoops we missed our window. Disruptions like this should happen during beta or RC. The next beta will be released Feb. 7. Thanks!
Comment #46
dawehnerThank you jess! I set me a calendar entry for end of January to motivate someone to reroll the patch and ping a committer, let's see whether this works :)
Comment #47
RytoEX CreditAttribution: RytoEX as a volunteer commentedShouldn't the date in the title be February 7, 2018?
Comment #48
dawehnerYou are absolutely right!
Comment #49
xjmThat works. Note that RC is only two weeks this time around, rather than four. So we should prepare this during the beta and plan to have it done at least a week before the minor release if we want to get it in this time around.
Comment #50
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedComment #51
dawehnerI just me a personal calendar entry to get someone to do it in that timeframe :)
Comment #53
borisson_We're now inside the window to be able to do this. I executed the script in the description, on my mac this left a bunch of files
*.php-e
. I usedgit clean -fd core
to remove all of those.The result is attached here. No interdiff as this is just the result of that script.
Comment #55
volegerRerolled
Comment #56
volegerFatal error: Access level $modules must be public
Fixed access level for base classes and classes that extends that base classes.
Comment #57
Anonymous (not verified) CreditAttribution: Anonymous commentedThe failures are due to the fact that the WTB tests in the BTB location. Perhaps, if we can quickly convert them - then we will not need to enter special rules for them. I will now create the necessary issues.
Comment #58
voleger#2946419: Entity: Convert system functional tests to phpunit
Comment #59
Anonymous (not verified) CreditAttribution: Anonymous commentedOne more issue :)
It got two issues. Because #2946419: Entity: Convert system functional tests to phpunit is actually should be child of #2862508: Convert system functional tests to phpunit.
#56: Hm.. SearchSimplifyTest is green localy.
Comment #60
Anonymous (not verified) CreditAttribution: Anonymous commented#56/#59
The reason of fail - just an new extra blank line at the end of UnicodeTest.txt :)
Comment #61
volegerNeeds new time window update.
BTW #2946425: Correcting the tests that lie in BTB but using WTB fixed
Comment #63
RytoEX CreditAttribution: RytoEX as a volunteer commentedPer #45 and #49, it seems this should be done during beta or RC. 8.6.0-alpha1 is nearly upon us, and 8.6.0-beta1 is due the Week of July 29, 2018. Based on previous windows, it seems like this should be done between July 29, 2018 and August 20, 2018 (from beta phase begin to one week after rc phase begins), so I've adjusted the issue title accordingly. If that window is wrong, please feel free to correct it.
@xjm and @dawehner : What needs to happen to get this one done?
Comment #64
pfrenssen@RytoEX it will need to be redone from scratch.
Note that this can best be coordinated with a core committer to minimize the turnover time. There is always a possibility that a new commit to core touches one of the tests being patched, or introduces a new public property, and the patch will need to be rerolled.
Comment #65
volegerSure, but before that window, we should be sure that tests will pass after applying.
Reroll patch using the script.
Comment #66
volegerI had tested different script for patch generating:
- from Issue Summary:
- and little bit changed:
So, the only difference between the scripts is that script from IS also update non-related files:
/core/modules/migrate_drupal_ui/tests/src/Functional/d6/files/core/modules/simpletest/files/image-1.png
/core/modules/migrate_drupal_ui/tests/src/Functional/d6/files/core/modules/simpletest/files/image-test.png
/core/modules/system/tests/fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update.php.gz
/core/modules/system/tests/fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update_mul.php.gz
/core/modules/system/tests/fixtures/update/drupal-8.0.0-rc1-filled.standard.entity_test_update_mul_rev.php.gz
/core/modules/system/tests/fixtures/update/drupal-8.2.0.bare.standard_with_entity_test_revlog_enabled.php.gz
/core/modules/system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz
/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz
/core/modules/system/tests/fixtures/update/drupal-8.filled.standard.php.gz
/core/tests/fixtures/config_install/testing_config_install.tar.gz
Comment #67
volegerHere is the regenerated patch
Comment #68
volegerLooks like the updated script works as expected.
Comment #69
pfrenssenThanks for starting the work on this! I had a quick look. I have two remarks so far:
Here is the list of files that came up when I did the following grep. This list is manually curated since the grep yields many false positives.
$ grep -nr modules core/ | grep public | grep -i test
List of files that still contain the public property:
Comment #70
Lendude@pfrenssen these remaining files all appear to be unconverted webtests
edit:Ah you pointed that out already :)
Comment #71
RytoEX CreditAttribution: RytoEX as a volunteer commentedIt seems the missed occurrences pointed out in #69 are due to the case-sensitivity of the find command used. I've adapted the command to check for paths containing '*/tests/*', '*/Tests/*', and '*/simpletest/*', and to replace both "public static $modules" and "static public $modules" with "protected static $modules". I then ran a series of checks on the resulting patch file to (hopefully) ensure that no unintended changes were introduced and check the resulting codebase to (hopefully) ensure that there were no more instances of "public static $modules" or "static public $modules". I did this for both 8.6.x and 8.7.x Patches and interdiff with #67 (against 8.7.x) are attached.
Per the request in comment #34, here are the commit hashes the patch was based on for each branch:
Here's hoping I did this right and all tests come back green.
Comment #72
RytoEX CreditAttribution: RytoEX as a volunteer commentedAll tests passed. Please feel free to check that I made all the necessary changes. Although this will probably need re-checked before committing, it seems fairly trivial to script the patch creation (if I got this right). Forgot to set to "Needs review" earlier, so setting that now.
Comment #73
volegerThere is the script based on the latest comments
Comment #74
volegerfind . -path './.git' -prune -o -name '*.php' -type f \( -path '*/tests/*' -or -path '*/src/Tests/*' -or -path '*/simpletest/*' \) -exec sed -i -e 's/public static $modules/protected static $modules/g; s/static public $modules/protected static $modules/g' {} \;
Optimized script and regenerated patches.
And still, we need IS update.
Comment #75
volegerinterdiff files are incorrect as they were generated on restructured revisions
the manual search showed that there are no one unprocessed "public static $modules" lines.
Comment #77
volegerwrong patch for 8.7.x in #74
Comment #78
RytoEX CreditAttribution: RytoEX as a volunteer commented@voleger
For reference, the script I used to do the patch generation was nearly identical to yours. I'd initially done multiple passes, but eventually switched to this:
That takes about 3.5 minutes on my machine on a clean 8.6.x or 8.7.x branch. To check the resulting patch file, I run this script from within the Drupal directory, specifying the patch file as the only argument:
If it outputs nothing, then the patch (and code base) are fine. That takes less than a minute.
As an aside, it looks like some commits from earlier today have added new files that need to be processed by these scripts before commit. Rather than continuously reroll, let's get someone's attention on this to make sure our scripts are actually making the right changes, so that the patches can be rerolled closer to when a committer can work on this.
Comment #79
volegerActually, the goal of this issue is to prepare the script that will correctly generate the changes to create a proper patch before the nearest time window.
So, I agree with @RytoEX that we should focus on the script at the current point.
I can confirm that the current version of the script from IS cover all required replacements.
Comment #80
volegerComment #81
RytoEX CreditAttribution: RytoEX as a volunteer commentedI thought the goal of this is to produce a patch to be committed? The scripts just facilitate that.
Why does the script in the IS use '*/src/Tests/*' instead of just '*/Tests/*'?
Setting back to Needs Review.
Comment #82
volegerbecause this is the part of namespace of WTB.
this issue has tag "rc target", so that's means that patch can be applied only during RC window.
please follow #33, #49 to understand why the time window is so important.
Updated IS
Comment #83
RytoEX CreditAttribution: RytoEX as a volunteer commentedNamespaces use backslashes. Unix paths use forward slashes, and the path argument for find uses paths, not file contents. I'm still confused on this point.
I have read the issue, and I do understand why the time window is important (I even proposed the current time window). My point here was that eventually a patch needs to be committed, regardless of how it is produced. A script is just probably the best way of producing a patch for this particular issue.
In any case, as I said before, I think what would help most here is a committer confirming that the patch is on the right track, and confirming the window for action, since I'm not 100% confident in the window that I provided (it is based on previous windows).
Comment #84
borisson_It should be done after the first RC release is tagged. According to https://www.drupal.org/core/release-cycle-overview, this will be august 13.
In any case, I think it's a good idea to have a script that produces the correct output, because hopefully a few more test conversions will land before the first RC.
Comment #85
volegerreminder
we are in the required time window
Comment #86
volegerup
Comment #87
volegerComment #89
volegerUpload correct patch for 8.6.x
Comment #90
tstoecklerLooks good to me:
Comment #91
catchCommitted/pushed to 8.7.x and cherry-picked to 8.6.x. Thanks!
Comment #92
xjmI had to revert this in order to revert #2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder for a critical regression. Sorry everyone! That said though this should not have been committed during the RC commit freeze; I think @borisson_ misunderstood the dates in the chart a little. :) This is the week of the commit freeze for the RC. The RC phase starts only after we release the RC and freeze for about 12-24h more to ensure there aren't any hotfixes we need.
We haven't released the RC yet, so this should wait another day before we reroll it. Retitling to the correct timeframe for an RC target. :) Thanks!
Comment #93
xjmAlso the commit freeze for release starts before release. :)
Comment #94
neclimdulCould we update the IS with why too? Seems strange such a large patch has no reasoning which I assume is just lost offline discussions.
Comment #95
xjm@neclimdul, the change record explains it pretty well: https://www.drupal.org/node/2909426
I've added the CR's text to the IS.
Are you thinking that the patch scope is too disruptive this close to release? Maybe we should consider just making it a beta target instead, since the length of the RC phase has been halved since the issue was originally scheduled last year. E.g. we made #2981652: [Aug. 9 2018] Format core JavaScript using recently add Prettier a beta target instead of an RC target based on this. I'll ask for another committer's opinion.
The CR will need to be updated as it mentions Drupal 8.4.0.
Comment #96
catchI think patches like this are OK during the beta too, the dates on the issue title made me thing 'end of beta', not 'during rc'.
Comment #97
pfrenssenOK then this is no longer postponed I guess?
I really would like this to get in now that we are so close :)
@xjm which update is needed for the CR? I reviewed it but it still seems OK to me. I can make changes if needed.
Comment #98
xjmStill postponed on the RC being released (it hasn't yet) +24h (so at least Saturday). :)
@pfrenssen, the change record simply needs to have version numbers corrected. It says things like "prior to 8.4.0", but the change is actually going to be in 8.6.0 instead.
@catch and I discussed this and agreed that with the current release cycle these issues should be beta targets (as the prettier JS conversion was); however, since this one is close, we are okay with it going in early during RC. Adjusting the time window based on that. If somehow we don't get to it this cycle it'll be a beta target.
Also, for changes of this magnitude that disrupt many patches, we usually do a g.d.o/core announcement a few days in advance letting contributors know the change will be made. See https://groups.drupal.org/node/534209 for an example. Can someone draft this announcement? We could target Tuesday, August 21 if the above contributors are available then to reroll it. That would give contributors enough lead time to know when their patches need a reroll, and be guaranteed to be after the RC freeze.
In the future I'd suggest tagging for release manager review again just to confirm the details of the cycle, and ping one of us if it's time-sensitive. :)
Thanks everyone!
Comment #99
pfrenssenUpdated the change record. Here is a proposed announcement:
Comment #100
xjmThanks @pfrenssen, that looks pretty good! One thing we need to know before posting is, what date this coming week? We should have a day that a patch author, reviewer, and committer are all available to land it.
One other question I have before we go ahead is: How do we plan to keep this from regressing? E.g., is this something we could add a PHPCS rule for? There are probably a lot of patches in the queue with new tests that have the property as public. It's a small difference that is easily missed in patch reviews.
Finally, do we have a count of how many tests have public vs. protected? I'm assuming a lot more are (correctly) protected, but it would be good to document this.
Updated announcement text:
Thanks!
Comment #101
neclimdulWasn't a big deal and don't have feelings about when its committed. Just came looking for more explanation than was in the commit but the IS and discussion didn't provide it. Thanks!
Comment #102
pfrenssenI don't think a PHPCS rule is the right approach for this. This is an OO convention, not a coding standards violation. It would also set a dangerous precedent that would open the floodgates to request rules for every public / protected property in core.
We _could_ add some lines in the test base classes to check the visibility of the property using reflection. But I'm conflicted on this, since for consistency we should then also do the same for all other properties used in test classes. I would be fine with making an exception for this case though. We don't often change visibility of a property.
I think the best approach would maybe be to just keep an eye out for it during reviews. I think this counts for all inherited properties, checking if the visibility matches the parent hierarchy is a part of the due diligence when reviewing patches. The main problem was that most tests were using the (incorrect) public visibility and this was being copy/pasted into new tests. Also a number of popular base classes had set the visibility to public, and then it becomes illegal in PHP to make it protected again in classes that inherit it. I think this was the main cause of the wide proliferation of the public property.
I did a quick rough check and the result is pretty surprising. It seems that the large majority of tests have deviated from the protected visibility that is defined in the test base classes:
Setting this back to active since we are now in the approved time window.
Comment #103
volegerComment #104
tstoecklerSame review as in #90 yields the same result as in #90. Also skimming the patch reveals nothing unexpected. -> RTBC
Thanks!
Comment #105
RytoEX CreditAttribution: RytoEX as a volunteer commentedThe patches from #103 also pass my tests from #78 which attempts to validate the changes in the patch files and checks the Drupal source for 'public static $modules' and 'static public $modules'. LGTM
Comment #106
volegerrerolled
6 days remaining
Comment #107
voleger2 days remaining
Comment #108
volegerThe last day of the available window
Comment #109
volegerComment #110
volegerI hope we still have the time to get it in.
Comment #111
volegerComment #112
borisson_Looks like we're going to have to do this for the RC-window of 8.7.x.
Comment #113
volegerComment #114
pfrenssenA very very big thank you to @voleger for all the work to try to get done in time!! Too bad we didn't make the window.
We'll give it another shot in January.
Comment #115
heddnWhat's the next date/time to make this land?
Comment #116
apadernoBasing on #98, I would say this is the next available time.
Comment #118
Krzysztof DomańskiComment #119
alexpottThe release date of 8.7.0 is May 1st according to https://www.drupal.org/core/release-cycle-overview
Comment #120
apadernoI take this is still a 8.7.x task, so far.
Comment #122
pfrenssenUpdated title and issue summary with the next available window of opportunity.
Comment #123
andypostAs for 8.9 beta
Comment #124
volegerMaybe we are able to perform changes in the different time window? See #3107732: Add return typehints to setUp/tearDown methods in concrete test classes
Comment #125
apadernoGiven the new dates, isn't this a task for the 9.0.x branch?
Comment #126
jungleAgree that what we need is the patch, not just the script helping generate the patch.
First time to use the script in IS, it generated me .e files. Instead of using the script. I made the patch with the find and replace feature of PHPStorm
static public $modules
with file mask*.*
, 0 match.public static $modules = [
with file mask*Test.php
, and replaced withprotected static $modules = [
public static $modules = [
with file mask*TestBase.php
, and replaced withprotected static $modules = [
public static $modules = [
with file mask*.php
, and replaced withprotected static $modules = [
(6 files. They do not follow the naming conversation)public static $modules =
with file mask*.php
, and replaced withprotected static $modules =
(Due to\Drupal\Tests\field\Kernel\Migrate\d6\MigrateFieldInstanceOptionTranslationTest::$modules
, its opening[
is at the next line)public static $modules
with file mask*.*
, 0 match.To verify changes only made to Kernel tests, Functional tests and FunctionalJavascript tests.
foo.txt
by usinggit status
./Functional/
,/Kernel/
,/FunctionalJavascript/
,/FunctionalTests/
,/KernelTests/
and/FunctionalJavascriptTests/
with/***/
(or any other string unique) one by one/***/
(by searching again, it should show the results found, used Atom), it should matchthe total lines of changed files - 1
.core/modules/system/src/Tests/Ajax/AjaxTestBase.php
does not match any of the above.Comment #127
junglecore/modules/jsonapi/tests/src/Functional/MenuLinkContentTest.php is recognized as a binary file, that's why the patch failed to apply in #126, a new issue filed.
Comment #128
jungleUsed
git diff --text
generated the patch this timeComment #129
jungleA patch for 9.0.x
Comment #130
voleger@kiamlaluno you are correct. But changes has to go into the 9.0.x and 9.1.x as well.
@jungle thanks for reroll and patches for both branches. Looks good for me. But I'll keep needs review till expected time window. Potentially new test may appear at that period of time.
April 13 - April 17 is the closest available time window to commit this patch?
Comment #131
volegerCorrect the title change if I'm wrong, but the issue #3107732: Add return typehints to setUp/tearDown methods in concrete test classes set the time window for the similar reasons as I understand.
Comment #132
daffie CreditAttribution: daffie commentedBoth patches needs a reroll.
Comment #133
jungleComment #134
jungleRerolled, thanks @daffie for reviewing!
Comment #135
alexpott@jungle the patches can be applied to either branch so there's no real difference between them. In such cases a single patch is preferred because there is less for reviewers to think about. You can queue a patch to test on other branches. I'll queue the 9.1.x against 9.0.x.
Comment #136
jungleActually, I was thinking the same, yesterday. but after checking by.
Found that besides the follow one:
the rest are all similar to the below.
Not sure whether the difference between the two patches of EntityCrudHookTest matters. so uploaded two.
Comment #137
alexpott@jungle git is able to resolve that and still apply the patches... it's patch cruft.
Comment #138
daffie CreditAttribution: daffie commentedAll the code changes looks good.
All the
static $modules
occurrences are now set to protected. For both 9.0 and 9.1. Used a full projects search.Both patches get a RTBC from me.
Please commit this fast as I do not like to do this again. It is not fun to do.
Comment #139
alexpottAs we've already done #3107732: Add return typehints to setUp/tearDown methods in concrete test classes today let's get all the massive test disruption out of the way in one go.
Committed and pushed 6bf02d966d to 9.1.x and d1512f59db to 9.0.x. Thanks!
Comment #142
pfrenssenVery nice to see this in finally! Thanks all for the concerted effort!!
Comment #144
Taran2LWell, this change makes it impossible to have tests that work for 8.x and 9.x when specifying $modules. This is not good.
Update: I guess this should be backported to 8.9, no?
Update #2: I can set visibility to public of course, but the whole point of this issue is to stop doing this
Comment #145
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commented@Taran2L
I don't know if things have changed since your comment three months ago, but at the moment tests which extend
KernelTestBase
orBrowserTestBase
do run OK at 8.8, 8.9 and 9.0+ with protected $modules.There is a problem with tests that extend
EntityKernelTestBase
as these fail at 8.8, 8.9 with protected $modules and have to remain public, which then fails with deprecations at 9.1 only (ok at 9.0)Comment #146
TR CreditAttribution: TR commented@jonathan1055: There are still over 2000 tests in core D8 that use public instead of protected. Of these, more than 100 are test base classes. Any contributed module that extends one of these test bases will have a problem because the change from public to protected is required for D9.1+ but will fail in D8. Affected contributed modules can't support D8 and D9.1+ at the same time.
Note there are still NEW tests/test bases being added to D8 that have this error, for example:
core/tests/Drupal/KernelTests/Core/Field/MapBaseFieldTest.php
which was created just four months ago.This started out as a D8 issue and was moved to D9 at some point then D8 was thrown aside and instead of being backported to address the original issue, this issue was closed when it was "fixed" in D9. And it still took more issues to fix more instances of public that were snuck into D9 over the years (for example #3164721: More uses of public static $modules).
In D9.1.x, we have finally enforced this at the CI level (#3165588: Add a check to ensure $modules property is always protected), but now the workaround of using public in contrib no longer works. So contrib can be broken in 9.1 or can be broken in 8.9, but can't work in both.
This has been a five-year long effort, and we keep going backwards in D8. Already so much work has been wasted. In order to fix this we would need to start over again.
Just have to wait until D8 EOL I guess, then it won't be a problem anymore right?