Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 Deprecated function: Optional parameter $input declared before required parameter $form_state is implicitly treated as a required parameter in include_once() #6005

Open
jenlampton opened this issue Feb 28, 2023 · 3 comments

Comments

@jenlampton
Copy link
Member

Description of the bug

I'm running a backdrop site on php 8.1 with deprecation warnings enabled, and I'm seeing a handful of these:

Deprecated function: Optional parameter $input declared before required parameter $form_state is implicitly treated as a required parameter in include_once() (line 1509 of backdrop/docroot/core/includes/bootstrap.inc).

These functions called via bootstrap.inc can be hard to track down...
Searching for $input before $form_state in function definitions returns a set of Form API value callbacks, all from core:

$value_callback($element, $input, $form_state);

Such as:

  • file_field_widget_value()
  • file_managed_file_value()
  • form_type_image_button_value()
  • form_type_textarea_value()
  • form_type_textfield_value()
  • list_boolean_allowed_values_callback()

Should we check all these to make sure that there are no optional items before required?

Steps To Reproduce

To reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'

Actual behavior

PHP warnings about deprecations

Expected behavior

No warnings :)

Additional information

Add any other information that could help, such as:

  • Backdrop CMS version: 1.24.0
  • PHP version: 8.1
@argiepiano
Copy link

Hi @jenlampton. I've checked those functions, but none of of them have an optional $input before $form_state. The culprit may be somewhere else. I'm using Backdrop with PHP 8.1 and am not seeing these messages (we have been fixing several of them in the past). I wonder if perhaps this is happening in a contrib module you have installed?

I'm searching core and several contrib modules using the following regex pattern
/\$input = (.*), \$form_state(,|\))/

and am not finding any so far.

@laryn
Copy link
Contributor

laryn commented Feb 28, 2023

@jenlampton If you have a copy of the site running locally and have xdebug installed you should be able to view the call stack to see what is firing before these warnings.

@kiamlaluno
Copy link
Member

Does that error happen with only Backdrop installed, or are there contributed modules installed?

Line 1509 is part of backdrop_load(). If the error is caused by Backdrop core, there are 22 functions/methods that call backdrop_load().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants