Problem/Motivation
As of #3056118: Remove deprecated code from Upgrade Status, Upgrade Status only uses deprecated APIs in tests. It does need to do that to test that it actually finds them. As such Upgrade Status cannot be made to run on Drupal 9 and pass its current tests, because the deprecated APIs it is testing with are removed in Drupal 9. The time of this writing, there are no deprecated Drupal 9 APIs yet, so there is no way to test that the module would perform the operations it is supposed to perform on Drupal 9.
That said, while it would be possible to slap a core_version_requirement
into the info file of the module and be done with it, it would be impossible to test that the module works on Drupal 9. We either need to wait on an API to get deprecated in Drupal 9 itself to have something to test against or figure out a workaround. For example, we can add our own test API that we deprecate for the sake of testing that we find when we use our own deprecated API.
Proposed resolution
1. Either wait for the first deprecation in Drupal 9 and adapt tests for that or
2. Add our own stub API that we deprecate so we can identify that finding it works. Then we can be Drupal 9 compatible cleanly.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#45 | 3100308-45.patch | 22.76 KB | Gábor Hojtsy |
#45 | interdiff.txt | 805 bytes | Gábor Hojtsy |
#44 | 3100308-44.patch | 22.7 KB | Gábor Hojtsy |
#44 | interdiff.txt | 8.05 KB | Gábor Hojtsy |
#41 | 3100308-41.patch | 25.11 KB | andypost |
Comments
Comment #2
rpayanmComment #3
nathandentzauRTBC +1 should probably get another pair of eyes on this and test.
Comment #4
rpayanmThe patch is on 8.x-2.x-dev.
Comment #5
Gábor HojtsyThese are explicitly included as deprecated API uses to test them. If we are fixing them then the tests will fail because we are not finding any deprecated APIs.
Steps for this issue, as explained in the proposed resolution is:
Since (1) did not happen and may not happen for a while AFAIK, (2) would be the best to do. Add some dummy API of our own that we deprecate and use and can test that we found the use of said deprecated API. That would make our testing Drupal major version agnostic. Unfortunately fixing the use of deprecated APIs while we are still testing to find them even though they are not there does not move us forward.
Also the project page (https://www.drupal.org/project/upgrade_status) has a link to #3100361: Remove usage of file_directory_temp() if its not available for Drupal 9 compatibility where the file_directory_temp() part of the patch would belong.
Finally the REQUEST_TIME fix looks like is in order regardless of major version compatibility, please open a new issue about that with that part of the patch, thanks a lot.
Comment #6
Gábor Hojtsy@lauriii also reported #3123824: Uncaught Drupal\Core\Extension\InfoParserException on Drupal 9
Comment #7
Gábor HojtsyOk I made the module Drupal 9 compatible in #3133544: Make Upgrade Status work on Drupal 9 (except tests), but tests are still not. So the module could theoretically be run on Drupal 9 but we cannot yet prove with tests, since our tests are heavily dependent on the availability of the Drupal 9 deprecated APIs in PHP, twig, etc. So this remains standing for full compatibility.
That said, there is no reason to run the module on Drupal 9 yet, so I am not very rushed to fix this ASAP. We need to have a plan for each area being tested how can we have version agnostic tests.
Comment #8
Gábor HojtsyComment #9
Kristen PolChecked patch from #2 in simplytest.me and get:
Fatal error: Cannot redeclare Drupal\upgrade_status\DeprecationAnalyzer::$time in /var/www/html.original/modules/contrib/upgrade_status/src/DeprecationAnalyzer.php on line 115
when going to:
/admin/reports/upgrade-status
. Moving back to "Needs work".Comment #10
Gábor HojtsyYeah I already committed the time property and use in #3133544: Make Upgrade Status work on Drupal 9 (except tests) and elsewhere based on @fgm's patch. I should have credited @rpayanm if I would have collated the issues. Sorry for that. The tests still need fixing, but not the way proposed here :) If we fix the deprecated API use we are testing for, then our tests will not find them of course.
So moving to active, since this is back to the drawing board.
Comment #11
ressa CreditAttribution: ressa at Ardea commentedEven though it is mainly an aesthetical issue, it would be nice to be able to check all modules, and get a sea of green error-free messages, by fixing the three errors :-)
Upgrade Status report
Contributed projects
Upgrade Status 8.x-2.7
Works on Drupal 9, even if there is no point yet. #3100308: Make Upgrade Status tests Drupal 9 compatible still stands.
Comment #12
Gábor Hojtsy@ressa: if the module would not report errors in its test code, then how would we test that it finds errors? Without errors?
Comment #13
ressa CreditAttribution: ressa at Ardea commentedI see, I thought they just needed some work to get fixed. But reading the Issue Summary closer, I now understand that they are meant to fail.
Comment #14
ressa CreditAttribution: ressa at Ardea commentedWhy not programmatically exclude the Upgrade Status module itself from the list of modules to check, under "Contributed projects" on
admin/reports/upgrade-status
?Comment #15
Gábor Hojtsy@ressa: do you have a patch proposal? We'd need to exclude it for the sake of runtime display then and not for the sake of testing.
Comment #16
Gábor Hojtsy@ressa: also that would still not make the tests themselves Drupal 9 compatible, so would not resolve the goal of this issue and therefore should be its own issue to have cleaner reporting.
Comment #17
ressa CreditAttribution: ressa at Ardea commentedGábor Hojtsy: Thanks for clarifying, I have created a new issue at #3152450: Exclude Upgrade Status module from it's own UI when not in tests.
Comment #18
andypostTests could use split depending on core version, OTOH it makes maintenance harder
Other way is redo tests for D9 and create 4.x release specifically for it
Comment #19
Gábor HojtsyMade some exploration to the extent of this. We are testing five things that are outside the bounds of this project:
Let's see how does this patch fairs for now. I added a @todo for the ones that need to be revisited. In particular 3 and 4 need some solution to make the module compatible with Drupal 9.
Comment #21
Gábor HojtsyThe fails were due to two things (a) we categorize errors by source version number for severity and using X.Y.0 did not fit that so did not pass that test, using a concrete version number for now (b) error line numbers of course changed where I added additional comments to file.
This passes locally. Still need to figure out what to do about the remaining 8 specific @todo items.
Comment #22
Gábor HojtsyRead up on the twig docs, and it is apparently possible to define our own deprecated filter to test that instead of raw. https://twig.symfony.com/doc/1.x/advanced.html#deprecated-filters -- would be great to get a helping hand in this. :)
Comment #23
Gábor HojtsyThe raw tag deprecation is very hard coded in src/Lexer.php:
I'll look into adding a custom twig filter though that we can check then. Fingers crossed.
Comment #24
Gábor HojtsyOk went by the samples at https://symfony.com/doc/current/templating/twig_extension.html -- this is not yet passing, but posting as a work in progress. Kept the raw usage for now until this passes.
Comment #26
Gábor HojtsyWoah, woah. Turns out the fail was due to the twig error regexp not matching line numbers other than 0-9 :D. That's not good, alright.
Comment #27
Gábor HojtsyNow removed uses of the raw tag, so we can be dependent of Drupal 8 / Twig 1 there too. Only WebTestBase left I think.
Comment #28
Gábor HojtsyAand now making it independent of WebTestBase also by defining our own deprecated base class. Wohoo!
Comment #29
Gábor HojtsyLet's allow to work on Drupal 9 in the info file so we can actually test with Drupal 9.
Comment #31
Gábor HojtsyDuh that puts the module into the "relax" category.
Comment #32
Gábor HojtsyShould update composer.json too so composer can install it.
Comment #33
Gábor HojtsyMeh, stray comma.
Comment #34
Gábor HojtsyWe can remove the "core: 8.x" from test info files on 8 without affecting how it is tested. This will at least uncover the next layer of fails on Drupal 9.
Comment #35
Gábor HojtsyMy limited grep did not find this 7.x core compatibility. It still does not affect D8 testing, let's see D9.
Comment #36
Gábor HojtsySo due to the added Drupal compatibility info for test modules, this will get categorized as relax. Wondering why the others did not come up first... Hm.
Comment #37
andypostUsed to run tests locally and getting other error in artifacts of HTML (end of batch scan screen)
User deprecated function: Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of upgrade_status_test_theme_function(). See https://www.drupal.org/node/1831138 in Drupal\Core\Theme\Registry->processExtension() (line 498 of core/lib/Drupal/Core/Theme/Registry.php).
CR https://www.drupal.org/node/2575445
Comment #38
andypostFiled related fix because I used to run on PHP 8 https://github.com/mglaman/phpstan-drupal/pull/163
Used to fix minors
-
DeprecationCollector
instead of\Twig_Util_DeprecationCollector
-
$modules
should be a protected property in test classesI did rename this function and moved it out of "no_error" module to upgrade_status_test_deprecated_function module
Could be added as protected method getDrupalCoreMajorVersion() to base test class
Comment #39
andypostFix remaining test but others could be broken because self deprecations will not fire
Comment #40
andypostIs 9.0 CR https://www.drupal.org/node/2909426
Additionally the
setUp()
method could use void type hint https://www.drupal.org/node/3114724 but it could use a follow-up to fix remaining self-deprecationsComment #41
andypostMake sure new test module also covered and has no errors
Comment #42
andypostProbably makes sense to add dependency on new module(
upgrade_status_test_deprecated_function
) toupgrade_status_test_contrib_error
andupgrade_status_test_error
Comment #43
Gábor HojtsyNot convinced that this needs to be its own module, it looks way too granular. Eg. the twig test modules both define and use their deprecated things. We can also just move the definition of this to the "contrib" "error" modules as an alternative (and if we want to super correct add a dependency to the "custom" module). The test deprecated base class is also in the error module.
Otherwise looks great, thanks!
Comment #44
Gábor HojtsyThere we go.
Comment #45
Gábor HojtsyActually I noticed one more accidental @andypost change. We intentionally test the 9.1 compatibility on one of the test modules. I don't think it would be a problem that 9.0 sites cannot run that test. Sites that run tests for deployment would usually not be outdated on 9.0 at this point.
Comment #47
Gábor HojtsyAll right, committed this!
Also credited @rpayanm for the $time replacement, because they were not credited for that elsewhere. (Even though that did not happen in this issue after all).
I opened #3201156: Make Upgrade Status logic make sense on Drupal 9 to continue with Drupal 9 to Drupal 10 support.
Comment #48
andypostThank you fixing remains! ++ latest changes