Problem/Motivation

Parameters in reverse order to implode() has been deprecated since PHP 7.4 and is removed since PHP 8.0.

FILE: sites/all/modules/contrib/field_group/field_group.module
 1295 | ERROR | Passing the $glue and $pieces parameters in reverse
      |       | order to implode has been deprecated since PHP 7.4
      |       | and is removed since PHP 8.0; $glue should be the
      |       | first parameter and $pieces the second

Steps to reproduce

Run Phpcs compatibility:

phpcs --standard=PHPCompatibility --runtime-set testVersion 7.4 contrib/field_group

Proposed resolution

Correct the order of the parameters.

Original report by rajeshwari10

This issue title and description has been updated to reflect the findings of the contributions in the comments below. The original posting, copied here for posterity, didn't account for existing fixes via #3085340.

PHPCS compatibility errors with PHP 7.2 and 7.4

Run Phpcs compatibility across field_group module. Will get the below warning.

ERROR : Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "$bundle_name" was changed on line 113.

When testing with PHP 7.4, you also get:

sites/all/modules/contrib/field_group/field_group.module line 1294

WARNING | Passing the $glue and $pieces parameters in reverse order to implode has been deprecated since PHP 7.4; $glue should be the first parameter and $pieces the second

Comments

rajeshwari10 created an issue. See original summary.

rajeshwari10’s picture

Status: Active » Needs review
StatusFileSize
new548 bytes

Please find the below patch which will resolve this issue.

dww’s picture

Title: PHPCS compatibility error with PHP 7.2 » PHPCS compatibility errors with PHP 7.2 and 7.4
Issue summary: View changes
Status: Needs review » Needs work

When I run this check on the 7.x-1.x branch, I'm also getting:

FILE: .../web/sites/all/modules/contrib/field_group/field_group.module
---------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------
 1294 | WARNING | Passing the $glue and $pieces parameters in reverse order to
      |         | implode has been deprecated since PHP 7.4; $glue should be the
      |         | first parameter and $pieces the second
---------------------------------------------------------------------------------

Seems worth fixing both of these in the same issue for scope management, right? Fix all the potential PHP 7+ compatibility problems at once, instead of 7.2 vs. 7.4 separately? I'll defer to the maintainers, but I vote for fixing both in 1 issue.

Thanks,
-Derek

dww’s picture

Issue tags: +affects drupal.org
divyesh19’s picture

Assigned: rajeshwari10 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new575 bytes
new863 bytes

As per latest php 7.4 compatibility check on 1.x-dev, we only have the below warning:
WARNING | Passing the $glue and $pieces parameters in reverse order to implode has been deprecated since PHP 7.4; $glue should be the first parameter and $pieces the second

Attached updated patch for the same.

joelpittet’s picture

Status: Needs review » Needs work

@divyesh19 please merge both patches into one patch.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new983 bytes
new472 bytes

Merged both patches #2 and #5 into one patch, please review.

Status: Needs review » Needs work

The last submitted patch, 7: field_group-php-7.2-compatible-3083542-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mrinalini9’s picture

Status: Needs work » Needs review

Please ignore patch #7 and patch #5 will be the updated patch because patch #1 seems to be already present in branch 7.x-1.x.

tormi’s picture

patch #1 seems to be already present in branch 7.x-1.x.

Indeed, duplicate of https://www.drupal.org/project/field_group/issues/3085340.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

My apologies, I should have checked the dev branch, this is great, thanks for everybody's help on this. Please commit #5 the other change was already committed.

fadonascimento’s picture

I have been tested both patches under the php7.4 and both worked as expected.
Should it generate another module version with theses fixes?

jcandan’s picture

Title: PHPCS compatibility errors with PHP 7.2 and 7.4 » Fix PHPCS compatibility warning with PHP 7.4, error with PHP 8.0
Issue summary: View changes
Issue tags: -PHP 7.2 +PHP 8.0, +PHP 7.4

Updated the issue description to make it clear that part of the original issue reported has already been fixed in a separate issue, and that the patch #5 appropriately addresses the single issue noted.

  • swentel committed ce02f9e on 7.x-1.x
    Issue #3083542 by mrinalini9, divyesh19, rajeshwari10: Fix PHPCS...
swentel’s picture

Status: Reviewed & tested by the community » Fixed

committed and pushed, thanks!

swentel’s picture

Status: Fixed » Closed (fixed)