mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Use proper DBAL connection call with parameter.
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade;
|
|||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
use Alchemy\Phrasea\Model\Entities\FtpCredential;
|
use Alchemy\Phrasea\Model\Entities\FtpCredential;
|
||||||
|
use Doctrine\DBAL\Connection;
|
||||||
use Doctrine\DBAL\Migrations\Configuration\Configuration;
|
use Doctrine\DBAL\Migrations\Configuration\Configuration;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Doctrine\ORM\NoResultException;
|
use Doctrine\ORM\NoResultException;
|
||||||
@@ -357,7 +358,11 @@ class Upgrade39Users implements PreSchemaUpgradeInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$em->getConnection()->executeUpdate('UPDATE Users SET geoname_id=NULL WHERE geoname_id=0');
|
$em->getConnection()->executeUpdate('UPDATE Users SET geoname_id=NULL WHERE geoname_id=0');
|
||||||
$em->getConnection()->executeUpdate('UPDATE Users SET locale=NULL WHERE locale NOT IN ("'.implode('", "', array_keys(Application::getAvailableLanguages())).'")');
|
$em->getConnection()->executeUpdate(
|
||||||
|
'UPDATE Users SET locale=NULL WHERE locale NOT IN (:locales)',
|
||||||
|
['locales' => array_keys(Application::getAvailableLanguages())],
|
||||||
|
['locales' => Connection::PARAM_STR_ARRAY]
|
||||||
|
);
|
||||||
$em->getConnection()->executeUpdate('UPDATE Users SET deleted=1, login=SUBSTRING(login, 11) WHERE login LIKE "(#deleted_%"');
|
$em->getConnection()->executeUpdate('UPDATE Users SET deleted=1, login=SUBSTRING(login, 11) WHERE login LIKE "(#deleted_%"');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,14 +372,28 @@ class Upgrade39Users implements PreSchemaUpgradeInterface
|
|||||||
$perBatch = 100;
|
$perBatch = 100;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$sql = 'SELECT usr_id, activeFTP, addrFTP, loginFTP,
|
$builder = $em->getConnection()->createQueryBuilder();
|
||||||
retryFTP, passifFTP, pwdFTP, destFTP, prefixFTPfolder
|
$sql = $builder
|
||||||
FROM usr
|
->select(
|
||||||
WHERE
|
'u.usr_id',
|
||||||
usr_login NOT LIKE "(#deleted_%"
|
'u.activeFTP',
|
||||||
AND model_of = 0
|
'u.addrFTP',
|
||||||
AND addrFTP != ""'
|
'u.loginFTP',
|
||||||
.sprintf(' LIMIT %d, %d', $offset, $perBatch);
|
'u.retryFTP',
|
||||||
|
'u.passifFTP',
|
||||||
|
'u.pwdFTP',
|
||||||
|
'u.destFTP',
|
||||||
|
'u.prefixFTPfolder'
|
||||||
|
)
|
||||||
|
->from('usr', 'u')
|
||||||
|
->where(
|
||||||
|
$builder->expr()->notLike('u.usr_login', '(#deleted_%'),
|
||||||
|
$builder->expr()->eq('u.model_of', 0),
|
||||||
|
$builder->expr()->neq('u.addrFTP', '')
|
||||||
|
)
|
||||||
|
->setFirstResult($offset)
|
||||||
|
->setMaxResults($perBatch)
|
||||||
|
->getSQL();
|
||||||
|
|
||||||
$rs = $em->getConnection()->fetchAll($sql);
|
$rs = $em->getConnection()->fetchAll($sql);
|
||||||
|
|
||||||
|
@@ -355,8 +355,7 @@ class appbox extends base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return databox[]
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_databoxes()
|
public function get_databoxes()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user