From d63b93a66e4a58a9860d2c97ea0c62e653245540 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Mon, 16 Jul 2012 13:44:38 +0000 Subject: [PATCH] [-] BO : #PSCFV-3222 - Fix array unique strange working --- classes/Tools.php | 13 +++++++++++++ controllers/admin/AdminProductsController.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/classes/Tools.php b/classes/Tools.php index 4eb8fb0a2..eb549d93d 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -2178,6 +2178,19 @@ FileETag INode MTime Size return false; } + + /** + * Reproduce array_unique working before php version 5.2.9 + * @param array $array + * @return array + */ + public static function arrayUnique($array) + { + if (version_compare(phpversion(), '5.2.9', '<')) + return array_unique($array); + else + return array_unique($array, SORT_REGULAR); + } } /** diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 2d8679a92..21c50ac92 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -3567,7 +3567,7 @@ class AdminProductsControllerCore extends AdminController if ($ws) $warehouses[] = $ws; } - $warehouses = array_unique($warehouses); + $warehouses = Tools::arrayUnique($warehouses); if (empty($warehouses)) $advanced_stock_management_warning = true;