Support Drupal 10 and update all use of deprecation in the CKEditor Anchor Link module

Created on 27 April 2022, about 2 years ago
Updated 26 January 2023, over 1 year ago

Problem/Motivation

Drupal 10.0.0 stable was released on: 15 Dec 2022 by the Drupal core team
https://www.drupal.org/project/drupal/releases/10.0.0

Thank you so much!

The current composer require status for this module under Drupal 10

composer create-project drupal/recommended-project:~10 /var/www/html/sandboxes/drupal10anchor_link
cd  /var/www/html/sandboxes/drupal10anchor_link/
composer require drupal/anchor_link;

is having the following problem

Using version ^2.5 for drupal/anchor_link
./composer.json has been updated
Running composer update drupal/anchor_link
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - drupal/anchor_link 2.x-dev is an alias of drupal/anchor_link dev-2.x and thus requires it to be installed too.
    - drupal/anchor_link[dev-2.x, 2.5.0] require drupal/fakeobjects ^1.0 -> satisfiable by drupal/fakeobjects[1.0.0, 1.1.0, 1.x-dev].
    - drupal/fakeobjects 1.0.0 requires drupal/core ^8 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev] but the package is fixed to 10.0.0-alpha4 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - drupal/fakeobjects[1.1.0, ..., 1.x-dev] require drupal/core ^8 || ^9 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.5.x-dev] but the package is fixed to 10.0.0-alpha4 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires drupal/anchor_link ^2.5 -> satisfiable by drupal/anchor_link[2.5.0, 2.x-dev (alias of dev-2.x)].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require drupal/anchor_link:*" to figure out if any version is installable, or "composer require drupal/anchor_link:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Further drupal-check on

composer create-project drupal/recommended-project:~9 /var/www/html/sandboxes/drupal9anchor_link

cd /var/www/html/sandboxes/drupal9anchor_link/

composer config minimum-stability dev

composer require drupal/anchor_link:1.x-dev

composer require drupal/core-dev:~9 --with-all-dependencies
composer require mglaman/drupal-check --dev
composer require phpspec/prophecy-phpunit:^2 --dev 

php vendor/bin/drupal-check -d web/modules/contrib/anchor_link/

Output:

4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ -------------------------------------------------------------------- 
  Line   src/Plugin/CKEditorPlugin/AnchorLink.php                            
 ------ -------------------------------------------------------------------- 
  23     Call to deprecated function drupal_get_path():                      
         in drupal:9.3.0 and is removed from drupal:10.0.0. Use              
           \Drupal\Core\Extension\ExtensionPathResolver::getPath() instead.  
  56     Call to deprecated function drupal_get_path():                      
         in drupal:9.3.0 and is removed from drupal:10.0.0. Use              
           \Drupal\Core\Extension\ExtensionPathResolver::getPath() instead.  
  60     Call to deprecated function drupal_get_path():                      
         in drupal:9.3.0 and is removed from drupal:10.0.0. Use              
           \Drupal\Core\Extension\ExtensionPathResolver::getPath() instead.  
  64     Call to deprecated function drupal_get_path():                      
         in drupal:9.3.0 and is removed from drupal:10.0.0. Use              
           \Drupal\Core\Extension\ExtensionPathResolver::getPath() instead.  
 ------ -------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------- 
  Line   src/Plugin/CKEditorPlugin/FakeObjects.php                           
 ------ -------------------------------------------------------------------- 
  24     Call to deprecated function drupal_get_path():                      
         in drupal:9.3.0 and is removed from drupal:10.0.0. Use              
           \Drupal\Core\Extension\ExtensionPathResolver::getPath() instead.  
 ------ -------------------------------------------------------------------- 

 ------ ----------------------------------------------------------------------- 
  Line   src/Plugin/Linkit/Matcher/CKEditorAnchorLinkMatcher.php                
 ------ ----------------------------------------------------------------------- 
  18     Class                                                                  
         Drupal\anchor_link\Plugin\Linkit\Matcher\CKEditorAnchorLinkMatcher     
         extends unknown class Drupal\linkit\MatcherBase.                       
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols    
  24     Instantiated class Drupal\linkit\Suggestion\SuggestionCollection not   
         found.                                                                 
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols    
  28     Instantiated class Drupal\linkit\Suggestion\DescriptionSuggestion not  
         found.                                                                 
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols    
  29     Call to an undefined method                                            
         Drupal\anchor_link\Plugin\Linkit\Matcher\CKEditorAnchorLinkMatcher::t  
         ().                                                                    
  29     Call to method setLabel() on an unknown class                          
         Drupal\linkit\Suggestion\DescriptionSuggestion.                        
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols    
  31     Call to an undefined method                                            
         Drupal\anchor_link\Plugin\Linkit\Matcher\CKEditorAnchorLinkMatcher::t  
         ().                                                                    
  33     Call to method addSuggestion() on an unknown class                     
         Drupal\linkit\Suggestion\SuggestionCollection.                         
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols    
 ------ ----------------------------------------------------------------------- 

 [ERROR] Found 12 errors                                                        

Thanks for using drupal-check!

Consider sponsoring the development of the maintainers which make drupal-check possible:

- phpstan (ondrejmirtes): https://github.com/sponsors/ondrejmirtes
- phpstan-deprecation-rules (ondrejmirtes)): https://github.com/sponsors/ondrejmirtes
- phpstan-drupal (mglaman)): https://github.com/sponsors/mglaman
- drupal-check (mglaman)): https://github.com/sponsors/mglaman

Proposed resolution

  • Support Drupal ~10 and change all deprecated packages, classes, functions, asset libraries to the Drupal 10 way
  • Real physical testing with Drupal ~10
  • Automated upgrade to Drupal ~10

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ✅ Code review by maintainers
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Release notes snippet
  • ✅ Release anchor_link-1.10.0 , anchor_link-2.6.0

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇯🇴Jordan Rajab Natshah Jordan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024