Problem/Motivation

Make sure Drupal 7 becomes compatible with PHP 8.2 (release date 24 November 2022 - https://wiki.php.net/todo/php82). There should be quite a lot of issues related mostly to the deprecation of dynamic properties: https://wiki.php.net/rfc/deprecate_dynamic_properties.

See #3224299: [META] Make Drupal 7 core compatible with PHP 8.1 for how we did it with PHP 8.1.

According to the previous comments and the fact that the D7 EOL was postponed, I think we should support PHP 8.2 in D7. See: #3224299-6: [META] Make Drupal 7 core compatible with PHP 8.1

re. #4, yes D7 End of Life is November 2022, but after that there will be D7 Extended Support:

https://www.drupal.org/project/d7es

I believe that's due to run another 3 years until November 2025, which is beyond when any current version of PHP is due to be supported (directly by the upstream developers at least).

For the reference, here is the D9/10 issue: #3283358: [META] Make Drupal 9/10 compatible with PHP 8.2.

Steps to reproduce

Run tests with PHP 8.2.

Proposed resolution

Make tests pass and fix all child issues.

Remaining tasks

See child issues.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

TBD

Comments

poker10 created an issue. See original summary.

poker10’s picture

StatusFileSize
new281 bytes

Adding a noop patch for the first test.

poker10’s picture

I will add first bunch of Deprecated function: Creation of dynamic property here (as child issues), but maybe we should consider creating a new META for all these issues, like they have done in D9/10: #3275851: [META] Fix PHP 8.2 dynamic property deprecations.

D7 PHP 8.2 testbot is not fully enabled yet (still queueing), so we need to wait a little bit to test that noop.

andypost’s picture

I bet it will need to fix callable syntax as well (which is not yet ported to 9.5.x)

- #3299327: Replace deprecated static::method() calls for PHP 8.2
- #3299890: Refactor views.views_data_helper service usage of self

poker10’s picture

StatusFileSize
new281 bytes

New noop patch, as there was a release in between.

poker10’s picture

Four issues are commited.

It seems like that fixing this: #3304883: [D7 PHP 8.2] Deprecated function: Creation of dynamic property in PDOException class should be sufficient to make the PHP 8.2 tests at least run (see https://www.drupal.org/pift-ci-job/2519057).

Then we can move forward with other deprecations which will arise from the full tests run.

poker10’s picture

StatusFileSize
new281 bytes

The last issue is committed so hopefully the PHP 8.2 testing should be unblocked now.

poker10’s picture

To check the status, I am adding a combined patch including patches from all 5 issues mentioned in the previous comment.

poker10’s picture

StatusFileSize
new281 bytes

Adding a new noop patch, as all issues are committed.

mcdruid’s picture

Yay - great work getting tests passing in PHP 8.2 @poker10!

As we've done before with previous versions I'd suggest that we keep this issue open for a while as there may be other issues we need to fix that are not exercised by core's test suite.

It's fantastic to have tests passing a week or so before PHP 8.2 is released though.

joseph.olstad’s picture

This patch https://www.drupal.org/files/issues/2019-09-23/php-warning-count-param-3...
resolves the following Error /warning:

count(): Parameter must be an array or an object that implements       [warning]
Countable field.crud.inc:789

exposed by custom module code with this hook_update code in companyname_widgets.install

code here:



/**
 * Upgrade to php 7.4 requires a new version of the views module which notifies us of orphaned fields of entity types.
 */
function companyname_widgets_update_7001() {

  $field_name = 'comment_body';
  $entity = 'comment';

  $instances = field_read_instances(array('field_name' => $field_name, 'entity_type' => $entity), array('include_inactive' => TRUE));
  if (!empty($instances)) {
    foreach ($instances as $instance) {
      field_delete_instance($instance, TRUE);
    }
  }

  $field_name = 'field_basic_file_file';
  $entity = 'fieldable_panels_pane';

  $instances = field_read_instances(array('field_name' => $field_name, 'entity_type' => $entity), array('include_inactive' => TRUE));
  if (!empty($instances)) {
    foreach ($instances as $instance) {
      field_delete_instance($instance, TRUE);
    }
  }
}
joseph.olstad’s picture

@mcdruid @poker10, could you please add PHP 8.2 tests for sqlite, psql and mysql into here:
https://www.drupal.org/node/3060/qa

BTW, I've pushed forward a release of i18n that is PHP 8.2 compatible
as well as patches that are passing for:
entity_translation php 8.2 patch

and also work in progress (advancing nicely) patch for:
views
and

Needing some assistance with this one:
ctools

The ctools patch is good, but something went haywire with the automated testing framework, ctools head tests were passing in August/september but since have been failing for no apparent reason, no change was made that co-incides with the failures.

poker10’s picture

Thanks for working on PHP 8.2 support on these contrib modules, @joseph.olstad.

I have proposed some changes to the D7 branch testing here - #3092260: [policy, no patch] Review and update automated testing config for 7.x branch.

joseph.olstad’s picture

@poker10, we're still missing PHP 8.2 from the automated tests, please add PHP 8.2 test for 7.x here:

https://www.drupal.org/node/3060/qa

joseph.olstad’s picture

@poker10, I made an important discovery during the PHP 8.2 contrib mission, trying to fix ctools, but noticed composer errors since Sept 8th 2022 that appear to me to be caused by a new D9.4+ contrib module called "color" that conflicts with the D7 core module also called "color". Since this module does not have a core: 8.x entry, there's something in the drupal.org build process that is not building a require in the correct way. I believe this could possibly be fixed by adding a composer.json to the color project both branches that explicitly says requires Drupal 9.4+.

#3332391: The contrib color project is conflicting with the D7 core color project, breaking ctools 7.x tests and possibly others

I'd appreciate some assistance from heavyweights such as yourself and @mcdruid or others like @andypost to fix this

related issues:
#3327350: Support PHP 8.2 with ctools

and

#3327498: D10 deprecations broke D7 ctools testing since sept 8th-14th 2022

joseph.olstad’s picture

Some positive feedback here, I just upgraded one of my bilingual documentation sites to PHP 8.2.1
PHP 8.2.1 (cli) (built: Jan 6 2023 15:17:58)

It is working so far without any notices, without any warnings showing up in the logs. I've done some pretty quick smoke tests for functionality, so far so good.

PHP 8.2 test results in a real world setup (and it's noticably faster)

with:

  • Drupal core 7.94
  • the core book module

The latest tagged releases of the following contrib modules:

  • admin_views
  • better_formats
  • book_access
  • bootstrap theme
  • code mirror
  • ctools
  • date
  • elysia_cron
  • entity (entity api)
  • entity_translation
  • entity_translation_unified_form
  • efq_extra_field
  • file_entity
  • i18n
  • honeypot
  • jquery_update
  • libraries (Libraries API)
  • logintoboggan
  • media_oembed
  • media
  • multiform (Multiple Forms)
  • navbar
  • pathauto
  • plupload
  • saveva_language_menu
  • title
  • token
  • views
  • views_bulk_operations (VBO)
  • views_slideshow
  • views_slideshow_swiper
  • wysiwyg
  • wysiwyg_codesnippet
  • variable

Out of all of these modules, only two are using patches:

The two patched modules are:
The variable module:

#2799811-2: hook_variable_group_info() allows adding a description which is not used in variable_realm_edit_variables_form()
#2141531-10: The realms of a variable edit form are lost when #ajax is used.
#2432801-2: Incorrect call to variable_get_value()
#2627438-2: typo in hook_variable_info()
#2574061-2: implement hook_hook_info() for Variable Realm
#2574689-3: exported Features code is incorrectly indented
#2576245: export of language_default variable is broken (& any other variables which store an object)
and this unidentified one https://www.drupal.org/files/issues/variable.realm-variable-config-form-...

and the plupload library
#1903850-16: [meta] Patch to remove plupload library examples folder for Drupal distribution

I'll keep testing it and reviewing, however I just wanted to share this because I've not yet upgraded to Drupal 10 and haven't tested that and Drupal 9.5 doesn't run PHP 8.2, so I was pleasantly surprised to start using PHP 8.2 with Drupal 7.94 on a decently complicated setup so much initial success on the first try.

I'm sure there's lots of work to do on contrib yet however this is a great start!

***EDIT*** I just wrote this PHP 8.2 compatibility patch for the date module (and needed it)
#3328051: PHP 8.2 - Fix deprecated dynamic properties

Thanks again to everyone that is contributing and great work everyone! Especially @poker10 and @mcdruid

joseph.olstad’s picture

@mcdruid and @poker10 , wondering if I could have a second opinion on a migrate module issue, I've noticed the tests pass up until PHP 7.3, then from PHP 7.4, 8.0, 8.1, 8.2 , the same error from core in all mentioned test fails.
Spits up an error comming from core modules/field/field.crud.inc

#3333649: Migrate.MigrateCommentUnitTest is failing on PHP 7.4+, test divulges error comming from core

https://www.drupal.org/pift-ci-job/2568554

https://www.drupal.org/node/391350/qa

This module is fairly important because many other important contrib modules such as the 'date' module have automated tests to make sure the date integration with the migrate module is working. People also use the migrate module to migrate from D6 and possibly use it to prepare for migrations to symfony based Drupal although I'm not 100% sure on that.

poker10’s picture

I think that these two issues are probably related:

#3129961: Fix $field / $instance exceptions in field.crud.inc and image.module
#3314719: Notice: Trying to access array offset on value of type null in _field_write_instance()

But it would be great to find the real cause, so we can tell if this is a problem in core (e.g. if this can happen unless there are malformed data or not).

joseph.olstad’s picture

I've got a PHP 8.2 compatible RTBC patch for ctools that is safe but cannot be tested with the Drupal ci testbot until a D10 deprecation issue is resolved and I think they've already resolved similar issues before. Trying to nudge this along , created a new issue in the ctools queue with the notes.

#3335458: D7 ctools head tests affected by D10 deprecations - See upstream issues

joelpittet’s picture

#3336591: PHP 8.2 Compatibility Adding this to related for Panels

poker10’s picture

Re #19, I have checked the issue and it seems to be a problem in the Migrate module, not in D7 core. Added a comment to that issue.

gábor hojtsy’s picture

Title: [META] Make Drupal 7 core compatible with PHP 8.2 » [META] Make key Drupal 7 contrib projects compatible with PHP 8.2

Looks like core is done, it has a green test on 8.2 running fine. So this is about key contrib modules now? If this should be kept about core, then the contrib should have a followup maybe?

joseph.olstad’s picture

@Gábor Hojtsy,
There is still one related core patch in a needs review state related to PHP 8.2 compatibility.
#3314719: Notice: Trying to access array offset on value of type null in _field_write_instance()

mcdruid’s picture

Title: [META] Make key Drupal 7 contrib projects compatible with PHP 8.2 » [META] Make Drupal 7 compatible with PHP 8.2
Status: Active » Fixed

I think we can close this for D7 core now.

If that specific issue would help contrib modules to pass tests on more recent PHP versions, let's please add it to #3366270: [meta] Priorities for 2023-12-06 release of Drupal 7 if it's not already there.

If there are more changes that could be made in core which should be considered, can we please file a follow-up for those?

Thanks!

Status: Fixed » Closed (fixed)

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