Problem/Motivation
Protected Pages module crashes in projects using Canvas.
Steps to reproduce
- versions used here: Drupal core 11.3.8, canvas 1.3.3, protected_pages 8.x-1.9
- install and enable Protected Pages module in a Drupal project already using Canvas
- try to add a protected page (-> /admin/config/system/protected_pages/add)
- results in TypeError
TypeError: Drupal\protected_pages\Form\ProtectedPagesAddForm::__construct(): Argument #4 ($messenger) must be of type Drupal\Core\Messenger\Messenger, Drupal\canvas\Messenger given, called in /var/www/html/web/modules/contrib/protected_pages/src/Form/ProtectedPagesAddForm.php on line 81 in Drupal\protected_pages\Form\ProtectedPagesAddForm->__construct() (line 69 of modules/contrib/protected_pages/src/Form/ProtectedPagesAddForm.php).
Similar problem for Edit, DeleteConfirm and SendEmail functionality.
Proposed resolution
Use Drupal\Core\Messenger\MessengerInterface instead of Drupal\Core\Messenger\Messenger.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork protected_pages-3588956
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
revathi.b commentedComment #3
revathi.b commentedI am not able to replicate this issue
Comment #5
cmarrufo commentedI'm be able to reproduce the issue, but putting that aside, from an OOP perspective it's better to use interfaces whenever possible, as this helps us avoid hard coupling.
Working in the MR.
Comment #7
cmarrufo commentedDone.
PD: I also fix a phpcs error in the ProtectedPagesSettingForm class (line 93 double dot on comment).
Comment #8
cmarrufo commentedComment #9
gordonio commentedThe patch looks good to me. I ran into this issue with 11.3.9 and it fixed it just fine.
Comment #11
oksana-c commentedmerged. thank you all.