Skip to content
Snippets Groups Projects
Commit d4b25149 authored by Laurent's avatar Laurent
Browse files

Merge branch 'origin-stable' into hotline-master

parents 67b19a1b 4c646c2c
Branches
Tags
No related merge requests found
......@@ -18,7 +18,6 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once('cosmogramme/php/classes/classe_notice_integration.php');
class Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integration_PhaseAbstract {
const MY_ID=7.5;
......@@ -49,21 +48,20 @@ class Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integ
return $this;
}
public function _execute() {
public function _execute() {
$page = 1;
while ($records = Class_AvisNotice::findAllBy(['order' => 'id',
'limitPage' => [$page, 500]])) {
if ($this->_log && (0 == ($this->_getData('nombre') % 100)))
$this->_log->ecrire('<span class="vert"> ' . $this->_getData('nombre') . ' records updated </span>');
$this->_log->ecrire('<span class="vert"> ' . $this->_getData('nombre') . ' avis mis à jour </span>');
$this->runUpdateForRecords($records);
$this->_resetDbConnection();
$page++;
}
if ($this->_log) {
......@@ -80,6 +78,8 @@ class Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integ
}
}
protected function runUpdateForRecords($records) {
foreach ($records as $record) {
if ($this->isTimeOut())
......
......@@ -23,7 +23,9 @@
class Class_Migration_Patchs {
use Trait_StaticFileSystem;
public $force = false;
public
$_last_patch_number,
$force = false;
public function extensionForFile($file) {
......@@ -42,7 +44,16 @@ class Class_Migration_Patchs {
}
public function setLastPatchNumber($number) {
$this->_last_patch_number = $number;
return $this;
}
public function getLastPatchNumber() {
if (isset($this->_last_patch_number))
return $this->_last_patch_number;
$ids=[];
foreach (self::getFileSystem()->glob(PATCH_PATH."patch_*") as $filename) {
$ids[]=$this->versionForFile($filename);
......@@ -50,14 +61,15 @@ class Class_Migration_Patchs {
if (empty($ids))
return 0;
rsort($ids);
return $ids[0];
return $this->_last_patch_number = (int)$ids[0];
}
public function getMatchingPatchFiles($patch_level) {
$to_patch_level = $this->getLastPatchNumber();
return $this->getPatchesFilteredBy(
function($version) use ($patch_level) {
return $version > (int)$patch_level;
function($version) use ($patch_level, $to_patch_level) {
return ($version > (int)$patch_level) && ($version <= $to_patch_level);
});
}
......@@ -80,7 +92,7 @@ class Class_Migration_Patchs {
$basePath = dirname(realpath(__FILE__));
$patch_level = Class_CosmoVar::find("patch_level");
$visitor->visitHeader($patch_level,$this->getLastPatchNumber());
$visitor->visitHeader($patch_level, $this->getLastPatchNumber());
$ok = true;
foreach($this->getMatchingPatchFiles($patch_level->getValeur()) as $script) {
......
......@@ -33,6 +33,12 @@ class Class_Migration_ScriptPatchs {
}
public function runTo($patch_level) {
$this->migration = (new Class_Migration_Patchs());
$this->migration->setLastPatchNumber($patch_level)->acceptVisitor($this);
}
public function visitPhpError($exception) {
$this->echoError("Code : ".$exception->getCode()."\n");
$this->echoError("Erreur :".$exception->getMessage());
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
abstract class UpgradeDBTestCase extends PHPUnit_Framework_TestCase {
const BACK_PATCH_LEVEL = 262;
protected static $_upgrade_done=false;
abstract public function prepare();
public function setUp() {
if (!self::$_upgrade_done) {
$this->_movePatchLevelTo(self::BACK_PATCH_LEVEL);
$this->_runAllPrepares();
self::$_upgrade_done = true;
}
(new Class_Migration_ScriptPatchs())->runTo($this->_getPatchLevel());
}
public function query($query) {
return Zend_Db_Table::getDefaultAdapter()->query($query);
}
public function _movePatchLevelTo($patch_level) {
$this->query('update variables set valeur=' . $patch_level . ' where clef="patch_level"');
$this->query('delete from patch_hash');
}
public function _runAllPrepares() {
foreach($this->_getSubclasses() as $subclass) {
(new $subclass())->prepare();
}
}
protected function _getPatchLevel() {
preg_match('/UpgradeDB_([0-9]+)_Test/',
get_class($this),
$matches);
return $matches[1];
}
protected function _getSubclasses() {
$result = array();
foreach (get_declared_classes() as $class) {
if (is_subclass_of($class, __CLASS__))
$result[] = $class;
}
return $result;
}
}
class UpgradeDB_263_Test extends UpgradeDBTestCase {
public function prepare() {
$this->query('delete from permission where code="CATEGORY"');
}
/** @test */
public function permissionCATEGORYShouldBeCreated() {
$data = $this->query('select * from permission where code="category" limit 1;')->fetch();
$this->assertArraySubset(['code' => 'CATEGORY',
'module' => 'ARTICLE',
'type' => 'Droits',
'sorting' => 1,
'description' => 'Créer des sous-catégories et des articles'],
$data);
}
}
class UpgradeDB_267_Test extends UpgradeDBTestCase {
public function prepare() {
$this->query('delete from bib_admin_var where clef="CNIL_CONSENT_ENABLE"');
}
/** @test */
public function varCNIL_CONSENT_ENABLE_ShouldEqualsOne() {
$data = $this->query('select valeur from bib_admin_var where clef="CNIL_CONSENT_ENABLE"')->fetch();
$this->assertEquals('1',
$data['valeur']);
}
}
?>
\ No newline at end of file
......@@ -7,6 +7,9 @@
stopOnError="false"
>
<testsuites>
<testsuite name="DBTestSuite">
<directory>./db/</directory>
</testsuite>
<testsuite name="ApplicationTestSuite">
<directory>./application/</directory>
<directory>./library/</directory>
......
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