mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 05:23:21 +00:00
Fix latest merge
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
|
||||
class patch_383alpha1a implements patchInterface
|
||||
{
|
||||
@@ -56,6 +57,10 @@ class patch_383alpha1a implements patchInterface
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
if (!$this->hasSessionTable($app)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove deleted users sessions
|
||||
$sql = 'SELECT s.id FROM `Sessions` s, usr u WHERE u.usr_login LIKE "(#deleted%" AND u.usr_id = s.usr_id';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
@@ -81,4 +86,19 @@ class patch_383alpha1a implements patchInterface
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function hasSessionTable(Application $app)
|
||||
{
|
||||
$rsm = (new ResultSetMapping())->addScalarResult('Name', 'Name');
|
||||
$ret = false;
|
||||
|
||||
foreach ($app['EM']->createNativeQuery('SHOW TABLE STATUS', $rsm)->getResult() as $row) {
|
||||
if ('Session' === $row['Name']) {
|
||||
$ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user