Problem/Motivation
Drupal core still calls deprecated APIs. We have tools to identify them and help us reduce deprecated API use. Some use will be left due to the need to test deprecated code, and things we cannot remove before Drupal 9. This issue is to track progress and identify issues left to resolve.
Proposed resolution
Track progress using phpstan, categorize issues as appropriate.
Remaining tasks
-------------------------------
Errors in need of review: 15 (7 distinct)
Errors found in legacy tests: 416 (282 distinct)
Deprecated code called from deprecated code: 20 (10 distinct)
Known errors postponed on Drupal 9 branch opening: 65 (30 distinct)
Autoloading errors: 24 (24 distinct)
Cache tag unclear errors: 4 (4 distinct)
-------------------------------
Errors in need of review:
4 | 3cdb8a | Instantiation of deprecated class Drupal\migrate\Plugin\migrate\process\Migration | #3004929: Fix 'The Drupal\migrate\Plugin\migrate\process\Migration is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate\Plugin\migrate\process\MigrationLookup' (currently blocked on #3004927: Create Migration Lookup and Stub services
1 | a901dc | Call to deprecated method getStyleSheetsRemove() of class Drupal\Core\Theme\ActiveTheme in core/lib/Drupal/Core/Asset/AssetResolver.php on line 167 | #3069052: Properly deprecate the stylesheets-remove key from theme info.yml files.
1 | 739c76 | Call to deprecated method handleHiddenType() of class Drupal\Core\Entity\EntityDisplayBase in core/lib/Drupal/Core/Entity/EntityDisplayBase.php on line 256 | #3082644: Properly deprecate type => 'hidden' component handling and EntityDisplayBase::handleHiddenType
1 | 302b29 | Call to deprecated method prepareComment() of class Drupal\comment\Plugin\migrate\source\d6\Comment in core/modules/comment/src/Plugin/migrate/source/d6/Comment.php on line 37 | #3069055: Undeprecate Drupal\comment\Plugin\migrate\source\d6\Comment::prepareComment()
-------------------------------
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A.
| Comment | File | Size | Author |
|---|---|---|---|
| #75 | 3038170-7.patch | 1.72 KB | gábor hojtsy |
| #71 | 3038170-7.patch | 1.72 KB | gábor hojtsy |
| #69 | deprecations.txt | 55.03 KB | gábor hojtsy |
| #69 | coredeprecations.php_.txt | 8.62 KB | gábor hojtsy |
| #66 | coredeprecations.php_.txt | 8.61 KB | mikelutz |
Comments
Comment #2
MixologicComment #3
jibranWhile using phpstan locally memory is my biggest concern. Are only adding phpstan support or would we be using https://github.com/mglaman/phpstan-drupal?
Comment #4
MixologicThis is a test issue where we've added support for phpstan provisionally to drupalci. Memory on the testbots is pretty gargantuan (60GB), so its also one of those things where its a good place to have it run.
We havent yet sorted out how and or what we want to display and to whom yet on drupal.org, but this will allow us to experiment with it so we can figure out what would be best.
Attached is a patch that is just phpstan and nothing else, to see if the jenkins parsing is working.
Comment #7
gábor hojtsy#3039472: Fix phpstan XML output is rolled out so this should work better. Same as #4.
Comment #8
gábor hojtsyComment #9
wim leersAlso trying this in a contrib module: #3044414: Add phpstan to ensure the CDN module is compatible with Drupal 9 the day it is released, specifically the patch at #3044414-6: Add phpstan to ensure the CDN module is compatible with Drupal 9 the day it is released.
Comment #10
gábor hojtsyLet's run again.
Comment #11
gábor hojtsyNow with getMock() removed, it should be much less.
Comment #12
gábor hojtsyI devised this script to tell apart Legacy deprecations from the non-legacy ones. So far a legacy deprecation is one that is in a *Legacy*Test.php file or that contains WebTestBase in the error, assuming all of those left are actual legacy. Since we can only go based on the file name or error, it is not possible to do very creative matching, but I believe the goal is to identify top items.
I also attached the full results based on data from #11. These are the ones that at least occur 5 times:
Comment #13
xjmWe noticed that some of the long tail in the above results are actually just autoloading errors. I stripped those manually with an emacs macro and put the data here:
https://docs.google.com/spreadsheets/d/1hAtFhN26UG0QpKxMqUi3-fyoMs54hYrV...
Somehow there are a few more things being counted than there were on Mar. 19 which should only have happened with either massively large new things deprecated in core (otherwise we would have removed the usages), or new deprecations in dependencies. I think. :)
Comment #14
xjmI know how to check if it's the result of new dependency deprecations: queue the patch against 8.7.x. :P Might as well hit 8.6.x and earlier while we're at it to get some "historical"-ish data.
Comment #15
mikelutz8.6.x compatible patch
Comment #16
gábor hojtsyUploading yet again for clear data - results mapping.
Comment #17
gábor hojtsyOverall numbers are down like this:
These are left with at least 5 occurrences outside of legacy tests:
Report generated with the script from #12.
Comment #18
gábor hojtsySo now we can half the remaining deprecated APIs used by completing #2228741: Replace calls to format_string() with Drupal\Component\Render\FormattableMarkup. Reviews welcome there.
Comment #19
Mixologicwould it make sense to exclude the legacy tests from analysis by adding it to the phpstan.neon? Kinda like we exclude the migrate test fixtures...
Comment #20
gábor hojtsy#2228741: Replace calls to format_string() with Drupal\Component\Render\FormattableMarkup is in, let's see again :)
Comment #21
gábor hojtsyYay, we are significantly down, these are the ones left with 5 or more uses:
Comment #22
gábor hojtsyNew issues:
- #3067196: Properly deprecate LinkGeneratorTrait would cover the current top item thanks @alexpott.
- #3067206: Properly deprecate drupalGetHeaders() method of Drupal\Tests\BrowserTestBase covers 11 uses as well, thanks @voleger :)
Comment #23
volegerAlso #2958925: Properly deprecate drupal_get_profile()
Comment #24
volegerAnd #2776031: Properly deprecate ThemeHandlerInterface install() and uninstall() also replace usage
Comment #25
amateescu commentedAnd #3067347: Undeprecate DefaultTableMapping::setFieldNames() and ::setExtraColumns(), mark them as internal instead :)
Comment #26
mikelutzMy new plan is to start at the bottom and work my way up.. the bottom issues are much easier.. ;-)
#3067361: Properly deprecate NodeType::isNewRevision
Comment #27
mikelutzI lied. There are more than 5 usages of NodeType::isNewRevision() they are just not type-hinted correctly.. :-(
Comment #28
gábor hojtsyLooking at the 1 item results, there was some suspicious ones especially around single use file.inc functions. Turns out there is also *DeprecationTest.php files (4 of them) that invoke deprecated APIs on purpose. Filtering those out, running on the same data set from yesterday, it is down 5% from 656 to 623 :) There are still deprecated code invoked from deprecated code that we cannot detect this way, so only actually removing the APIs and seeing things possibly fail will uncover those. The 623 errors come from 262 types of things, but due to uses of traits, a lot of them are the same thing as well.
Comment #29
gábor hojtsyThanks to suggestion by @berdir, we should also ignore anything in 'modules/simpletest/*' and 'src/Tests/*', which further cuts down to 596 from 623 still using the same data set from yesterday.
Comment #30
mikelutzHere is a new parsing script to combine some things, and to manually weed out the rest of the legacy test usage cases, and some other special cases that can be ignored right now.
Comment #31
mikelutzI only manually cleared out the legacy test usages from the items that only had 1 usage. some of the remaining ones with 2 or 3 usages might be okay too, but my brain is done for today. :-)
Comment #32
alexpott@mikelutz nice work. Yeah we somehow need to be able to identify things like
system_list()which are properly deprecated.Comment #33
gábor hojtsyA bunch of issues landed, so let's try again. :)
Comment #34
gábor hojtsyThe parsed output of that is the following (5 or more usages). Definitely trending down! Full report attached.
Comment #35
alexpottHere's some nice context to a few of the things in the list in #34
12 | 737cec | Access to deprecated property $entityContextDefinition of class Drupal\Core\Plugin\Context\ContextDefinition. |This is part of a BC layer that's all marked private and will be removed in Drupal 9 but can not in 89 | aeec37 | Call to deprecated method entityManager() of class Drupal |is deprecated properly and only called from test code. Mind you we should deprecate \Drupal\views\FieldAPIHandlerTrait::getEntityManager() and \Drupal\image\Plugin\Field\FieldType\ImageItem::getEntityManager()7 | 3524c4 | Call to deprecated method initializeEntityContextDefinition() of class Drupal\Core\Plugin\Context\ContextDefinition. |This is part of a BC layer that's all marked private and will be removed in Drupal 9 but can not in 86 | 9cd736 | Call to deprecated function system_list() |is only called from legacy testingSo we're in an even better place.
Comment #36
gábor hojtsyThanks @alexpott. Updated the summary script with:
Note that the new 2d13e4 I (easily) identified as a false positive. It is
Call to deprecated function deprecation_test_function():D only used in test code testing deprecations.Results are significantly down with these (ones with 5 or more to review):
Comment #37
gábor hojtsyComment #38
gábor hojtsyLet's update based on recent commits.
Comment #39
gábor hojtsyDown 28 more :) Ones with 5 or more:
Comment #40
mikelutzI went through the list and moved more into postponed/legacy/dcdc. I also added/linked issues for all the outstanding ones. Sorry for the dump here, but I think it's useful
Edit: moved dump to the IS for others to edit.
Comment #41
berdir> 2 | 524ff7 | Call to deprecated method url() of class Drupal\Core\Entity\EntityBase | #3067198: Properly deprecate UrlGeneratorTrait
Entity::url() is not about UrlGeneratorTrait and is already fully deprecated, those most be tests/deprecated code => this is done.
> 1 | 411a38 | Access to deprecated property $entityManager of class Drupal\Core\Entity\EntityForm in core/lib/Drupal/Core/Entity/ContentEntityForm.php on line 59 | #2450793: Properly deprecate support for entity type label callbacks
Wrong issue, should be the same as the one above?
Maybe move this list into the issue summary so every can update it? Great work btw.
Comment #42
mikelutzI copied it as is, I'm on my phone. Have at it. :-)
Comment #43
voleger#2958925: Properly deprecate drupal_get_profile() is in
few child issues needs review
Comment #44
mikelutzedit: oops, posted on wrong issue.
Comment #45
mikelutzComment #46
mikelutzLatest results, fixing a couple incorrect links in the script + updating IS.
Comment #47
mikelutzComment #48
mikelutzComment #49
mikelutzComment #50
mikelutzComment #51
gábor hojtsyDrupal::l() landed :)
Comment #52
mikelutzComment #53
mikelutzComment #54
mikelutzComment #55
mikelutzComment #56
mikelutzComment #57
mikelutzComment #58
mikelutzComment #59
mikelutzComment #60
mikelutzComment #61
gábor hojtsy#3069046: Properly manage newly required parameter of FileUsageBase::__construct() landed, removing from summary.
Comment #62
gábor hojtsyHm, we actually went up a bit:
Somehow #2450793: Properly deprecate support for entity type label callbacks is back in 4 instances.
Comment #63
mikelutzI may not have posted my latest script. Every time we fix one we add a legacy test that then needs to be marked in the script, or it still shows up. You just re-added several closed issues that I had been taking out.
Comment #64
xjmComment #65
gábor hojtsyTwo more issues landed. Retesting. Will wait for @mikelutz's updated script to summarise.
Comment #66
mikelutzComment #67
gábor hojtsyLooks like it should be 9 unique as this one is found but already fixed(?)
1 | 46f674 | Call to deprecated method prepareLegacyRequest() of class Drupal\Core\DrupalKernel in core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php on line 209 | #2869573: Remove usages of deprecated DrupalKernel::prepareLegacyRequest()
Comment #68
mikelutzYeah, looks like I missed one.
Comment #69
gábor hojtsyUpdated :)
Comment #70
mikelutzComment #71
gábor hojtsyLet's run this again :)
Comment #72
mikelutzComment #73
mikelutzComment #74
mikelutzComment #75
gábor hojtsyThree more patches landed from above.
Comment #76
volegerUpdate errors list from IS
Comment #82
quietone commentedStumbled on this issue.
All the child issues are closed and phpstan is now running on Core, #3178534: Start running PHPStan on Drupal core (level 0). I don't see anything else to do here. Setting to RTBC just in case I missed something at this late hour.
Comment #83
catchAgreed, I think we can close this. If we enable new phpstan levels we can have new issues to fix anything that comes up too.