mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
Remove legacy record_adapter::get_status
This commit is contained in:
@@ -125,7 +125,8 @@ class LegacyRecordRepository implements RecordRepository
|
|||||||
$connection->quoteIdentifier('type'),
|
$connection->quoteIdentifier('type'),
|
||||||
'originalname AS originalName',
|
'originalname AS originalName',
|
||||||
'sha256',
|
'sha256',
|
||||||
'mime'
|
'mime',
|
||||||
|
'LPAD(BIN(status), 32, \'0\') as status'
|
||||||
)
|
)
|
||||||
->from('record', 'r');
|
->from('record', 'r');
|
||||||
}
|
}
|
||||||
|
2
lib/classes/cache/databox.php
vendored
2
lib/classes/cache/databox.php
vendored
@@ -75,8 +75,6 @@ class cache_databox
|
|||||||
$databox->delete_data_from_cache($key);
|
$databox->delete_data_from_cache($key);
|
||||||
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SHA256;
|
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_SHA256;
|
||||||
$databox->delete_data_from_cache($key);
|
$databox->delete_data_from_cache($key);
|
||||||
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_STATUS;
|
|
||||||
$databox->delete_data_from_cache($key);
|
|
||||||
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_TECHNICAL_DATA;
|
$key = 'record_' . $sbas_id . '_' . $row['value'] . '_' . \record_adapter::CACHE_TECHNICAL_DATA;
|
||||||
$databox->delete_data_from_cache($key);
|
$databox->delete_data_from_cache($key);
|
||||||
|
|
||||||
|
@@ -48,7 +48,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
const CACHE_SHA256 = 'sha256';
|
const CACHE_SHA256 = 'sha256';
|
||||||
const CACHE_SUBDEFS = 'subdefs';
|
const CACHE_SUBDEFS = 'subdefs';
|
||||||
const CACHE_GROUPING = 'grouping';
|
const CACHE_GROUPING = 'grouping';
|
||||||
const CACHE_STATUS = 'status';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
@@ -78,6 +77,10 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
private $collection_id;
|
private $collection_id;
|
||||||
private $mime;
|
private $mime;
|
||||||
private $number;
|
private $number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
private $status;
|
private $status;
|
||||||
private $subdefs;
|
private $subdefs;
|
||||||
private $type;
|
private $type;
|
||||||
@@ -524,51 +527,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
return $this->sha256;
|
return $this->sha256;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_status()
|
|
||||||
{
|
|
||||||
if (!$this->status) {
|
|
||||||
$this->status = $this->retrieve_status();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
* @throws Exception
|
|
||||||
* @throws \Doctrine\DBAL\DBALException
|
|
||||||
*/
|
|
||||||
protected function retrieve_status()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$data = $this->get_data_from_cache(self::CACHE_STATUS);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$data = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false !== $data) {
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = $this->getDataboxConnection()->fetchColumn(
|
|
||||||
'SELECT BIN(status) as status FROM record WHERE record_id = :record_id',
|
|
||||||
[':record_id' => $this->getRecordId()]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (false === $status) {
|
|
||||||
throw new Exception('status not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = str_pad($status, 32, '0', STR_PAD_LEFT);
|
|
||||||
|
|
||||||
$this->set_data_to_cache($status, self::CACHE_STATUS);
|
|
||||||
|
|
||||||
return $status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function has_subdef($name)
|
public function has_subdef($name)
|
||||||
{
|
{
|
||||||
return in_array($name, $this->get_available_subdefs(), false);
|
return in_array($name, $this->get_available_subdefs(), false);
|
||||||
@@ -1490,9 +1448,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
switch ($option)
|
switch ($option)
|
||||||
{
|
{
|
||||||
case self::CACHE_STATUS:
|
|
||||||
$this->status = null;
|
|
||||||
break;
|
|
||||||
case self::CACHE_SUBDEFS:
|
case self::CACHE_SUBDEFS:
|
||||||
$this->subdefs = null;
|
$this->subdefs = null;
|
||||||
break;
|
break;
|
||||||
@@ -1785,7 +1740,9 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
['status' => bindec($status), 'record_id' => $this->getRecordId()]
|
['status' => bindec($status), 'record_id' => $this->getRecordId()]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->delete_data_from_cache(self::CACHE_STATUS);
|
$this->status = str_pad($status, 32, '0', STR_PAD_LEFT);
|
||||||
|
// modification date is now unknown, delete from cache to reload on another record
|
||||||
|
$this->delete_data_from_cache();
|
||||||
|
|
||||||
$this->dispatch(RecordEvents::STATUS_CHANGED, new StatusChangedEvent($this));
|
$this->dispatch(RecordEvents::STATUS_CHANGED, new StatusChangedEvent($this));
|
||||||
}
|
}
|
||||||
@@ -1795,7 +1752,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function getStatus()
|
public function getStatus()
|
||||||
{
|
{
|
||||||
return $this->get_status();
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
@@ -1828,6 +1785,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
'created' => $this->created->format(DATE_ISO8601),
|
'created' => $this->created->format(DATE_ISO8601),
|
||||||
'base_id' => $this->base_id,
|
'base_id' => $this->base_id,
|
||||||
'collection_id' => $this->collection_id,
|
'collection_id' => $this->collection_id,
|
||||||
|
'status' => $this->status,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->set_data_to_cache($data);
|
$this->set_data_to_cache($data);
|
||||||
@@ -1853,6 +1811,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
$this->original_name = $row['originalName'];
|
$this->original_name = $row['originalName'];
|
||||||
$this->sha256 = $row['sha256'];
|
$this->sha256 = $row['sha256'];
|
||||||
$this->mime = $row['mime'];
|
$this->mime = $row['mime'];
|
||||||
|
$this->status = str_pad($row['status'], 32, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user