mirror of
https://github.com/nextcloud/server.git
synced 2026-05-22 01:55:56 -04:00
be conservative when reading from fresh created column
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
bbb19b675a
commit
73d5e0c6ae
1 changed files with 13 additions and 3 deletions
|
|
@ -43,6 +43,8 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
|
|||
private $dbc;
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
/** @var string[] */
|
||||
private $hashColumnAddedToTables = [];
|
||||
|
||||
public function __construct(IDBConnection $dbc, LoggerInterface $logger) {
|
||||
$this->dbc = $dbc;
|
||||
|
|
@ -89,6 +91,7 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
|
|||
'length' => 64,
|
||||
]);
|
||||
$changeSchema = true;
|
||||
$this->hashColumnAddedToTables[] = $tableName;
|
||||
}
|
||||
$column = $table->getColumn('ldap_dn');
|
||||
if ($tableName === 'ldap_user_mapping') {
|
||||
|
|
@ -177,9 +180,16 @@ class Version1130Date20211102154716 extends SimpleMigrationStep {
|
|||
|
||||
protected function getSelectQuery(string $table): IQueryBuilder {
|
||||
$qb = $this->dbc->getQueryBuilder();
|
||||
$qb->select('owncloud_name', 'ldap_dn', 'ldap_dn_hash')
|
||||
->from($table)
|
||||
->where($qb->expr()->isNull('ldap_dn_hash'));
|
||||
$qb->select('owncloud_name', 'ldap_dn')
|
||||
->from($table);
|
||||
|
||||
// when added we may run into risk that it's read from a DB node
|
||||
// where the column is not present. Then the where clause is also
|
||||
// not necessary since all rows qualify.
|
||||
if (!in_array($table, $this->hashColumnAddedToTables, true)) {
|
||||
$qb->where($qb->expr()->isNull('ldap_dn_hash'));
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue