Commit a3a86f11 authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#71738_check_sql_patch' into 'master'

dev #71738 : guard memory comsuption of patch 337

See merge request afi/opacce!2511
parents afe8b4d6 8fae188f
- ticket #71738 : Système : Amélioration des performances du patch SQL 337
\ No newline at end of file
......@@ -20,26 +20,35 @@
*/
class Class_Migration_AlbumEditorToNotes {
use Trait_MemoryCleaner;
public function run() {
try {
$albums = Class_Album::findAllBy(['where' => 'editeur is not null and editeur != ""']);
while($albums = Class_Album::findAllBy(['where' => 'editeur is not null and editeur != ""',
'limit' => 1000]))
$this->_migratePage($albums);
} catch (Exception $e) {
return;
}
}
foreach($albums as $album) {
protected function _migratePage($albums) {
foreach($albums as $album)
$this->_migrateEditor($album);
}
$this->_cleanMemory();
}
protected function _migrateEditor($album) {
$editors = $album->getEditors();
if (in_array($album->getEditeur(), $editors))
return;
if (!in_array($album->getEditeur(), $editors))
$album->addEditor($album->getEditeur());
$album
->addEditor($album->getEditeur())
->setEditeur(null)
->save();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment