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
drupal-check on version:
https://git.drupal.org/project/pathauto c2bc5206a0bfdea39976e43e7f011be86f6711dd
------ -------------------------------------------------------------------------------------------------------------------------
Line src/Tests/PathautoTestHelperTrait.php (in context of class Drupal\Tests\pathauto\Kernel\PathautoEntityWithStringIdTest)
------ -------------------------------------------------------------------------------------------------------------------------
76 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
122 Call to deprecated method assertEqual() of class Drupal\KernelTests\KernelTestBase.
179 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
------ -------------------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------
Line src/Tests/PathautoTestHelperTrait.php (in context of class Drupal\Tests\pathauto\Kernel\PathautoKernelTest)
------ -------------------------------------------------------------------------------------------------------------
76 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
122 Call to deprecated method assertEqual() of class Drupal\KernelTests\KernelTestBase.
179 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
------ -------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------
Line tests/src/Kernel/PathautoKernelTest.php
------ -----------------------------------------------------------------------------------------
75 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
156 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
218 Call to deprecated method assertEqual() of class Drupal\KernelTests\KernelTestBase.
239 Call to deprecated method assertEqual() of class Drupal\KernelTests\KernelTestBase.
377 Call to deprecated function entity_get_display().
------ -----------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------
Line tests/src/Kernel/PathautoTokenTest.php
------ -----------------------------------------------------------------------------------------
41 Call to deprecated method assertEqual() of class Drupal\KernelTests\KernelTestBase.
99 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
------ -----------------------------------------------------------------------------------------
[ERROR] Found 13 errors
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#48 | 3042582-48-interdiff.txt | 1.57 KB | Berdir |
#48 | 3042582-48.patch | 28.81 KB | Berdir |
#43 | interdiff_42-43.txt | 2.65 KB | malaynayak |
#43 | 3042582-43.patch | 27.65 KB | malaynayak |
| |||
#42 | interdiff_41-42.txt | 672 bytes | katherined |
Comments
Comment #2
Sergiu Stici CreditAttribution: Sergiu Stici at FFW commentedHere is the patch, please review.
Comment #4
waverate CreditAttribution: waverate commentedPatch at #2 works. Removes deprecation errors.
Setting this to Needs Work to get the tests to pass.
Comment #5
zeutyComment #7
zeutyTest fails against Drupal 8.7
1) Drupal\Tests\pathauto\Kernel\PathautoKernelTest::testParentChildPathTokens
Error: Call to undefined method Drupal\Core\Entity\EntityDisplayRepository::getViewDisplay()
Should work against Drupal 8.8 as EntityDisplayRepository::getViewDisplay() is introduced in 8.8.
Comment #8
BerdirI will only be able to commit deprecation updates that work on 8.6, to able to commit your work, I suggest you split the parts that are deprecated on 8.6 or earlier into a separate issue.
Comment #9
zeutyTried to fix the final issue according to: https://api.drupal.org/api/drupal/core%21includes%21entity.inc/function/...
Comment #10
BerdirThis is exactly why we introduced the new API in 8.8, to avoid duplicating that much code. There's no reason to update this now, just remove that part from the patch.
Comment #11
zeutyAdjusted patch according to @Berdir's remarks
Comment #12
zeutyNot sure why the tests are failing. Seems not related to the patch.
Comment #13
Berdir> 20:43:27 Fatal error: Uncaught Error: Call to undefined method Drupal\pathauto\Tests\PathautoUserWebTest::assertEquals() in /var/www/html/modules/contrib/pathauto/src/Tests/PathautoTestHelperTrait.php:122
Looks pretty related to me :)
These test aren't converted yet, so assertEquals() doesn't exist. We need to convert them to phpunit first.
You're welcome to give that a try, I'd do that in a new issue if there is none yet. Simpletest base classes were officially deprecated today, but not sure how much documentation there already is on converting them. Basically it is about moving them into the new location, update base classes and so on.
Comment #14
zeuty@Berdir,
Thanks, I got the point. Will try to look into it.
Comment #15
zeutyConverted the simpletests to phpunit.
Comment #16
zeutyChanged how ajax requests are processed in tests
Comment #17
zeutyComment #18
BerdirNote to others following this: test conversion now happens in #3061563: Convert simpletest to PHPUnit tests., don't reroll the patch here ;)
Comment #19
robpowellI rerolled at #11, and then ran drupal-checker and the only failure was `entity_get_display()`. So hopefully this works after the changes in #3061563.
Comment #20
robpowellComment #21
Berdirthe phpunit assert methods have inverted arguments expected should come first.
Comment #22
katherinedHere's the change from #21.
Comment #23
katherinedComment #24
phenaproximaRTBC on green, thanks @katherined!
Comment #25
thallesFollow a new patch that replace entity_get_display().
Comment #26
BerdirOk, so if we fix 8.8 deprecations then lets do it properly, and use this issue to prepare for a release that is compatible with 8.8 and 9.0.
1. Update the version constraints to require ^8.8 || ^9.0 to all info.yml files.
2. Add the defaultTheme property to browser tests
3. fix remaining entity manager usages (grep entity.manager -r .)
4. Remove the BC layer that we added for 8.7 (service provider and the alternative storage helper class)
5. Fix other remaining dynamic deprecations that drupal-check can't find, run phpunit tests with deprecations enabled.
Comment #27
BerdirAlso, there are several existing overlapping and duplicate issues in the issue queue like #3004108: ContextDefinition object for an entity type is deprecated, #3069603: [8.8+] Removing deprecated method entity_get_display() and #3086586: Add new key core_version_requirement in pathauto.info.yml.
I'd really appreciate help to consolidate that into this issue, close them as duplicate and merge existing patches together, so we can test it all together. That's just as much work as fixing the code :)
Note that I will commit this then likely around 9.0 beta. We'll also need to make dependencies like ctools and token ready for D9 in the same way.
Comment #28
BerdirTook care of all the 8.7 deprecations in #3004108: ContextDefinition object for an entity type is deprecated, this can now increase the version requirement to 8.8 and deal with the final parts.
Comment #29
pranit84Changing version to 8.8 in info files.
Comment #30
pranit84Comment #31
BerdirSo far so good, the next step is removing \Drupal\pathauto\PathautoServiceProvider, \Drupal\pathauto\LegacyAliasStorageHelper. Then remove usages of \Drupal\Core\Path\AliasRepositoryInterface, \Drupal\Core\Path\AliasManagerInterface and replace it with type hints on path_alias.module services.
Comment #32
andreyjan CreditAttribution: andreyjan at FFW commentedAdded changes per #31.
Comment #33
amitgoyal CreditAttribution: amitgoyal at Acquia commented#32 looks good to me.
Comment #34
robertoperuzzo#3042582-32: Drupal 9 Deprecated Code Report for Pathauto works fine. Checked with upgrade_status module too.
Comment #35
BerdirThese tools don't find everything though, there are still quite a few cases of the old services left, for example in \Drupal\Tests\pathauto\Functional\PathautoTestHelperTrait.
Comment #36
andreyjan CreditAttribution: andreyjan at FFW commentedFixed above items.
Comment #37
andreyjan CreditAttribution: andreyjan at FFW commentedComment #38
Berdirthe delete and re-save is pretty strange, are we really using that?
There's also \Drupal\Tests\Traits\Core\PathAliasTestTrait that we could use with a few useful methods for loading,creating as well as asserting that an alias exists.
Comment #39
andreyjan CreditAttribution: andreyjan at FFW commentedWell, I've added some core PathAliasTestTrait methods, but not assertPathAliasExists, because it loads the alias differently from PathautoTestHelperTrait similar method already used in the tests.
Comment #40
andreyjan CreditAttribution: andreyjan at FFW commentedComment #41
andreyjan CreditAttribution: andreyjan at FFW commentedJavaScript test fix.
Comment #42
katherinedThis change should take care of
Comment #43
malaynayak CreditAttribution: malaynayak as a volunteer and at Acquia for Drupal India Association commentedFixed the deprecation warning below in this patch.
Note: the changes from the issue https://www.drupal.org/project/pathauto/issues/3108739 has been added to the patch #42 to create new patch.
Comment #44
fm_ CreditAttribution: fm_ at Hiberus commentedWorking on this issue contributionweekend2020
Comment #45
fm_ CreditAttribution: fm_ at Hiberus commentedFix
377 Call to deprecated function entity_get_display().
99 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.
Comment #46
BerdirThis is missing all the existing work in this issue and has some unrelated changes.
Comment #47
fm_ CreditAttribution: fm_ at Hiberus commentedMy bad, the patch didn't apply correctly
Comment #48
BerdirAdding the missing module dependency to kernel tests to the patch in #43, those were the only tests that failed on #43, so I think this is complete and ready.
Comment #49
DamienMcKennaComment #50
phenaproximaI gave #48 a test run locally using Drupal 9.0.x HEAD. Initially, I got the same failure as we're seeing here. After patching Token with #3042568: Drupal 9 Deprecated Code Report for Token on @Berdir's recommendation, the failure disappeared.
Comment #51
phenaproximaFor the record, we don't know why it passes with the Token patch, but it does, and Drupal is mysterious. So, in the name of getting this very important module ready for Drupal 9, I'm marking this RTBC.
Comment #52
grasmash CreditAttribution: grasmash commentedNeed to remove the dependency on the path_alias.manager service, which has been deprecated.
Comment #53
Berdirpath.alias_manager is deprecated, not the same thing. This is passing on d9 now.
Comment #54
grasmash CreditAttribution: grasmash commentedOk definitely read that too fast path_alias.manager vs path.alias_manager.
Comment #56
BerdirDrupal 9 tests aren't passing yet, but that's because it is tested against token 8.x-1.6. Committed.
Comment #58
hugovk CreditAttribution: hugovk at Digia for Yle - Finnish Broadcasting Company commentedThanks all for updating pathauto for D9!
Is there a schedule for the next release? It'd be great to have pathauto show as green in our Upgrade Status list :)
https://www.drupal.org/project/upgrade_status