steps to reproduce
- create a test template, Template:Test in a wiki using PHP < 5.4.0 and with the TemplateData extension active.
- place a test <templatedata/> JSON in the template
- 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