Fix latest merge

This commit is contained in:
Romain Neutron
2013-12-04 08:20:58 +01:00
parent a59e501104
commit 1ba41c4421
2 changed files with 20 additions and 2 deletions

View File

@@ -15,8 +15,6 @@ class Version
{
protected static $number = '3.9.0-alpha.9';
protected static $name = 'Epanterias';
protected static $number = '3.8.3-alpha.1';
protected static $name = 'Diplodocus';
public static function getNumber()
{

View File

@@ -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;
}
}