Problem/Motivation

When attempting to update modules with Drupal next error appears:

Fatal error: Cannot use result of built-in function in write context in /modules/system/system.tar.inc on line 717

Looks like it happens with PHP 7.2. Steps to reproduce:

1. Go to the Modules > Update (admin/modules/update).
2. Select items to update.
3. Confirm updating. Notice the error described above.

Proposed resolution

Drupal uses modified Archive_Tar class. There is new version 1.4.3 which does not use function result by reference.

Comments

aprogs created an issue. See original summary.

aprogs’s picture

Issue summary: View changes
torgormack’s picture

I have just come across this issue on a recently update website of mine.

How do I fix it? - do I need to wait for a core update?

David_Rothstein’s picture

Title: Unable to update modules with PHP 7.2 » Unable to update modules due to Archive_Tar incompatibility with PHP 7.2
Priority: Normal » Critical
Issue tags: +PHP 7.2

Is this reproducible in Drupal 8 also? It looks like the same code: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Archiver%...

It may be very simple to patch (see https://github.com/pear/Archive_Tar/pull/18), and then upgrading to a newer version of Archive_Tar could be discussed in a separate followup issue.

soyjaz’s picture

StatusFileSize
new82.69 KB

Had this problem while trying to backup and migrate using the eponymous module.
Modified the system.tar.inc file accordingly to the new version 1.4.3.
This solved the issue for me, as I hope it does for you.

göran’s picture

also get error when try to update Modules:

Ett AJAX HTTP-fel inträffade Resultatkod för HTTP: 200 Felsökningsinformation följer. Sökväg: /batch?render=overlay&id=476&op=do Statustext: OK Svarstext: Fatal error: Cannot use result of built-in function in write context in /myDP_Core/modules/system/system.tar.inc on line 717.

This error is fully related to PHP 7.2 -
I will not patch my core! I will use php 7.1 instead, waiting for a ordinary fix. (Also Rules need to be updated for php 7.2 and probably more modules ?)

It would be grate if this could be fixed in next Core 7.59 version
We probably need a list on all modules who needs to be updated to be compatible with PHP 7.2. That's why I will use php 7.1 until right time comes.

nicorac’s picture

StatusFileSize
new291 bytes

Here's the very simple patch to fix this deprecation, based on upstream commit

nicorac’s picture

StatusFileSize
new278 bytes

Fixed patch line endings

sjerdo’s picture

@David_Rothstein (comment #4)
I have tried to reproduce this issue in Drupal 8 (using PHP 7.2). This fatal error does not occur in Drupal 8.
Somehow the fatal error only occurs when the result of a built-in function is referenced when not in a namespace.

Did some tests:

no namespace, Fatal error occurs in PHP 7.2: (test result at https://3v4l.org/XopHJ)

class Test {
    public function test() {
      $args = & func_get_args();
    }
}

code in namespace, No fatal error occurs in PHP 7.2: (testresult at https://3v4l.org/W16mN)

namespace Test {
  class Test {
      public function test() {
        $args = & func_get_args();
      }
  }
}

So I suppose this could be fixed by wrapping the code in a namespace or update the Archive_Tar class to the newest version (1.4.3). Since we do not use namespaces in Drupal 7, we should do the latter.

Just manually tested the updated class and the fatal error no longer occurs in PHP 7.2

sjerdo’s picture

Status: Active » Needs review
StatusFileSize
new5.42 KB

Added patch which contains updates of PEAR.php (1.9.5 -> 1.10.5) and Archive Tar class (1.4.0 -> 1.4.3).

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

aside from minor code style, this is RTBC

we've combined this latest patch above with the two other patches for php 7.2
all passing, 100% pass for php 7.2 on D7 core, WOOT

#2947772: Fully support PHP 7.2 in Drupal 7

fabianx’s picture

Issue tags: +Pending Drupal 7 commit

Looks good to me and I think it is okay to upgrade the version directly as the code is simple enough: This is pending commit.

srikanth.g’s picture

tar module installation gives the error "Fatal error: Cannot use result of built-in function in write context in \modules\system\system.tar.inc on line 717 drupal"
but zip format modules install fine in my drupal 7.59

fabianx’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Pending Drupal 7 commit

Committed and pushed to 7.x. Thanks all!

  • Fabianx committed 127ffe9 on 7.x
    Issue #2946045 by nicorac, sjerdo, soyjaz, aprogs, Göran, joseph.olstad...

Status: Fixed » Closed (fixed)

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

dimante’s picture

Thanks! This was really helpful and allowed the system to work properly.

Anonymous’s picture

I still was getting this error (php7.2) in 7.60. Changes from #8 fixed the issue.

myDrupal2014_846824658246’s picture

I'm running on drupal 7.6 and getting this error as well when upgrading to php 7.2
The patch on #8 fixed the issue

joseph.olstad’s picture

short term you can upgrade to 7.x dev release , no need for patching on 7.x dev.