From c819b3b87c097617cb66b342ca54d1ab8c0e9b7b Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 5 Nov 2011 03:15:35 +0100
Subject: [PATCH] Fix: Must work with PHP 5.*

---
 htdocs/core/lib/functions.lib.php | 29 +++++++++++++++++------------
 htdocs/main.inc.php               |  1 -
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 3ec4c3933a1..f36f9e6ad2f 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -31,6 +31,22 @@
  */
 
 
+if (! function_exists('json_encode'))
+{
+    /**
+     * Implement json_encode for PHP that does not support it
+     *
+     * @param	mixed	$elements		PHP Object to json encode
+     * @return 	string					Json encoded string
+     */
+    function json_encode($elements)
+    {
+        if (is_array($elements)) return '["' . join('","', $elements) . '"]';
+        else return '"'.$elements.'"';
+    }
+}
+
+
 /**
  * Return a DoliDB instance (database handler).
  *
@@ -52,18 +68,6 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
 }
 
 
-/**
- *  This function output memory used by PHP and exit everything. Used for debugging purpose.
- *
- *  @return	void
- */
-function dol_stopwithmem()
-{
-    print memory_get_usage();
-    llxFooter();
-    exit;
-}
-
 /**
  *  Function called at end of web php process
  *
@@ -77,6 +81,7 @@ function dol_shutdown()
     dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced)':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG));
 }
 
+
 /**
  *  Return value of a param into GET or POST supervariable
  *
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 27bed102c63..19ff6392f41 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -232,7 +232,6 @@ if (! empty($conf->file->main_force_https))
 if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/core/class/menu.class.php");			// Need 10ko memory (11ko in 2.2)
 if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php");	    // Need 660ko memory (800ko in 2.2)
 if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php');	// Need 22ko memory
-//dol_stopwithmem();
 
 // If install or upgrade process not done or not completely finished, we call the install page.
 if (! empty($conf->global->MAIN_NOT_INSTALLED) || ! empty($conf->global->MAIN_NOT_UPGRADED))
-- 
GitLab