Problem/Motivation
fail: [PHP Deprecated] Line 58 of sites/all/modules/ctools/plugins/contexts/entity.inc:
Optional parameter $data declared before required parameter $plugin is implicitly treated as a required parameter
exception: [Deprecated] Line 535 of sites/all/modules/ctools/includes/math-expr.inc:
preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated
TypeError: Unsupported operand types: string + int in ctools_context_next_id() (line 1125 of /var/www/html/sites/all/modules/ctools/includes/context.inc).
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | ctools-required_paramater_after_optional-3253226.patch | 739 bytes | beagaliana |
Issue fork ctools-3253226
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
joelpittetComment #5
joelpittetComment #7
joelpittetComment #9
liam morlandWith this change, ctools_context_create_entity() can be invoked without a value for the $plugin param. $plugin is then NULL which will raise an error on the first line of the function when it is accessed like an array.
A better fix would be to remove the default value for $conf and $data (as well as $plugin).
An array type declaration should also be added to $plugin. This will cause no harmful side-effects because $plugin must be an array anyway to avoid errors.
Comment #10
beagaliana commentedHi. I know this is marked as fixed and contributions are preferred as a fork+MR. However, I'm having these two errors below and I used part of this issue's solution to fix it, so I thought I might as well share the patch in case is useful to anyone.
I'm using Ctools version 7.x-1.19 with PHP 8.1 and these are the deprecated msgs I'm getting.
I attach a simple patch based in https://git.drupalcode.org/project/ctools/-/merge_requests/9 to fix it.
Comment #11
liam morlandA better fix is to remove the defaults. That would fix the errors without causing any side-effects.