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

CommentFileSizeAuthor
#48 3042582-48-interdiff.txt1.57 KBBerdir
#48 3042582-48.patch28.81 KBBerdir
#45 3042582-44.patch5.01 KBfm_
#43 interdiff_42-43.txt2.65 KBmalaynayak
#43 3042582-43.patch27.65 KBmalaynayak
#42 interdiff_41-42.txt672 byteskatherined
#42 3042582-42.patch25.13 KBkatherined
#41 3042582-41.patch25 KBandreyjan
#41 3042582-interdiff--39-41.txt842 bytesandreyjan
#39 3042582-39.patch25 KBandreyjan
#39 3042582-interdiff--36-39.txt6.45 KBandreyjan
#36 3042582-36.patch22.68 KBandreyjan
#36 3042582-interdiff--32-36.txt8.1 KBandreyjan
#34 Screen Shot 2020-01-11 at 14.16.55.png50.79 KBrobertoperuzzo
#32 3042582-32.patch14.8 KBandreyjan
#32 3042582-interdiff--29-32.txt11.38 KBandreyjan
#29 interdiff_25_29.txt1.54 KBpranit84
#29 3042582-29.patch3.42 KBpranit84
#25 interdiff-22-25.txt823 bytesthalles
#25 3042582-25.patch1.96 KBthalles
#22 3042582-22.patch1.06 KBkatherined
#22 interdiff_19-22.txt994 byteskatherined
#19 30425820-19.patch1.06 KBrobpowell
#16 drupal_9_deprecated_code-3042582-16.patch15.41 KBzeuty
#15 drupal_9_deprecated_code-3042582-15.patch15.35 KBzeuty
#11 drupal_9_deprecated_code-3042582-11.patch6.1 KBzeuty
#9 drupal_9_deprecated_code-3042582-9.patch6.71 KBzeuty
#5 drupal_9_deprecated_code-3042582-5.patch6.54 KBzeuty
#2 drupal_9_deprecated_code-3042582-2.patch6.56 KBSergiu Stici
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

josephdpurcell created an issue. See original summary.

Sergiu Stici’s picture

Status: Active » Needs review
FileSize
6.56 KB

Here is the patch, please review.

Status: Needs review » Needs work

The last submitted patch, 2: drupal_9_deprecated_code-3042582-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

waverate’s picture

Patch at #2 works. Removes deprecation errors.

Setting this to Needs Work to get the tests to pass.

zeuty’s picture

Status: Needs review » Needs work

The last submitted patch, 5: drupal_9_deprecated_code-3042582-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

zeuty’s picture

Test 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.

Berdir’s picture

I 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.

zeuty’s picture

Status: Needs work » Needs review
FileSize
6.71 KB
Berdir’s picture

Status: Needs review » Needs work
+++ b/tests/src/Kernel/PathautoKernelTest.php
@@ -374,7 +374,16 @@ class PathautoKernelTest extends KernelTestBase {
 
-    $display = entity_get_display('taxonomy_term', 'tags', 'default');
+    $values = array(
+      'targetEntityType' => 'taxonomy_term',
+      'bundle' => 'tags',
+      'mode' => 'default',
+      'status' => TRUE,
+    );
+    $display = \Drupal::entityTypeManager()
+      ->getStorage('entity_view_display')
+      ->create($values);
+

This 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.

zeuty’s picture

Adjusted patch according to @Berdir's remarks

zeuty’s picture

Not sure why the tests are failing. Seems not related to the patch.

Berdir’s picture

> 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.

zeuty’s picture

@Berdir,
Thanks, I got the point. Will try to look into it.

zeuty’s picture

Converted the simpletests to phpunit.

zeuty’s picture

Changed how ajax requests are processed in tests

zeuty’s picture

Assigned: Unassigned » zeuty
Berdir’s picture

Note to others following this: test conversion now happens in #3061563: Convert simpletest to PHPUnit tests., don't reroll the patch here ;)

robpowell’s picture

I 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.

robpowell’s picture

Status: Needs work » Needs review
Berdir’s picture

Status: Needs review » Needs work

the phpunit assert methods have inverted arguments expected should come first.

katherined’s picture

katherined’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

RTBC on green, thanks @katherined!

thalles’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.96 KB
823 bytes

Follow a new patch that replace entity_get_display().

Berdir’s picture

Assigned: zeuty » Unassigned
Status: Needs review » Needs work

Ok, 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.

Berdir’s picture

Also, 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.

Berdir’s picture

Took 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.

pranit84’s picture

Changing version to 8.8 in info files.

pranit84’s picture

Status: Needs work » Needs review
Berdir’s picture

Status: Needs review » Needs work

So 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.

andreyjan’s picture

Status: Needs work » Needs review
FileSize
11.38 KB
14.8 KB

Added changes per #31.

amitgoyal’s picture

Status: Needs review » Reviewed & tested by the community

#32 looks good to me.

➜  d9 git:(8.8.x) ✗ ./vendor/mglaman/drupal-check/drupal-check --drupal-root=./ modules/contrib/pathauto

 54/54 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


 [OK] No errors


robertoperuzzo’s picture

#3042582-32: Drupal 9 Deprecated Code Report for Pathauto works fine. Checked with upgrade_status module too.

screenshot

Berdir’s picture

Status: Reviewed & tested by the community » Needs work

These 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.

  26x: The \Drupal\Core\Path\AliasManager class is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, use \Drupal\path_alias\AliasManager. See https://drupal.org/node/3092086
    5x in PathautoEntityWithStringIdTest::testEntityWithStringId from Drupal\Tests\pathauto\Kernel
    1x in PathautoMassDeleteTest::testDeleteAll from Drupal\Tests\pathauto\Functional
    1x in PathautoKernelTest::testUpdateActions from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testDefaultRevision from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPatternStatus from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPathAliasUniquifyWordsafe from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testProgrammaticEntityCreation from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testNoExistingPathAliases from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testParentChildPathTokens from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPathTokens from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testNoTokensNoAlias from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testSameTitleDifferentLanguages from Drupal\Tests\pathauto\Kernel
    1x in PathautoNodeWebTest::testNodeEditing from Drupal\Tests\pathauto\Functional
    1x in PathautoBulkUpdateTest::testBulkUpdate from Drupal\Tests\pathauto\Functional
    1x in PathautoUiTest::testPatternsWorkflow from Drupal\Tests\pathauto\FunctionalJavascript
    1x in PathautoLocaleTest::testLanguageAliases from Drupal\Tests\pathauto\FunctionalJavascript
    1x in PathautoUserWebTest::testUserOperations from Drupal\Tests\pathauto\Functional
    1x in PathautoSettingsFormWebTest::testPunctuationSettings from Drupal\Tests\pathauto\Functional
    1x in PathautoSettingsFormWebTest::testSettingsForm from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testNodeState from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testNodeOperations from Drupal\Tests\pathauto\Functional
    1x in PathautoKernelTest::testCreateNodeWhileAccessingPath from Drupal\Tests\pathauto\Kernel

  18x: \Drupal\Core\Path\AliasStorage is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the "path_alias.repository" service instead, or the entity storage handler for the "path_alias" entity type for CRUD methods. See https://www.drupal.org/node/3013865.
    5x in PathautoEntityWithStringIdTest::testEntityWithStringId from Drupal\Tests\pathauto\Kernel
    1x in PathautoBulkUpdateTest::testBulkUpdate from Drupal\Tests\pathauto\Functional
    1x in PathautoEnablingEntityTypesTest::testEnablingEntityTypes from Drupal\Tests\pathauto\Functional
    1x in PathautoMassDeleteTest::testDeleteAll from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testNodeEditing from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testNodeState from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testCustomAliasWithoutPattern from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testCustomAliasAfterAutomaticAlias from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testCustomAliasAfterRemovingPattern from Drupal\Tests\pathauto\Functional
    1x in PathautoLocaleTest::testLanguageAliases from Drupal\Tests\pathauto\FunctionalJavascript
    1x in PathautoKernelTest::testPathDeleteMultiple from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testUpdateActions from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testNoTokensNoAlias from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPathTokens from Drupal\Tests\pathauto\Kernel

  16x: The "path.alias_manager" service is deprecated. Use "path_alias.manager" instead. See https://drupal.org/node/3092086
    5x in PathautoEntityWithStringIdTest::testEntityWithStringId from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testSameTitleDifferentLanguages from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testUpdateActions from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testNoTokensNoAlias from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPathTokens from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testParentChildPathTokens from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testNoExistingPathAliases from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testProgrammaticEntityCreation from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPathAliasUniquifyWordsafe from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPatternStatus from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testDefaultRevision from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testCreateNodeWhileAccessingPath from Drupal\Tests\pathauto\Kernel

  9x: The "path.alias_storage" service is deprecated. Use the "path_alias.repository" service instead, or the entity storage handler for the "path_alias" entity type for CRUD methods. See https://www.drupal.org/node/3013865
    5x in PathautoEntityWithStringIdTest::testEntityWithStringId from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPathDeleteMultiple from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testUpdateActions from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testNoTokensNoAlias from Drupal\Tests\pathauto\Kernel
    1x in PathautoKernelTest::testPathTokens from Drupal\Tests\pathauto\Kernel

  1x: Support for asserting against non-boolean values in ::assertTrue is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use a different assert method, for example, ::assertNotEmpty(). See https://www.drupal.org/node/3082086
    1x in PathautoLocaleTest::testLanguageAliases from Drupal\Tests\pathauto\FunctionalJavascript

  1x: Support for asserting against non-boolean values in ::assertFalse is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use a different assert method, for example, ::assertEmpty(). See https://www.drupal.org/node/3082086
    1x in PathautoUiTest::testPatternsWorkflow from Drupal\Tests\pathauto\FunctionalJavascript
andreyjan’s picture

Status: Needs work » Needs review
FileSize
8.1 KB
22.68 KB

Fixed above items.

andreyjan’s picture

Status: Needs review » Needs work
Berdir’s picture

+++ b/tests/src/Functional/PathautoTestHelperTrait.php
@@ -77,8 +77,9 @@ trait PathautoTestHelperTrait {
 
   public function saveAlias($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
-    \Drupal::service('path.alias_storage')->delete(['source' => $source, 'langcode' => $langcode]);
-    return \Drupal::service('path.alias_storage')->save($source, $alias, $langcode);
+    $alias_to_delete = \Drupal::service('entity_type.manager')->getStorage('path_alias')->loadByProperties(['path' => $source, 'langcode' => $langcode]);
+    \Drupal::service('entity_type.manager')->getStorage('path_alias')->delete($alias_to_delete);
+    return \Drupal::service('entity_type.manager')->getStorage('path_alias')->create(['path' => $source, 'alias' => $alias, 'langcode' => $langcode])->save();
   }

the 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.

andreyjan’s picture

Status: Needs work » Needs review
FileSize
6.45 KB
25 KB

Well, 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.

andreyjan’s picture

Status: Needs review » Needs work
andreyjan’s picture

Status: Needs work » Needs review
FileSize
842 bytes
25 KB

JavaScript test fix.

katherined’s picture

This change should take care of

26x: Support for asserting against non-boolean values in ::assertFalse is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use a different assert method, for example, ::assertEmpty(). See https://www.drupal.org/node/3082086
    11x in PathautoNodeWebTest::testNodeState from Drupal\Tests\pathauto\Functional
    5x in PathautoEntityWithStringIdTest::testEntityWithStringId from Drupal\Tests\pathauto\Kernel
    3x in PathautoKernelTest::testUpdateActions from Drupal\Tests\pathauto\Kernel
    2x in PathautoKernelTest::testPathDeleteMultiple from Drupal\Tests\pathauto\Kernel
    1x in PathautoBulkUpdateTest::testBulkUpdate from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testNodeEditing from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testCustomAliasAfterAutomaticAlias from Drupal\Tests\pathauto\Functional
    1x in PathautoNodeWebTest::testCustomAliasAfterRemovingPattern from Drupal\Tests\pathauto\Functional
    1x in PathautoKernelTest::testNoTokensNoAlias from Drupal\Tests\pathauto\Kernel
malaynayak’s picture

Fixed the deprecation warning below in this patch.

Parameter $entity_manager of method Drupal​\​pathauto​\​Plugin​\​migrate​\​source​\​PathautoPattern::__construct() has typehint with deprecated interface Drupal​\​Core​\​Entity​\​EntityManagerInterface. Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.

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.

fm_’s picture

Working on this issue contributionweekend2020

fm_’s picture

Fix
377 Call to deprecated function entity_get_display().
99 Call to deprecated method assertIdentical() of class Drupal\KernelTests\KernelTestBase.

Berdir’s picture

Status: Needs review » Needs work

This is missing all the existing work in this issue and has some unrelated changes.

fm_’s picture

My bad, the patch didn't apply correctly

Berdir’s picture

Adding 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.

DamienMcKenna’s picture

Title: Drupal 9 Deprecated Code Report » Drupal 9 Deprecated Code Report for Pathauto
phenaproxima’s picture

I 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.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

For 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.

grasmash’s picture

Need to remove the dependency on the path_alias.manager service, which has been deprecated.

Berdir’s picture

path.alias_manager is deprecated, not the same thing. This is passing on d9 now.

grasmash’s picture

Ok definitely read that too fast path_alias.manager vs path.alias_manager.

  • Berdir committed 607a59f on 8.x-1.x
    Issue #3042582 by zeuty, andreyjan, katherined, Berdir, pranit84,...
Berdir’s picture

Status: Reviewed & tested by the community » Fixed

Drupal 9 tests aren't passing yet, but that's because it is tested against token 8.x-1.6. Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

hugovk’s picture

Thanks 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