Unverified Commit d969b1b1 authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/14494 rework count in cluster.php to avoid warning

parent c3264116
Pipeline #8844 failed with stage
......@@ -151,7 +151,7 @@ class cluster
try {
$this->sdoFactory->update($cluster, "digitalResource/cluster");
$this->sdoFactory->deleteChildren("digitalResource/clusterRepository", $cluster, "digitalResource/cluster");
if (count($cluster->clusterRepository) > 0) {
if (is_array($cluster->clusterRepository) && !empty($cluster->clusterRepository)) {
$this->sdoFactory->createCollection($cluster->clusterRepository, "digitalResource/clusterRepository");
}
} catch (\core\Route\Exception $e) {
......@@ -236,7 +236,7 @@ class cluster
}
}
if (count($cluster->clusterRepository) == 0) {
if (is_array($cluster->clusterRepository) && !empty($cluster->clusterRepository)) {
throw \laabs::newException("digitalResource/noClusterRepositoryException", "No repository for %s mode", 404, null, [$mode]);
}
}
......@@ -250,9 +250,9 @@ class cluster
*
* @return String[] Array of ressource container on the cluster
*/
public function openContainers($cluster, $path, $metadata=null)
public function openContainers($cluster, $path, $metadata = null)
{
if (count($cluster->clusterRepository) < 1) {
if (empty($cluster->clusterRepository)) {
throw \laabs::newException("digitalResource/clusterException", "All repositories must be accessible");
}
......@@ -299,7 +299,7 @@ class cluster
*/
public function rollbackStorage($resource)
{
if (is_array($resource->address) && count($resource->address)) {
if (is_array($resource->address) && !empty($resource->address)) {
foreach ($resource->address as $address) {
$this->repositoryController->rollbackStorage($address);
}
......@@ -335,7 +335,6 @@ class cluster
$resource->setContents($contents);
return $contents;
} catch (\Exception $e) {
$address->integrityCheckResult = false;
$this->sdoFactory->update($address);
......@@ -374,7 +373,7 @@ class cluster
$queryParams['resId'] = $resource->resId;
$queryParts['resId'] = "resId = :resId";
$queryString = implode(' AND ', $queryParts );
$queryString = implode(' AND ', $queryParts);
$resource->address = $this->sdoFactory->find("digitalResource/address", $queryString, $queryParams);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment