From 85c34af0199c96f9e359ba14c95ea708c2613bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 24 Sep 2015 18:54:28 +0200 Subject: [PATCH] [Qual] Replaced deprecated dol_json_*() --- htdocs/core/ajax/selectsearchbox.php | 2 +- htdocs/core/lib/json.lib.php | 6 ++++++ htdocs/projet/class/projectstats.class.php | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index c7a1c7f6d3006..1783c4794b5eb 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -43,6 +43,6 @@ { $arrayresult['searchintoproject']=$langs->trans("SearchIntoProject", $search_boxvalue); } -print dol_json_encode($arrayresult); +print json_encode($arrayresult); if (is_object($db)) $db->close(); diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 5a87e2537586c..6b868663aa703 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -43,9 +43,12 @@ function json_encode($elements) * @param mixed $elements PHP Object to json encode * @return string Json encoded string * @deprecated PHP >= 5.3 supports native json_encode + * @see json_encode() */ function dol_json_encode($elements) { + dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING); + $num=count($elements); if (is_object($elements)) // Count number of properties for an object { @@ -221,9 +224,12 @@ function json_decode($json, $assoc=false) * @param bool $assoc False return an object, true return an array. Try to always use it with true ! * @return mixed Object or Array or false on error * @deprecated PHP >= 5.3 supports native json_decode + * @see json_decode() */ function dol_json_decode($json, $assoc=false) { + dol_syslog('dol_json_decode() is deprecated. Please update your code to use native json_decode().', LOG_WARNING); + $comment = false; $out=''; diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index 98e9c0ce3e042..0578e3b95deb7 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -371,7 +371,7 @@ function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = if ($foundintocache) // Cache file found and is not too old { dol_syslog(get_class($this) . '::' . __FUNCTION__ . " read data from cache file " . $newpathofdestfile . " " . $filedate . "."); - $data = dol_json_decode(file_get_contents($newpathofdestfile), true); + $data = json_decode(file_get_contents($newpathofdestfile), true); } else { $year = $startyear; while ( $year <= $endyear ) { @@ -397,7 +397,7 @@ function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp); $fp = fopen($newpathofdestfile, 'w'); - fwrite($fp, dol_json_encode($data)); + fwrite($fp, json_encode($data)); fclose($fp); if (! empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK; @@ -460,4 +460,4 @@ function getTransformRateByMonth($year) // var_dump($res);print '
'; return $res; } -} \ No newline at end of file +}