mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Update cache databox
This commit is contained in:
34
lib/classes/cache/databox.class.php
vendored
34
lib/classes/cache/databox.class.php
vendored
@@ -9,6 +9,9 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Core\Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package cache
|
||||
@@ -24,7 +27,7 @@ class cache_databox
|
||||
* @param int $sbas_id
|
||||
* @return cache_databox
|
||||
*/
|
||||
public static function refresh($sbas_id)
|
||||
public static function refresh(Application $app, $sbas_id)
|
||||
{
|
||||
if (self::$refreshing) {
|
||||
return;
|
||||
@@ -32,17 +35,16 @@ class cache_databox
|
||||
|
||||
self::$refreshing = true;
|
||||
|
||||
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
||||
$databox = $appbox->get_databox((int) $sbas_id);
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
|
||||
$date = new \DateTime('-3 seconds');
|
||||
|
||||
$registry = \registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
$last_update = null;
|
||||
|
||||
try {
|
||||
$last_update = $appbox->get_data_from_cache('memcached_update_' . $sbas_id);
|
||||
$last_update = $app['phraseanet.appbox']->get_data_from_cache('memcached_update_' . $sbas_id);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
@@ -58,7 +60,7 @@ class cache_databox
|
||||
return;
|
||||
}
|
||||
|
||||
$connsbas = \connection::getPDOConnection($sbas_id);
|
||||
$connsbas = \connection::getPDOConnection($app, $sbas_id);
|
||||
|
||||
$sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id';
|
||||
$stmt = $connsbas->prepare($sql);
|
||||
@@ -98,7 +100,7 @@ class cache_databox
|
||||
$stmt->execute($params);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$record = new \record_adapter($sbas_id, $row['value']);
|
||||
$record = new \record_adapter($app, $sbas_id, $row['value']);
|
||||
$record->get_caption()->delete_data_from_cache();
|
||||
|
||||
foreach ($record->get_subdefs() as $subdef) {
|
||||
@@ -107,8 +109,8 @@ class cache_databox
|
||||
|
||||
break;
|
||||
case 'structure':
|
||||
$appbox->delete_data_from_cache(\appbox::CACHE_LIST_BASES);
|
||||
$appbox->delete_data_from_cache(\appbox::CACHE_SBAS_IDS);
|
||||
$app['phraseanet.appbox']->delete_data_from_cache(\appbox::CACHE_LIST_BASES);
|
||||
$app['phraseanet.appbox']->delete_data_from_cache(\appbox::CACHE_SBAS_IDS);
|
||||
|
||||
$sql = 'DELETE FROM memcached
|
||||
WHERE site_id = :site_id AND type="structure" AND value = :value';
|
||||
@@ -128,9 +130,9 @@ class cache_databox
|
||||
$date = new \DateTime();
|
||||
$now = $date->format(DATE_ISO8601);
|
||||
|
||||
$appbox->set_data_to_cache($now, 'memcached_update_' . $sbas_id);
|
||||
$app['phraseanet.appbox']->set_data_to_cache($now, 'memcached_update_' . $sbas_id);
|
||||
|
||||
$conn = \connection::getPDOConnection();
|
||||
$conn = \connection::getPDOConnection($app);
|
||||
|
||||
$sql = 'UPDATE sitepreff SET memcached_update = :date';
|
||||
$stmt = $conn->prepare($sql);
|
||||
@@ -149,12 +151,12 @@ class cache_databox
|
||||
* @param mixed content $value
|
||||
* @return Void
|
||||
*/
|
||||
public static function update($sbas_id, $type, $value = '')
|
||||
public static function update(Application $app, $sbas_id, $type, $value = '')
|
||||
{
|
||||
|
||||
$connbas = \connection::getPDOConnection($sbas_id);
|
||||
$connbas = \connection::getPDOConnection($app, $sbas_id);
|
||||
|
||||
$registry = \registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
$sql = 'SELECT distinct site_id as site_id
|
||||
FROM clients
|
||||
@@ -179,11 +181,11 @@ class cache_databox
|
||||
return;
|
||||
}
|
||||
|
||||
public static function insertClient(\databox $databox)
|
||||
public static function insertClient(Application $app, \databox $databox)
|
||||
{
|
||||
$connbas = $databox->get_connection();
|
||||
|
||||
$registry = \registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
$sql = 'SELECT site_id FROM clients WHERE site_id = :site_id';
|
||||
$stmt = $connbas->prepare($sql);
|
||||
|
Reference in New Issue
Block a user