Skip to content

Commit

Permalink
Merge pull request Shardj#1 from gfaza/DTPORTAL-14813-handling_php72_…
Browse files Browse the repository at this point in the history
…incompatibilities_by_notifications

Dtportal 14813 handling php72 incompatibilities by notifications
  • Loading branch information
Jenni Lubke authored May 1, 2019
2 parents c4fe107 + 9c4a923 commit b6e97aa
Show file tree
Hide file tree
Showing 87 changed files with 190 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/classmap_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
$maxWidth = max($maxWidth, strlen($match[1]));
}

trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: preg_replace() - \/e modifier is deprecated since PHP 5.5 and removed since PHP 7.0\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$content = preg_replace('(\n\s+([^=]+)=>)e', "'\n \\1' . str_repeat(' ', " . $maxWidth . " - strlen('\\1')) . '=>'", $content);

// Make the file end by EOL
Expand Down
4 changes: 4 additions & 0 deletions library/Zend/Amf/Parse/Resource/MysqlResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ class Zend_Amf_Parse_Resource_MysqlResult
*/
public function parse($resource) {
$result = array();
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'mysql_' is deprecated since PHP 5.5 and removed since PHP 7.0; Use mysqli instead\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$fieldcnt = mysql_num_fields($resource);
$fields_transform = array();
for($i=0;$i<$fieldcnt;$i++) {
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'mysql_' is deprecated since PHP 5.5 and removed since PHP 7.0; Use mysqli instead\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$type = mysql_field_type($resource, $i);
if(isset(self::$fieldTypes[$type])) {
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'mysql_' is deprecated since PHP 5.5 and removed since PHP 7.0; Use mysqli instead\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type];
}
}

trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'mysql_' is deprecated since PHP 5.5 and removed since PHP 7.0; Use mysqli instead\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
while($row = mysql_fetch_object($resource)) {
foreach($fields_transform as $fieldname => $fieldtype) {
settype($row->$fieldname, $fieldtype);
Expand Down
1 change: 1 addition & 0 deletions library/Zend/Amf/Parse/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract class Zend_Amf_Parse_Serializer
public function __construct(Zend_Amf_Parse_OutputStream $stream)
{
$this->_stream = $stream;
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: INI directive 'mbstring.func_overload' is deprecated since PHP 7.2\n\tWARNING: INI directive 'mbstring.func_overload' is deprecated since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$this->_mbStringFunctionsOverloaded = function_exists('mb_strlen') && (ini_get('mbstring.func_overload') !== '') && ((int)ini_get('mbstring.func_overload') & 2);
}

Expand Down
1 change: 1 addition & 0 deletions library/Zend/Amf/Util/BinaryStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function __construct($stream)

$this->_stream = $stream;
$this->_needle = 0;
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: INI directive 'mbstring.func_overload' is deprecated since PHP 7.2\n\tWARNING: INI directive 'mbstring.func_overload' is deprecated since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$this->_mbStringFunctionsOverloaded = function_exists('mb_strlen') && (ini_get('mbstring.func_overload') !== '') && ((int)ini_get('mbstring.func_overload') & 2);
$this->_streamLength = $this->_mbStringFunctionsOverloaded ? mb_strlen($stream, '8bit') : strlen($stream);
$this->_bigEndian = (pack('l', 1) === "\x00\x00\x00\x01");
Expand Down
17 changes: 17 additions & 0 deletions library/Zend/Cache/Backend/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function __construct(array $options = array())
*/
public function __destruct()
{
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
@sqlite_close($this->_getConnection());
}

Expand All @@ -118,6 +119,7 @@ public function load($id, $doNotTestCacheValidity = false)
$sql = $sql . " AND (expire=0 OR expire>" . time() . ')';
}
$result = $this->_query($sql);
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$row = @sqlite_fetch_array($result);
if ($row) {
return $row['content'];
Expand All @@ -136,6 +138,7 @@ public function test($id)
$this->_checkAndBuildStructure();
$sql = "SELECT lastModified FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
$result = $this->_query($sql);
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$row = @sqlite_fetch_array($result);
if ($row) {
return ((int) $row['lastModified']);
Expand All @@ -160,6 +163,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$this->_checkAndBuildStructure();
$lifetime = $this->getLifetime($specificLifetime);
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$data = @sqlite_escape_string($data);
$mktime = time();
if ($lifetime === null) {
Expand Down Expand Up @@ -191,6 +195,7 @@ public function remove($id)
{
$this->_checkAndBuildStructure();
$res = $this->_query("SELECT COUNT(*) AS nbr FROM cache WHERE id='$id'");
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$result1 = @sqlite_fetch_single($res);
$result2 = $this->_query("DELETE FROM cache WHERE id='$id'");
$result3 = $this->_query("DELETE FROM tag WHERE id='$id'");
Expand Down Expand Up @@ -233,6 +238,7 @@ public function getIds()
$this->_checkAndBuildStructure();
$res = $this->_query("SELECT id FROM cache WHERE (expire=0 OR expire>" . time() . ")");
$result = array();
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
while ($id = @sqlite_fetch_single($res)) {
$result[] = $id;
}
Expand All @@ -249,6 +255,7 @@ public function getTags()
$this->_checkAndBuildStructure();
$res = $this->_query("SELECT DISTINCT(name) AS name FROM tag");
$result = array();
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
while ($id = @sqlite_fetch_single($res)) {
$result[] = $id;
}
Expand All @@ -272,6 +279,7 @@ public function getIdsMatchingTags($tags = array())
if (!$res) {
return array();
}
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
$ids2 = array();
foreach ($rows as $row) {
Expand Down Expand Up @@ -302,6 +310,7 @@ public function getIdsMatchingTags($tags = array())
public function getIdsNotMatchingTags($tags = array())
{
$res = $this->_query("SELECT id FROM cache");
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
$result = array();
foreach ($rows as $row) {
Expand All @@ -312,6 +321,7 @@ public function getIdsNotMatchingTags($tags = array())
if (!$res) {
return array();
}
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$nbr = (int) @sqlite_fetch_single($res);
if ($nbr > 0) {
$matching = true;
Expand Down Expand Up @@ -341,6 +351,7 @@ public function getIdsMatchingAnyTags($tags = array())
if (!$res) {
return array();
}
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
$ids2 = array();
foreach ($rows as $row) {
Expand Down Expand Up @@ -397,6 +408,7 @@ public function getMetadatas($id)
$tags = array();
$res = $this->_query("SELECT name FROM tag WHERE id='$id'");
if ($res) {
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
foreach ($rows as $row) {
$tags[] = $row['name'];
Expand All @@ -407,6 +419,7 @@ public function getMetadatas($id)
if (!$res) {
return false;
}
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$row = @sqlite_fetch_array($res, SQLITE_ASSOC);
return array(
'tags' => $tags,
Expand All @@ -429,6 +442,7 @@ public function touch($id, $extraLifetime)
if (!$res) {
return false;
}
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$expire = @sqlite_fetch_single($res);
$newExpire = $expire + $extraLifetime;
$res = $this->_query("UPDATE cache SET lastModified=" . time() . ", expire=$newExpire WHERE id='$id'");
Expand Down Expand Up @@ -491,6 +505,7 @@ private function _getConnection()
if (is_resource($this->_db)) {
return $this->_db;
} else {
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$this->_db = @sqlite_open($this->_options['cache_db_complete_path']);
if (!(is_resource($this->_db))) {
Zend_Cache::throwException("Impossible to open " . $this->_options['cache_db_complete_path'] . " cache DB file");
Expand All @@ -509,6 +524,7 @@ private function _query($query)
{
$db = $this->_getConnection();
if (is_resource($db)) {
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$res = @sqlite_query($db, $query);
if ($res === false) {
return false;
Expand Down Expand Up @@ -582,6 +598,7 @@ private function _checkStructureVersion()
{
$result = $this->_query("SELECT num FROM version");
if (!$result) return false;
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Extension 'sqlite' is removed since PHP 5.4\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$row = @sqlite_fetch_array($result);
if (!$row) {
return false;
Expand Down
1 change: 1 addition & 0 deletions library/Zend/Crypt/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static function randBytes($length, $strong = false)
return random_bytes($length);
}
if (function_exists('mcrypt_create_iv')) {
trigger_error("PHP 7.2 Compatibility Alert:\n\tERROR: Function mcrypt_create_iv() is deprecated since PHP 7.1 and removed since PHP 7.2; Use random_bytes() or OpenSSL instead\n\tERROR: Extension 'mcrypt' is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl\/mcrypt once available instead\n\tERROR: The constant \"MCRYPT_DEV_URANDOM\" is deprecated since PHP 7.1 and removed since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
$bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
if ($bytes !== false && strlen($bytes) === $length) {
return $bytes;
Expand Down
2 changes: 2 additions & 0 deletions library/Zend/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public static function importString($string)
*/
public static function importFile($filename)
{
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: INI directive 'track_errors' is deprecated since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
@ini_set('track_errors', 1);
$feed = @file_get_contents($filename);
@ini_restore('track_errors');
Expand Down Expand Up @@ -297,6 +298,7 @@ public static function findFeeds($uri)
$contents = $response->getBody();

// Parse the contents for appropriate <link ... /> tags
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: INI directive 'track_errors' is deprecated since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
@ini_set('track_errors', 1);
$pattern = '~(<link[^>]+)/?>~i';
$result = @preg_match_all($pattern, $contents, $matches);
Expand Down
2 changes: 2 additions & 0 deletions library/Zend/Feed/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ public function __construct($uri = null, $string = null, Zend_Feed_Builder_Inter
*/
public function __wakeup()
{
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: INI directive 'track_errors' is deprecated since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
@ini_set('track_errors', 1);
$doc = new DOMDocument;
$doc = @Zend_Xml_Security::scan($this->_element, $doc);
@ini_restore('track_errors');

if (!$doc) {
// prevent the class to generate an undefined variable notice (ZF-2590)
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: The variable '\$php_errormsg' is deprecated since PHP 7.2; Use error_get_last() instead\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
if (!isset($php_errormsg)) {
if (function_exists('xdebug_is_enabled')) {
$php_errormsg = '(error message not available, when XDebug is running)';
Expand Down
2 changes: 2 additions & 0 deletions library/Zend/Feed/Entry/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ public function __construct($uri = null, $element = null)
if (!($element instanceof DOMElement)) {
if ($element) {
// Load the feed as an XML DOMDocument object
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: INI directive 'track_errors' is deprecated since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
@ini_set('track_errors', 1);
$doc = new DOMDocument();
$doc = @Zend_Xml_Security::scan($element, $doc);
@ini_restore('track_errors');

if (!$doc) {
// prevent the class to generate an undefined variable notice (ZF-2590)
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: The variable '\$php_errormsg' is deprecated since PHP 7.2; Use error_get_last() instead\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
if (!isset($php_errormsg)) {
if (function_exists('xdebug_is_enabled')) {
$php_errormsg = '(error message not available, when XDebug is running)';
Expand Down
2 changes: 2 additions & 0 deletions library/Zend/Feed/Entry/Atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,15 @@ public function save($postUri = null)
}

// Update internal properties using $client->responseBody;
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: INI directive 'track_errors' is deprecated since PHP 7.2\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
@ini_set('track_errors', 1);
$newEntry = new DOMDocument;
$newEntry = @Zend_Xml_Security::scan($response->getBody(), $newEntry);
@ini_restore('track_errors');

if (!$newEntry) {
// prevent the class to generate an undefined variable notice (ZF-2590)
trigger_error("PHP 7.2 Compatibility Alert:\n\tWARNING: The variable '\$php_errormsg' is deprecated since PHP 7.2; Use error_get_last() instead\n\t".implode("\n\t", array_map(function ($item) { return sprintf("%s::%s", $item['file'], $item['line']); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING);
if (!isset($php_errormsg)) {
if (function_exists('xdebug_is_enabled')) {
$php_errormsg = '(error message not available, when XDebug is running)';
Expand Down
Loading

0 comments on commit b6e97aa

Please sign in to comment.