Page MenuHomePhabricator

Fatal error: Call to undefined function gzdecode()
Closed, ResolvedPublic

Description

steps to reproduce

  1. create a test template, Template:Test in a wiki using PHP < 5.4.0 and with the TemplateData extension active.
  2. place a test <templatedata/> JSON in the template
  3. use the api to retrieve the templatedata as a JSON with api.php?action=templatedata&titles=Template:Test

result

Fatal error: Call to undefined function gzdecode() in /core/extensions/TemplateData/TemplateDataBlob.php on line 59

expected result

the JSON in Template:Test.

issue

TemplateData/TemplateDataBlob.php line 59 relies on gzdecode() to decode a potentially gzipped JSON. gzdecode() is only available in (PHP 5 >= 5.4.0) when compiled with zlib.

potential solution

public static function newFromDatabase( $json ) {

// Handle GZIP compression. \037\213 is the header for GZIP files.
if ( substr( $json, 0, 2 ) === "\037\213" ) {
  if ( function_exists( 'gzdecode' ) ) {
    $json = gzdecode( $json );
  } else {
    $json = gzinflate( substr( $json, 10, -8 ) );
  }
}
return self::newFromJSON( $json );

}

@see http://stackoverflow.com/questions/9801908/php-call-to-undefined-function-gzdecode#answer-10381158.


Version: master
Severity: normal

Details

Reference
bz54084

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:13 AM
bzimport added a project: TemplateData.
bzimport set Reference to bz54084.
bzimport added a subscriber: Unknown Object (MLST).

Change 84015 had a related patch set uploaded by Dan-nl:
Bug: 54084 Fatal error: Call to undefined function gzdecode()

https://gerrit.wikimedia.org/r/84015

  • This bug has been marked as a duplicate of bug 54058 ***

Change 84015 had a related patch set uploaded by Krinkle:
Bug: 54084 Fatal error: Call to undefined function gzdecode()

https://gerrit.wikimedia.org/r/84015

  • This bug has been marked as a duplicate of bug 54058 ***

Change 84015 abandoned by Dan-nl:
Fix "PHP Fatal error: Call to undefined function gzdecode"

Reason:
Superseded by 0e4339d.

https://gerrit.wikimedia.org/r/84015