CMS MADE SIMPLE FORGE

Gallery

 

[#11958] Notices in error log

avatar
Created By: Rolf (rolf1)
Date Submitted: Sat Jan 26 04:13:54 -0500 2019

Assigned To: Jos (josvd)
Version: 2.3.2
CMSMS Version: 2.2.9
Severity: Minor
Resolution: Fixed
State: Closed
Summary:
Notices in error log
Detailed Description:
Hello Jos,

I found a some Gallery related notices in my error log:

[26-Jan-2019 10:06:40 Europe/Amsterdam] PHP Deprecated:  Function
create_function() is deprecated in
/home/public_html/modules/Gallery/lib/class.Gallery_utils.php on line 412

CMSMS 2.2.9
Gallery 2.3.2
PHP 7.2.14

Thanks Rolf


History

Comments
avatar
Date: 2019-03-18 19:19
Posted By:  (JamesT)

According to the PHP docs, "relying on this function is highly discouraged".
      
avatar
Date: 2019-04-03 07:27
Posted By: Franck (knarf)

Just noticed on a PHP 7.2.16 / gallery 2.3.2 / CMSMS 2.2.10 install.
      
avatar
Date: 2019-05-24 10:47
Posted By: Gregor de Graaf (gregor)

Hello Jos,

Using PHP 7.2.18 this notice still is in place. Is there a forecast when this
will be solved in Gallery?

Thanks!
      
avatar
Date: 2019-05-25 21:16
Posted By: Gregor de Graaf (gregor)

Suggested fix of the function where the notice occurs:
	public static function ArraySort($array, $arguments = array(), $keys = true) {
	  uasort($array,function($a,$b) use ($arguments){
		$result = 0;

		foreach ($arguments as $argument) if (!empty($argument)){

		  if (!Is_Numeric($result) || $result == 0){
			// order field
			$field = substr($argument, 2, strlen($argument));
			// sort type ("s" -> string, "n" -> numeric)
			$type = $argument[0];
			// sort order ("+" -> "ASC", "-" -> "DESC")
			$order = $argument[1];

			if (strtolower($type) == "n"){ // if "numeric" sort type
			  $result = ($order == "-")
				? ($a->$field > $b->$field ? -1 : ($a->$field < $b->$field ? 1 : 0))
				: ($a->$field > $b->$field ? 1 : ($a->$field < $b->$field ? -1 : 0));
			}
			else // if "string" sort type
			{
			  $result = ($order == "-")
				? strcoll($a->$field, $b->$field) * -1
				: strcoll($a->$field, $b->$field);
			}
		  }
		}

		return $result;
	  });

	  // return array
	  return $array;
	}

      
avatar
Date: 2019-07-04 18:15
Posted By: Jos (josvd)

fixed in version 2.3.3 with the solution provided by Gregor, thanks!
      
Updates

Updated: 2019-07-04 18:15
resolution_id: => 7
state: Open => Closed