From 93bbd6770e891e80dde4513252ddb370facbb3ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 Sep 2023 11:20:30 +0200 Subject: [PATCH] Fix function stream_wrapper_restore not found --- htdocs/core/class/dolgeoip.class.php | 8 ++++++-- htdocs/filefunc.inc.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 2aaaf2e666f..86f02628ff2 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -56,13 +56,17 @@ class DolGeoIP if ($type == 'country') { // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) { - stream_wrapper_restore('phar'); + if (function_exists('stream_wrapper_restore')) { + stream_wrapper_restore('phar'); + } require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; } } elseif ($type == 'city') { // geoip may have been already included with PEAR if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) { - stream_wrapper_restore('phar'); + if (function_exists('stream_wrapper_restore')) { + stream_wrapper_restore('phar'); + } require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; } } else { diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index d110660b6f5..cfad9f838b1 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -80,7 +80,7 @@ $result = @include_once $conffile; // Keep @ because with some error reporting t // Disable some not used PHP stream $listofwrappers = stream_get_wrappers(); -// We need '.phar' for geoip2. TODO Replace phar with explode files so we can disable phar. +// We need '.phar' for geoip2. TODO Replace phar in geoip with exploded files so we can disable phar. $arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftps', 'glob', 'data', 'expect', 'ftp', 'ogg', 'rar', 'zip', 'zlib'); foreach ($arrayofstreamtodisable as $streamtodisable) { if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {