Problem/Motivation

Drupal core 9.3 updated the typecasting for the node_revision route parameter which means it's a fully fledged object now. The code in this module for getting the entity is using code that thinks it's the revision id, a numeric value, which then throw this error:

TypeError: Illegal offset type in Drupal\Core\Entity\ContentEntityStorageBase->loadRevision() (line 636 of core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php).

Steps to reproduce

  1. Install the module
  2. Create a node with revisions
  3. Click on the Revisions tab, click to view one of the revisions, observe WSOD

Proposed resolution

See attached patch.

Remaining tasks

User testing

Command icon 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

sahilgidwani created an issue. See original summary.

sahilgidwani’s picture

StatusFileSize
new1.08 KB
sahilgidwani’s picture

Status: Active » Needs review
franceslui’s picture

Assigned: sahilgidwani » Unassigned
StatusFileSize
new844 bytes

@sahilgidwani Thank you for submitting the patch in your comment #2. I have reviewed it and found that it worked correctly.

Since node_revision_load is deprecated in Drupal 10.1.0 and will be removed in Drupal 11.0.0, I have submitted a new patch that uses \Drupal\Core\Entity\RevisionableStorageInterface::loadRevision instead.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

Thank you both, this issue is indeed major as it is a WSOD for content editors. I have reviewed the patches and tested it out and it works well.

damienmckenna’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

This needs:
* To be recreated as a merge request.
* To be rewritten to use DI.
* Add test coverage.

damienmckenna’s picture

Issue tags: +Needs tests

damienmckenna’s picture

I created a MR from the patch, it's ready for someone else to convert to DI.

joelpittet’s picture

Status: Needs work » Needs review

@damienmckenna DI can be a bit of scope creep like we could do StaticPageSettingsForm as well. I kept the changes localized to avoid that...

dww’s picture

Thanks for working on this!

Unless we change the minimum supported version, I think it’d be better to do this:

$vid = \Drupal::routeMatch()->getRawParameter('node_revision');

Then we always know we’re getting a vid, not an object, regardless of what core we’re running against. We don’t even want the loaded revision object, we only use it to get the vid back for loading the right revision of the node.

Meanwhile, yeah, I’d rather not scope creep this with all the DI changes. We can do those in a follow-up, they’re not necessary for fixing this bug.

dww’s picture

Status: Needs review » Needs work

In addition to #11, this also still needs tests. 😅

joelpittet’s picture

Status: Needs work » Needs review

@dww are the DI changes I already did going to be OK? I tried to keep the scope as tight as possible.

dww’s picture

Status: Needs review » Needs work
Issue tags: +Needs rebase

Personally, I'd rather just fix the bug here, and do all the DI stuff at #3563027: Use dependency injection in StaticPageSubscriber and StaticPageSettingsForm. Hopefully fairly easy to move those commits/changes to another branch.

Meanwhile, I opened #3563026: Enable GitLab CI for static_page to add the .gitlab-ci.yml file and fix the pipelines. That's now merged. So this needs a rebase to remove that from here.

Thanks again for working on this!
-Derek

dww’s picture

Title: Revision object is returned instead of revision id due to core type upcasting change. » Fatal error when viewing a static_page revision due to core type upcasting change
dww’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs rebase

Moved the DI changes to #3563027: Use dependency injection in StaticPageSubscriber and StaticPageSettingsForm. Rebased to latest 8.x-1.x. There's now test coverage here, removing that tag, too.

Let's see what the bot says now.

joelpittet’s picture

The tests-only need the schema issue #3563033: Missing config schema and default config to show if they are actually testing the right thing. I'll have to get ddev-drupal-contrib locally to test local better.

  • dww committed b439f1ed on 8.x-1.x
    fix: #3386719 Fatal error when viewing a static_page revision due to...
dww’s picture

Status: Needs review » Fixed

I merged #3563033: Missing config schema and default config. Rebased in here to remove the schema changes that are now in 8.x-1.x. Pipeline is happy. Merged to 8.x-1.x.

Thanks, everyone!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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