Skip to content
Snippets Groups Projects
Commit 9a077034 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#88956_problemes_affichage_realisateur_arte_vod' into 'hotline'

hotline 88956 : fix memory limit

See merge request !3127
parents 86c41e74 68d7f1b7
Branches
Tags
4 merge requests!3297WIP: Master,!3131Master,!3128Hotline,!3127hotline 88956 : fix memory limit
Pipeline #7012 passed with stage
in 36 minutes and 19 seconds
- ticket #88956 : Arte VOD : Amélioration du script de mise à jour des auteurs
\ No newline at end of file
......@@ -21,6 +21,33 @@
class Class_Migration_ArteVODAuthorsOrder {
use Trait_MemoryCleaner;
public function updateAuthorsForAllAlbums($closure=null) {
try {
$page = 0;
while($albums = Class_Album::findAllBy(['type_doc_id' => Class_TypeDoc::ARTEVOD,
'order' => 'id',
'limitPage' => [$page, 500]])) {
$this->_runPage($albums, $closure);
$this->_cleanMemory();
$page++;
}
} catch(Exception $e) {
return;
}
}
protected function _runPage($albums, $closure) {
foreach($albums as $album) {
$this->updateAuthors($album);
if ($closure)
$closure($album);
}
}
public function updateAuthors($album) {
$old_authors = new Storm_Collection($album->getAuthors());
$album->getMarc()->clearZone('701');
......@@ -36,15 +63,6 @@ class Class_Migration_ArteVODAuthorsOrder {
}
public function updateAuthorsForAllAlbums($closure=null) {
foreach(Class_Album::findAllBy(['type_doc_id' => Class_TypeDoc::ARTEVOD]) as $album) {
$this->updateAuthors($album);
if ($closure)
$closure($album);
}
}
protected function addAuthorsTo($authors, $closure, $album) {
$authors->select($closure)
->eachDo(function ($author) use ($album)
......
......@@ -54,7 +54,10 @@ class ArteVodLinkUpdateAuthorTest extends ModelTestCase {
->setExternalUri("http://artevod/comme-elle-respire")
->beValidated()
->save();
(new Class_Migration_ArteVODAuthorsOrder())->updateAuthorsForAllAlbums();
(new Class_Migration_ArteVODAuthorsOrder())
->setMemoryCleaner(function() {})
->updateAuthorsForAllAlbums();
}
......
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