Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Move JUpdater:arrayUnique() to JArrayHelper::arrayUnique(). Keep JUpd…
Browse files Browse the repository at this point in the history
…ater:arrayUnique() as an alias an deprecate it.
  • Loading branch information
realityking committed Jun 14, 2011
1 parent f5c536e commit 354a765
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
23 changes: 7 additions & 16 deletions libraries/joomla/updater/updater.php
Expand Up @@ -14,6 +14,8 @@
jimport('joomla.filesystem.archive');
jimport('joomla.filesystem.path');
jimport('joomla.base.adapter');
jimport('joomla.utilities.arrayhelper');
jimport('joomla.log.log');

/**
* Updater Class
Expand Down Expand Up @@ -79,7 +81,7 @@ public function findUpdates($eid=0) {
{
if(array_key_exists('update_sites',$update_result) && count($update_result['update_sites']))
{
$results = $this->arrayUnique(array_merge($results, $update_result['update_sites']));
$results = JArrayHelper::arrayUnique(array_merge($results, $update_result['update_sites']));
$result_count = count($results);
}
if(array_key_exists('updates', $update_result) && count($update_result['updates']))
Expand Down Expand Up @@ -139,24 +141,13 @@ public function findUpdates($eid=0) {
* Multidimensional array safe unique test
* Borrowed from PHP.net
* @see http://au2.php.net/manual/en/function.array-unique.php
*
* @deprecated 11.1 Use JArrayHelper::arrayUnique() instead.
*/
public function arrayUnique($myArray)
{
if (!is_array($myArray)) {
return $myArray;
}

foreach ($myArray as &$myvalue){
$myvalue=serialize($myvalue);
}

$myArray=array_unique($myArray);

foreach ($myArray as &$myvalue){
$myvalue=unserialize($myvalue);
}

return $myArray;
JLog::add('JUpdater::arrayUnique() is deprecated. See JArrayHelper::arrayUnique().', JLog::WARNING, 'deprecated');
return JArrayHelper::arrayUnique($myArray);
}

public function update($id)
Expand Down
24 changes: 24 additions & 0 deletions libraries/joomla/utilities/arrayhelper.php
Expand Up @@ -360,4 +360,28 @@ protected static function _sortObjects(&$a, &$b)

return 0;
}

/**
* Multidimensional array safe unique test
* Borrowed from PHP.net
* @see http://au2.php.net/manual/en/function.array-unique.php
*/
public static function arrayUnique($myArray)
{
if (!is_array($myArray)) {
return $myArray;
}

foreach ($myArray as &$myvalue){
$myvalue=serialize($myvalue);
}

$myArray=array_unique($myArray);

foreach ($myArray as &$myvalue){
$myvalue=unserialize($myvalue);
}

return $myArray;
}
}

0 comments on commit 354a765

Please sign in to comment.