Problem/Motivation

When running Drupal with PHP 8.4, several methods in Panels trigger deprecation warnings due to parameters being implicitly nullable.

PHP 8.4 deprecates signatures where a parameter has a type declaration but is given a NULL default without being explicitly marked nullable.

Example pattern triggering the deprecation:

Request $request = NULL

PHP now requires this to be written as:

?Request $request = NULL

When caches are rebuilt (for example via the UI), the following deprecation notices appear:

Deprecated function: Drupal\panels\Form\PanelsAddBlockForm::buildForm(): 
Implicitly marking parameter $request as nullable is deprecated.

Deprecated function: Drupal\panels\Storage\PanelsStorageManager::access(): 
Implicitly marking parameter $account as nullable is deprecated.

Deprecated function: Drupal\panels\Storage\PanelsStorageManagerInterface::access(): 
Implicitly marking parameter $account as nullable is deprecated.

Deprecated function: Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant::access(): 
Implicitly marking parameter $account as nullable is deprecated.

Steps to reproduce

  1. Install Drupal with the Panels module enabled.
  2. Upgrade the PHP runtime to PHP 8.4.
  3. Clear caches via the UI or with Drush.
  4. Observe the deprecation notices above.

Proposed resolution

Update the affected method signatures to explicitly mark nullable parameters.

Remaining tasks

Review patch.

User interface changes

None

API changes

None

Data model changes

None

Comments

smulvih2 created an issue. See original summary.

smulvih2’s picture

Status: Active » Needs review
StatusFileSize
new2.63 KB

Patch fixes the issue for me on PHP8.4, panels 4.9.0.

vistree’s picture

Thank you @smulvih2. Your path fixes the PHP 8.4 panels error - which also occured on running drush commands

joseph.olstad’s picture

+1 thanks!

joseph.olstad’s picture

Duplicate of
#3534531: php 8.4 compatibility issue

The solution is to use 4.x-dev or wait for 4.10

once 4.10 is tagged, this above patch won't apply anymore.

joseph.olstad’s picture

Version: 8.x-4.x-dev » 8.x-4.9

leave this open until 8.x-4.10

torreytoomajanian’s picture

StatusFileSize
new2.64 KB

The same error was getting thrown from another area so I went ahead and remade the patch to cover it as well.

joseph.olstad’s picture

@torreytoomanjanian, patch 7 is identical to patch #2, all you've done is introduce fuzz

I suggest re-reading comment #5, the solution is to switch to 4.0.x-dev while awaiting 4.10

NO PATCH REQUIRED unless you stick to 4.9 instead of using 4.0.x-dev that has the fix

joseph.olstad’s picture

xem8vfdh’s picture

> The solution is to use 4.x-dev or wait for 4.10

> once 4.10 is tagged, this above patch won't apply anymore.

I dont see 4.10 here: https://www.drupal.org/project/panels/releases

Am I missing something, if not, any idea when it's expected?

joseph.olstad’s picture

  1. 4.10 hasn't been tagged yet
  2. If you use 4.9 then you need to patch
  3. If you don't like patches then use 4.x-dev (it has the fix)
xem8vfdh’s picture

I hear you. It is of course humorous to call using the latest official release "stubborn"

I, like many, can wait on the official release, as this is a warning not a break, and its suppressed in properly configured prod.

joseph.olstad’s picture

This actually should be closed as a duplicate however the issue is that the maintainer(s) is/are intentionally neglecting this project.
Perhaps it's time for a replacement.

There's a replacement pattern that is basically like forking. Have a look at the explanation.

I've done this before for jquery_ui (jq_ui) and the book module (livre). Basically clone this project (panels) , push it into a new project such as panels_forever . I'm tempted to do this to try out an even easier flow, basically just leave the module code in place and add a panels_forever.info.yml file which is a dummy file that doesn't need to be installed. Otherwise a simple composer replace directive in the composer.json file.

I'm tempted to try out this in a simplified approach I just described. Previously I put the module into a folder inside the new project but I don't even think that's necessary. Would have to try and see.

xem8vfdh’s picture

I would wholeheartedly support you. The module has been neglected for years now, basically since D8 if I remember correctly, and core made the broad shift to Symfony.

liam morland’s picture

Version: 8.x-4.9 » 8.x-4.x-dev
Status: Needs review » Closed (duplicate)
Related issues: +#3534531: php 8.4 compatibility issue

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.