Problem/Motivation

After creating a Context with a "Page template suggestions" reaction, I decided to check my site to get some base template names and got a lot of errors popping up. This is due to changes to PHP 8.2 not tolerating unset values.

Steps to reproduce

Create a context with a "Page template suggestions" reaction and start navigating your site before adding anything to that field. The site should be running on PHP 8.2

Proposed resolution

Add a default empty string to the execute method return value in the PageTemplateSuggestions class.

CommentFileSizeAuthor
PageTemplateSuggestions_fix.patch533 bytesjaydee1818

Issue fork context-3451442

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

jaydee1818 created an issue. See original summary.

nfabing’s picture

Version: 8.x-4.1 » 5.0.0-rc1
Assigned: Unassigned » nfabing
nfabing’s picture

Assigned: nfabing » Unassigned
Status: Active » Needs review

Hi

This issue happens when adding a new "Page template suggestions" or "Page title" and only if the form was not saved afterward.
I added the missing default configuration for the related plugins to fix the issue.

I've created a new MR. Rdy for review

aimadbachar changed the visibility of the branch 3451442-handle-saving-a to hidden.

aimadbachar changed the visibility of the branch 3451442-handle-saving-a to active.

aimadbachar’s picture

Hi

I have tested the MR !60
It works fine for me, there are no more errors

Drupal Core: 10.3.5
PHP: 8.3.12

benstallings’s picture

Version: 5.0.0-rc1 » 5.x-dev
Status: Needs review » Reviewed & tested by the community

after rebasing on 5.x, Claude Code says,

Both changes are correct, follow the same pattern used by other reaction plugins (e.g. BodyClass), and prevent undefined index errors when the reactions are added to a context but not yet configured.

No issues. Good to merge.