* Replace array_column to helper::arrayColumn, compatibility with low version object arrays.

This commit is contained in:
caoyanyi
2023-09-04 14:48:59 +08:00
parent d15df882ed
commit 96b899b527
21 changed files with 41 additions and 41 deletions
+4 -4
View File
@@ -362,7 +362,7 @@ class block extends control
public function dynamic()
{
$this->view->actions = $this->loadModel('action')->getDynamic('all', 'today', 'id_desc', 30);
$this->view->users = $this->loadModel('user')->getPairs('nodeleted|noletter|all', '', 0, array_unique(array_column($this->view->actions, 'actor')));
$this->view->users = $this->loadModel('user')->getPairs('nodeleted|noletter|all', '', 0, array_unique(helper::arrayColumn($this->view->actions, 'actor')));
$this->display();
}
@@ -898,7 +898,7 @@ class block extends control
$orderBy = isset($this->params->orderBy) ? $this->params->orderBy : 'id_desc';
$this->view->projects = $this->loadModel('project')->getOverviewList('byStatus', $type, $orderBy, $count);
$this->view->users = $this->loadModel('user')->getPairs('noletter', '', 0, array_unique(array_column($this->view->projects, 'PM')));
$this->view->users = $this->loadModel('user')->getPairs('noletter', '', 0, array_unique(helper::arrayColumn($this->view->projects, 'PM')));
}
/**
@@ -1571,7 +1571,7 @@ class block extends control
$projectID = $this->session->project;
$this->view->actions = $this->loadModel('action')->getDynamic('all', 'all', 'id_desc', 30, 'all', $projectID);
$this->view->users = $this->loadModel('user')->getPairs('noletter', '', 0, array_unique(array_column($this->view->actions, 'actor')));
$this->view->users = $this->loadModel('user')->getPairs('noletter', '', 0, array_unique(helper::arrayColumn($this->view->actions, 'actor')));
}
/**
@@ -2108,7 +2108,7 @@ class block extends control
public function printDocDynamicBlock()
{
$this->view->actions = $this->loadModel('doc')->getDynamic(30);
$this->view->users = $this->loadModel('user')->getPairs('nodeleted|noletter|all', '', 0, array_unique(array_column($this->view->actions, 'actor')));
$this->view->users = $this->loadModel('user')->getPairs('nodeleted|noletter|all', '', 0, array_unique(helper::arrayColumn($this->view->actions, 'actor')));
}
/**
+6 -6
View File
@@ -50,7 +50,7 @@ class cneModel extends model
if(empty($result) || $result->code != 200 || empty($result->data)) return array();
$instanceList = $result->data;
return array_combine(array_column($instanceList, 'name'), $instanceList);
return array_combine(helper::arrayColumn($instanceList, 'name'), $instanceList);
}
/**
@@ -449,7 +449,7 @@ class cneModel extends model
$apiUrl = "/api/cne/statistics/app";
$result = $this->apiPost($apiUrl, $apiData, $this->config->CNE->api->headers);
if(!isset($result->code) || $result->code != 200)return array_combine(array_column($instancesMetrics, 'id'), $instancesMetrics);
if(!isset($result->code) || $result->code != 200)return array_combine(helper::arrayColumn($instancesMetrics, 'id'), $instancesMetrics);
foreach($result->data as $k8sMetric)
{
@@ -468,7 +468,7 @@ class cneModel extends model
$instancesMetrics[$k8sMetric->name]->memory->rate = $instancesMetrics[$k8sMetric->name]->memory->limit > 0 ? round($instancesMetrics[$k8sMetric->name]->memory->usage / $instancesMetrics[$k8sMetric->name]->memory->limit * 100, 2) : 0;
}
return array_combine(array_column($instancesMetrics, 'id'), $instancesMetrics);
return array_combine(helper::arrayColumn($instancesMetrics, 'id'), $instancesMetrics);
}
/**
@@ -998,7 +998,7 @@ class cneModel extends model
if(empty($result) || $result->code != 200 || empty($result->data)) return array();
$dbList = $result->data;
return array_combine(array_column($dbList, 'name'), $dbList);
return array_combine(helper::arrayColumn($dbList, 'name'), $dbList);
}
/**
@@ -1062,7 +1062,7 @@ class cneModel extends model
if(empty($result) || $result->code != 200 || empty($result->data)) return array();
$dbList = $result->data;
return array_combine(array_column($dbList, 'name'), $dbList);
return array_combine(helper::arrayColumn($dbList, 'name'), $dbList);
}
/**
@@ -1082,7 +1082,7 @@ class cneModel extends model
if(empty($result) || $result->code != 200 || empty($result->data)) return array();
$dbList = $result->data;
return array_combine(array_column($dbList, 'name'), $dbList);
return array_combine(helper::arrayColumn($dbList, 'name'), $dbList);
}
/**
+1 -1
View File
@@ -4101,7 +4101,7 @@ class execution extends control
$this->view->productID = $productID;
$this->view->pager = $pager;
$this->view->orderBy = $orderBy;
$this->view->users = $this->loadModel('user')->getPairs('noletter', '', 0, array_unique(array_column($executionStats, 'PM')));
$this->view->users = $this->loadModel('user')->getPairs('noletter', '', 0, array_unique(helper::arrayColumn($executionStats, 'PM')));
$this->view->projects = array('') + $this->project->getPairsByProgram();
$this->view->status = $status;
$this->view->from = $from;
+9 -9
View File
@@ -63,10 +63,10 @@ class InstanceModel extends model
->andWhere('deleted')->eq(0)
->fetchAll('id');
$spaces = $this->dao->select('*')->from(TABLE_SPACE)->where('deleted')->eq(0)->andWhere('id')->in(array_column($instances, 'space'))->fetchAll('id');
$spaces = $this->dao->select('*')->from(TABLE_SPACE)->where('deleted')->eq(0)->andWhere('id')->in(helper::arrayColumn($instances, 'space'))->fetchAll('id');
foreach($instances as $instance) $instance->spaceData = zget($spaces, $instance->space, new stdclass);
$solutionIDList = array_column($instances, 'solution');
$solutionIDList = helper::arrayColumn($instances, 'solution');
$solutions = $this->dao->select('*')->from(TABLE_SOLUTION)->where('id')->in($solutionIDList)->fetchAll('id');
foreach($instances as $instance) $instance->solutionData = zget($solutions, $instance->solution, new stdclass);
@@ -119,12 +119,12 @@ class InstanceModel extends model
$spaces = $this->dao->select('*')->from(TABLE_SPACE)
->where('deleted')->eq(0)
->andWhere('id')->in(array_column($instances, 'space'))
->andWhere('id')->in(helper::arrayColumn($instances, 'space'))
->fetchAll('id');
foreach($instances as $instance) $instance->spaceData = zget($spaces, $instance->space, new stdclass);
$solutionIDList = array_column($instances, 'solution');
$solutionIDList = helper::arrayColumn($instances, 'solution');
$solutions = $this->dao->select('*')->from(TABLE_SOLUTION)->where('id')->in($solutionIDList)->fetchAll('id');
foreach($instances as $instance) $instance->solutionData = zget($solutions, $instance->solution, new stdclass);
@@ -143,7 +143,7 @@ class InstanceModel extends model
$spaces = $this->dao->select('*')->from(TABLE_SPACE)
->where('deleted')->eq(0)
->andWhere('id')->in(array_column($instances, 'space'))
->andWhere('id')->in(helper::arrayColumn($instances, 'space'))
->fetchAll('id');
foreach($instances as $instance) $instance->spaceData = zget($spaces, $instance->space, new stdclass);
@@ -330,7 +330,7 @@ class InstanceModel extends model
->andWhere("REPLACE(domain, '.$sysDomain', '')")->like("%.%")
->fetchAll('id');
$spaces = $this->dao->select('*')->from(TABLE_SPACE)->where('deleted')->eq(0)->andWhere('id')->in(array_column($instanceList, 'space'))->fetchAll('id');
$spaces = $this->dao->select('*')->from(TABLE_SPACE)->where('deleted')->eq(0)->andWhere('id')->in(helper::arrayColumn($instanceList, 'space'))->fetchAll('id');
foreach($instanceList as $instance) $instance->spaceData = zget($spaces, $instance->space, new stdclass);
@@ -1518,8 +1518,8 @@ class InstanceModel extends model
$backupList = $result->data;
usort($backupList, function($backup1, $backup2){ return $backup1->create_time < $backup2->create_time; });
$accounts = array_column($backupList, 'creator');
foreach($backupList as $backup) $accounts = array_merge($accounts, array_column($backup->restores, 'creator'));
$accounts = helper::arrayColumn($backupList, 'creator');
foreach($backupList as $backup) $accounts = array_merge($accounts, helper::arrayColumn($backup->restores, 'creator'));
$accounts = array_unique($accounts);
@@ -1652,7 +1652,7 @@ class InstanceModel extends model
->fetchAll();
if(empty($instanceList)) return;
$spaceList = $this->dao->select('*')->from(TABLE_SPACE)->where('id')->in(array_column($instanceList, 'space'))->fetchAll('id');
$spaceList = $this->dao->select('*')->from(TABLE_SPACE)->where('id')->in(helper::arrayColumn($instanceList, 'space'))->fetchAll('id');
foreach($instanceList as $instance)
{
+2 -2
View File
@@ -123,7 +123,7 @@ class mrModel extends model
public function getGiteaProjects($hostID = 0)
{
$projects = $this->loadModel('gitea')->apiGetProjects($hostID);
return array($hostID => array_column($projects, null, 'full_name'));
return array($hostID => helper::arrayColumn($projects, null, 'full_name'));
}
/**
@@ -136,7 +136,7 @@ class mrModel extends model
public function getGogsProjects($hostID = 0)
{
$projects = $this->loadModel('gogs')->apiGetProjects($hostID);
return array($hostID => array_column($projects, null, 'full_name'));
return array($hostID => helper::arrayColumn($projects, null, 'full_name'));
}
/**
+1 -1
View File
@@ -150,7 +150,7 @@ class myModel extends model
/* Sort by storyCount, get 5 records */
$products = json_decode(json_encode($products), true);
array_multisort(array_column($products, 'storyEstimateCount'), SORT_DESC, $products);
array_multisort(helper::arrayColumn($products, 'storyEstimateCount'), SORT_DESC, $products);
$products = array_slice($products, 0, 5);
$data = new stdClass();
+1 -1
View File
@@ -75,7 +75,7 @@ class program extends control
}
/* Get PM id list. */
$accounts = array_unique(array_column(json_decode(json_encode($programs), true), 'PM'));
$accounts = array_unique(helper::arrayColumn($programs, 'PM'));
$hasProject = false;
foreach($programs as $program)
{
+2 -2
View File
@@ -215,7 +215,7 @@ class repo extends control
$products = $this->loadModel('product')->getPairs('', 0, '', 'all');
$linkedProducts = $this->loadModel('product')->getByIdList(explode(',', $repo->product));
$linkedProductPairs = array_combine(array_keys($linkedProducts), array_column(json_decode(json_encode($linkedProducts), true), 'name'));
$linkedProductPairs = array_combine(array_keys($linkedProducts), helper::arrayColumn($linkedProducts, 'name'));
$products = $products + $linkedProductPairs;
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->edit;
@@ -1695,7 +1695,7 @@ class repo extends control
$products = $postData->objectID ? $this->loadModel('product')->getProductPairsByProject($objectID) : $this->loadModel('product')->getPairs();
$linkedProducts = $this->loadModel('product')->getByIdList($postData->products);
$linkedProductPairs = array_combine(array_keys($linkedProducts), array_column($linkedProducts, 'name'));
$linkedProductPairs = array_combine(array_keys($linkedProducts), helper::arrayColumn($linkedProducts, 'name'));
$products = $products + $linkedProductPairs;
return print (html::select('product[]', $products, $selectedProducts, "class='form-control chosen' multiple"));
+1 -1
View File
@@ -363,7 +363,7 @@ class repoZen extends repo
else
{
$infos = $this->scm->ls($path, $revision);
$revisionList = array_column($infos, 'revision', 'revision');
$revisionList = helper::arrayColumn($infos, 'revision', 'revision');
$comments = $this->repo->getHistory($repo->id, $revisionList);
foreach($infos as $info)
{
+1 -1
View File
@@ -79,7 +79,7 @@ class space extends control
/* Data sort. */
list($order, $sort) = explode('_', $orderBy);
$orderInstances = json_decode(json_encode($allInstances), true);
$createdColumn = array_column($orderInstances, $order == 'id' ? 'createdAt' : $order);
$createdColumn = helper::arrayColumn($orderInstances, $order == 'id' ? 'createdAt' : $order);
array_multisort($createdColumn, $sort == 'desc' ? SORT_DESC : SORT_ASC, $allInstances);
/* Pager. */
+1 -1
View File
@@ -107,7 +107,7 @@ class spaceModel extends model
$this->loadModel('store');
foreach($instances as $instance) $instance->latestVersion = $this->store->appLatestVersion($instance->appID, $instance->version);
$solutionIDList = array_column($instances, 'solution');
$solutionIDList = helper::arrayColumn($instances, 'solution');
$solutions = $this->dao->select('*')->from(TABLE_SOLUTION)->where('id')->in($solutionIDList)->fetchAll('id');
foreach($instances as $instance) $instance->solutionData = zget($solutions, $instance->solution, new stdclass);
+1 -1
View File
@@ -12,7 +12,7 @@
?>
<?php include $this->app->getModuleRoot() . '/common/view/header.html.php';?>
<?php js::set('instanceNotices', $lang->instance->notices);?>
<?php js::set('instanceIdList', array_column($instances, 'id'));?>
<?php js::set('instanceIdList', helper::arrayColumn($instances, 'id'));?>
<div id='mainMenu' class='clearfix'>
<form id="spaceSearchForm" method="post" class="not-watch load-indicator">
<div class="btn-toolbar pull-left">
+1 -1
View File
@@ -75,7 +75,7 @@ class store extends control
$pager = pager::init($pagedApps->total, $recPerPage, $pageID);
$pagedCategories = $this->store->getCategories();
$categories = array_combine(array_column($pagedCategories->categories, 'id'), array_column($pagedCategories->categories, 'alias'));
$categories = array_combine(helper::arrayColumn($pagedCategories->categories, 'id'), helper::arrayColumn($pagedCategories->categories, 'alias'));
$this->lang->switcherMenu = $this->store->getBrowseSwitcher();
+2 -2
View File
@@ -144,7 +144,7 @@ class storeModel extends model
$result = commonModel::apiGet($apiUrl, $apiParams, $this->config->cloud->api->headers);
if(!isset($result->code) || $result->code != 200) return array();
return array_combine(array_column($result->data, 'version'), $result->data);
return array_combine(helper::arrayColumn($result->data, 'version'), $result->data);
}
/**
@@ -400,7 +400,7 @@ class storeModel extends model
if(!isset($result->code) || $result->code != 200) return null;
$solution = $result->data;
$solution->apps = array_combine(array_column($solution->apps, 'chart'), $solution->apps);
$solution->apps = array_combine(helper::arrayColumn($solution->apps, 'chart'), $solution->apps);
return $solution;
}
+1 -1
View File
@@ -112,7 +112,7 @@ detailBody
h::tr
(
h::td($cloudApp->app_version),
h::td(trim(implode('/', array_column($cloudApp->categories, 'alias')), '/')),
h::td(trim(implode('/', helper::arrayColumn($cloudApp->categories, 'alias')), '/')),
h::td($cloudApp->author),
h::td((new \DateTime($cloudApp->publish_time))->format('Y-m-d')),
)
+1 -1
View File
@@ -63,7 +63,7 @@
<th><?php echo $lang->store->releaseDate;?>:</th>
<td><?php echo (new DateTime($cloudApp->publish_time))->format('Y-m-d');?></td>
<th><?php echo $lang->store->appType;?>:</th>
<td><?php echo trim(implode('/', array_column($cloudApp->categories, 'alias')), '/');?></td>
<td><?php echo trim(implode('/', helper::arrayColumn($cloudApp->categories, 'alias')), '/');?></td>
</tr>
</tbody>
</table>
+1 -1
View File
@@ -4955,7 +4955,7 @@ class storyModel extends model
if($story->parent == -1)
{
$childrenTitle = $this->dao->select('title')->from(TABLE_STORY)->where('parent')->eq($story->id)->fetchAll();
$childrenTitle = array_column($childrenTitle, 'title');
$childrenTitle = helper::arrayColumn($childrenTitle, 'title');
$story->linkStories = implode(',', $childrenTitle);
}
+1 -1
View File
@@ -19,7 +19,7 @@ $memoryInfo['tip'] = trim(substr($memoryInfo['tip'], strpos($memoryInfo['tip'],
jsVar('cpuInfo', $cpuInfo);
jsVar('memoryInfo', $memoryInfo);
jsVar('instanceIdList', array_column($instances, 'id'));
jsVar('instanceIdList', helper::arrayColumn($instances, 'id'));
/* 资源统计 */
div
+1 -1
View File
@@ -1,5 +1,5 @@
<?php $this->app->loadLang('instance');?>
<?php js::set('instanceIdList', array_column($instances, 'id'));?>
<?php js::set('instanceIdList', helper::arrayColumn($instances, 'id'));?>
<div class="cell main-table instance-container">
<h3 class='text-center'><?php echo $lang->instance->runningService;?></h3>
<?php if(empty($instances)):?>
+2 -2
View File
@@ -1224,7 +1224,7 @@ class task extends control
if($task->assignedTo == $currentAccount) $taskEffortFold = 1;
if(!empty($task->team))
{
$teamMember = array_column($task->team, 'account');
$teamMember = helper::arrayColumn($task->team, 'account');
if(in_array($currentAccount, $teamMember)) $taskEffortFold = 1;
}
}
@@ -1873,7 +1873,7 @@ class task extends control
if(!empty($this->view->task->team))
{
$teamAccounts = array_column($this->view->task->team, 'account');
$teamAccounts = helper::arrayColumn($this->view->task->team, 'account');
$teamMembers = array();
foreach($this->view->members as $account => $name)
{
+1 -1
View File
@@ -6873,7 +6873,7 @@ class upgradeModel extends model
if(empty($reviewIssues)) return false;
$reviewIds = array_unique(array_column($reviewIssues, 'review'));
$reviewIds = array_unique(helper::arrayColumn($reviewIssues, 'review'));
$approvalsPairs = $this->dao->select('objectID, max(id) as approval')->from(TABLE_APPROVAL)
->where('objectID')->in($reviewIds)