From 23a4e61de86157c0314b6477fff49647b5db4988 Mon Sep 17 00:00:00 2001 From: pbarroca <pbarroca@afi-sa.fr> Date: Wed, 2 Sep 2015 12:03:46 +0200 Subject: [PATCH] rel #21694 : PseudoRecords phase memory clean --- cosmogramme/php/_init.php | 2 +- cosmogramme/sql/patch/patch_265.php | 4 +++ library/Class/Autocomplete/Index.php | 9 ++++--- library/Class/Cosmogramme/Chronometre.php | 2 +- .../Integration/PhasePseudoRecord.php | 27 ++++++++++++++----- 5 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 cosmogramme/sql/patch/patch_265.php diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 633bd0493dc..6ab78cb83b0 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -1,7 +1,7 @@ <?php error_reporting(E_ERROR | E_PARSE); -define("PATCH_LEVEL","264"); +define("PATCH_LEVEL","265"); define("APPLI","cosmogramme"); define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs"); diff --git a/cosmogramme/sql/patch/patch_265.php b/cosmogramme/sql/patch/patch_265.php new file mode 100644 index 00000000000..f12163ced40 --- /dev/null +++ b/cosmogramme/sql/patch/patch_265.php @@ -0,0 +1,4 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); +$adapter->query('ALTER TABLE `album` MODIFY `notice_id` int(11) null default null'); +$adapter->query('UPDATE `album` SET `notice_id`=null WHERE `notice_id`=0'); \ No newline at end of file diff --git a/library/Class/Autocomplete/Index.php b/library/Class/Autocomplete/Index.php index 37c06bf7551..4a5e86c0510 100644 --- a/library/Class/Autocomplete/Index.php +++ b/library/Class/Autocomplete/Index.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -36,17 +36,17 @@ class Class_Autocomplete_Index { return $this->getBasePath() . $this->file_name; } - + public static function getClassFor($name) { foreach (['Title' => new Class_Autocomplete_IndexTitle(), - 'Author' => new Class_Autocomplete_IndexAuthor()] + 'Author' => new Class_Autocomplete_IndexAuthor()] as $k => $clazz) { if ((false !== strpos($name, $k))) return $clazz; } return new Class_Autocomplete_IndexNull(); } - + public static function getMethodFor($name) { if ('search' == substr($name, 0, 6)) @@ -85,6 +85,7 @@ class Class_Autocomplete_Index { $current = $response->done; Class_Notice::clearCache(); + Class_CodifAuteur::clearCache(); Storm_Model_Loader::resetCache(); gc_collect_cycles(); } while($response->done < $response->total); diff --git a/library/Class/Cosmogramme/Chronometre.php b/library/Class/Cosmogramme/Chronometre.php index e7c08c6ecdd..99c579fa4f3 100644 --- a/library/Class/Cosmogramme/Chronometre.php +++ b/library/Class/Cosmogramme/Chronometre.php @@ -92,7 +92,7 @@ class Class_Cosmogramme_Chronometre { $elapsed = 1; $mean = $total / ($elapsed / 60); - return number_format($mean, 0, ',', '.') + return number_format($mean, 0, ',', ' ') . ' ' . $label . ' par minute'; } } diff --git a/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php b/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php index c305c39f48d..a75d4ddb731 100644 --- a/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php +++ b/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php @@ -23,22 +23,27 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord extends Class_Cosmogramme_Integration_PhaseAbstract { + protected $_model_id_field; + /** @var Trait_Indexable */ protected $_model_name; protected function _getModelIdField() { - return call_user_func([$this->_model_name, 'getIdField']); + if (!$this->_model_id_field) + $this->_model_id_field = call_user_func([$this->_model_name, 'getIdField']); + + return $this->_model_id_field; } protected function _loadPage() { + $this->_cleanMemory(); $id_field = $this->_getModelIdField(); - return call_user_func_array([$this->_model_name, 'findAllBy'], - [['where' => $id_field . ' > ' . $this->_getData('pointeur_reprise'), - 'order' => $id_field, - 'limit' => 100 - ]]); + return call_user_func([$this->_model_name, 'findAllBy'], + ['where' => $id_field . ' > ' . $this->_getData('pointeur_reprise'), + 'order' => $id_field, + 'limit' => 100]); } @@ -55,6 +60,7 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord protected function _runPage($models) { + $this->_log->ecrire($this->_getData('nombre') . '<br>'); foreach($models as $model) { if ($this->isTimeOut()) return; @@ -85,7 +91,7 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord return; } - $this->_incrementCount(Class_Cosmogramme_Integration_Phase::RECORD_UPDATE); + $this->_incrementCount(Class_Cosmogramme_Integration_Phase::RECORD_FULLUPDATE); } @@ -124,4 +130,11 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord ->startOnFile() ->startOnRecords(); } + + + protected function _cleanMemory() { + Storm_Model_Abstract::unsetLoaders(); + Storm_Model_Loader::resetCache(); + gc_collect_cycles(); + } } \ No newline at end of file -- GitLab