mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 19:13:26 +00:00
Merge pull request #411 from romainneutron/cache-patch
[3.8] Cache patch
This commit is contained in:
@@ -68,6 +68,13 @@ The idea of `bin/setup` is to provide an commandline tool that is not aware of
|
||||
Phraseanet Installation, whereas `bin/console` requires an up-to-date Phraseanet
|
||||
install.
|
||||
|
||||
## Database Upgrade
|
||||
|
||||
Database will be upgraded when running the `bin/console system:upgrade` command.
|
||||
This command will not remove old tables. To remove them, use the
|
||||
`--dump` option of the previous command to get a dump of the raw SQL commands to
|
||||
execute;
|
||||
|
||||
## Customization
|
||||
|
||||
If you were using custom homepage or LDAP connection, they might not work.
|
||||
|
@@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core;
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
protected static $number = '3.8.0.a10';
|
||||
protected static $number = '3.8.0.a11';
|
||||
protected static $name = 'Carnosaurus';
|
||||
|
||||
public static function getNumber()
|
||||
|
@@ -262,6 +262,7 @@ abstract class base implements cache_cacheableInterface
|
||||
$stmt->closeCursor();
|
||||
|
||||
$ORMTables = array(
|
||||
'AuthFailures',
|
||||
'BasketElements',
|
||||
'Baskets',
|
||||
'StoryWZ',
|
||||
@@ -275,6 +276,9 @@ abstract class base implements cache_cacheableInterface
|
||||
'LazaretChecks',
|
||||
'LazaretFiles',
|
||||
'LazaretSessions',
|
||||
'SessionModules',
|
||||
'Sessions',
|
||||
'UsrAuthProviders',
|
||||
);
|
||||
|
||||
foreach ($rs as $row) {
|
||||
|
@@ -30,8 +30,9 @@ class module_console_systemUpgrade extends Command
|
||||
|
||||
$this
|
||||
->setDescription('Upgrade Phraseanet to the latest version')
|
||||
->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answer yes to all questions and do not ask the user')
|
||||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force the upgrade even if there is a concurrent upgrade');
|
||||
->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answers yes to all questions and do not ask the user')
|
||||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces the upgrade even if there is a concurrent upgrade')
|
||||
->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps SQL queries that can be used to clean database.');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -72,7 +73,21 @@ class module_console_systemUpgrade extends Command
|
||||
|
||||
$upgrader = new Setup_Upgrade($this->container, $input->getOption('force'));
|
||||
|
||||
$this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
|
||||
$queries = $this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
|
||||
|
||||
if ($input->getOption('dump')) {
|
||||
if (0 < count($queries)) {
|
||||
$output->writeln("Some SQL queries can be executed to optimize\n");
|
||||
|
||||
foreach ($queries as $query) {
|
||||
$output->writeln(" ".$query['sql']);
|
||||
}
|
||||
|
||||
$output->writeln("\n");
|
||||
} else {
|
||||
$output->writeln("No SQL queries to execute to optimize\n");
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($upgrader->getRecommendations() as $recommendation) {
|
||||
list($message, $command) = $recommendation;
|
||||
|
116
lib/classes/patch/3811.php
Normal file
116
lib/classes/patch/3811.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2012 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Entities\Session;
|
||||
use Entities\SessionModule;
|
||||
|
||||
class patch_3811 implements patchInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.8.0.a11';
|
||||
|
||||
/** @var array */
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
try {
|
||||
$sql = 'SELECT usr_id, user_agent, ip, platform, browser, app,
|
||||
browser_version, screen, token, nonce, lastaccess, created_on
|
||||
FROM cache';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
} catch (\PDOException $e) {
|
||||
// this may fail on oldest versions
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$created = $updated = null;
|
||||
if ('0000-00-00 00:00:00' !== $row['created_on']) {
|
||||
$created = \DateTime::createFromFormat('Y-m-d H:i:s', $row['created_on']);
|
||||
}
|
||||
if ('0000-00-00 00:00:00' !== $row['lastaccess']) {
|
||||
$updated = \DateTime::createFromFormat('Y-m-d H:i:s', $row['lastaccess']);
|
||||
}
|
||||
|
||||
$session = new Session();
|
||||
$session
|
||||
->setUsrId($row['usr_id'])
|
||||
->setUserAgent($row['user_agent'])
|
||||
->setUpdated($updated)
|
||||
->setToken($row['token'])
|
||||
->setPlatform($row['platform'])
|
||||
->setNonce($row['nonce'])
|
||||
->setIpAddress($row['ip'])
|
||||
->setCreated($created)
|
||||
->setBrowserVersion($row['browser_version'])
|
||||
->setBrowserName($row['browser']);
|
||||
|
||||
$sizes = explode ('x', $row['screen']);
|
||||
|
||||
if (2 === count($sizes)) {
|
||||
$session
|
||||
->setScreenWidth($sizes[0])
|
||||
->setScreenHeight($sizes[1]);
|
||||
}
|
||||
|
||||
if (false !== $apps = @unserialize($row['app'])) {
|
||||
foreach ($apps as $app) {
|
||||
$module = new SessionModule();
|
||||
$module
|
||||
->setModuleId($app)
|
||||
->setCreated($created)
|
||||
->setSession($session)
|
||||
->setUpdated($updated);
|
||||
|
||||
$session->addModule($module);
|
||||
|
||||
$app['EM']->persist($module);
|
||||
}
|
||||
}
|
||||
|
||||
$app['EM']->persist($session);
|
||||
}
|
||||
|
||||
$app['EM']->flush();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user