There are some PHP functions being used in Drupal core and contrib modules that are not compatible when running on PHP 7.2 e.g. count($elements['#value']) in includes/form.inc produces warning message when $elements['#value'] has a string as result.

There are patches for, but the changes are not included in this release. To fix this issue, patches need to be applied for now and wait until the solution is included in the next release.

Comments

chansorpea@ezcompany.nl’s picture

The patch above applies a patch that replaces count() function with empty() function and adds if-statement with is_array() function before calling the count() function.

These changes are made on some necessary core files, not on all core files.

chansorpea@ezcompany.nl’s picture

Patch #3 applies more patches to fix other deprecated functions on PHP 7.2 as well such as:

[PHP 7.2] create_function() is deprecated
Function each() is deprecated since PHP 7.2
Unable to update modules due to Archive_Tar incompatibility with PHP 7.2

Replacing count() function by empty() is also included.

chansorpea@ezcompany.nl’s picture

Patch #3 includes the following patches which might be duplicated. This leads to fail applying patch 2947772-31.patch

projects[drupal][patch][] = "https://www.drupal.org/files/issues/2018-04-21/drupal-7-count-function-d..."
projects[drupal][patch][] = "https://www.drupal.org/files/issues/2018-05-15/drupal-7-php-7-2-2947772-..."

Patch 2885610-19.patch is also included in 2947772-31.patch

See Fully support PHP 7.2 in Drupal 7

Thus, patch #4 applies only two patches which includes everything needed.

paulvandenburg’s picture

Status: Active » Needs review

Looks good!
I've not marked it tested though, because I'll wait until we've done some more extensive testing on the staging environment we've prepared for this.

Danny.Wouters’s picture

I think there will be a D7 release soon to fix compatibility with PHP 7.2 because a lot of patches are recently committed in the dev branch.

I created a new patch for dvg with the PHP 7.2 patches we are using on production sites for several months now.

Danny.Wouters’s picture

Title: Make Drupal 7 compatible on PHP 7.2 » Make Dvg compatible on PHP 7.2
Issue summary: View changes
StatusFileSize
new2 KB

I rerolled the previous patch against the current dev-branch and added PHP 7.2 patches for contrib modules (admin_menu and features)

paulvandenburg’s picture

StatusFileSize
new2.23 KB
new728 bytes

By removing the #2947772: Fully support PHP 7.2 in Drupal 7 patch we were also missing some php7.2 fixes for core.
But instead of readding that patch I've added the few missing patches that have been committed to the core 7.x-dev branch to fix php7.2 compatibility.

I've verified the other core patches match those already committed to core.

The contrib patches look good.

paulvandenburg’s picture

StatusFileSize
new2.84 KB
new676 bytes

Came across another php7.2 incompatibility in webform this time.

It is already fixed and committed to webform in this issue: #2953662: Only use count() on countables.

I've added that fix to this patch as well.

paulvandenburg’s picture

Status: Needs review » Needs work

I've found 2 more issues in contrib modules. However those 2 might need some work on the contrib part.

field_collection: #2936874: PHP7.2 - Deprecated function: each()
The patch does not apply on the field_collection version currently used in DvG.
The error, occurring when creating a simple basic page:
Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in FieldCollectionItemEntity->fetchHostDetails() (line 422 of /<project>/profiles/dvg/modules/contrib/field_collection/field_collection.module).

adminimal_theme: #2951412: Warning notice in php 7.2
The patch might need work, although it currently does solve the issue.
The error, when visiting admin pages like watchdog logs:
Warning: count(): Parameter must be an array or an object that implements Countable in adminimal_table() (line 400 of /<project>/profiles/dvg/themes/adminimal_theme/template.php).

  • paulvandenburg committed 1c6fca6 on 7.x-1.x
    Issue #2988323 by chansorpea@ezcompany.nl, paulvandenburg, Danny.Wouters...
paulvandenburg’s picture

After some internal discussion with Danny.Wouters we've concluded it is best to commit #9 to start making some progress on php7.2 compatibility.

The mentioned fixes for field_collection and adminimal_theme can be added at a later time.

paulvandenburg’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

Both known and mentioned patches are fixed in those 2 projects. So we can now update our versions of those modules to include the patches:
For field_collection we can update to 7.x-1.0-beta13
For adminimal_theme we can update to 7.x-1.25

joshahubbers’s picture

Nice! Looks good and works.

joshahubbers’s picture

Status: Needs review » Reviewed & tested by the community

  • paulvandenburg committed ffdba0f on 7.x-1.x
    Issue #2988323 by paulvandenburg, chansorpea@ezcompany.nl, Danny.Wouters...
paulvandenburg’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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