|
From: <gem...@li...> - 2011-11-04 12:47:07
|
Revision: 183
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=183&view=rev
Author: mennodekker
Date: 2011-11-04 12:47:01 +0000 (Fri, 04 Nov 2011)
Log Message:
-----------
Minor refactoring to be able to execute patches from the upgrader that is being built
Modified Paths:
--------------
trunk/library/classes/Gems/Default/DatabaseAction.php
trunk/library/classes/Gems/Util/DatabasePatcher.php
Modified: trunk/library/classes/Gems/Default/DatabaseAction.php
===================================================================
--- trunk/library/classes/Gems/Default/DatabaseAction.php 2011-11-04 11:39:43 UTC (rev 182)
+++ trunk/library/classes/Gems/Default/DatabaseAction.php 2011-11-04 12:47:01 UTC (rev 183)
@@ -351,8 +351,6 @@
$data['db_level'] = $data['level'];
$form->getElement('db_level')->setValue($data['db_level']);
- $this->db->query('INSERT IGNORE INTO gems__patch_levels (gpl_level, gpl_created) VALUES (?, CURRENT_TIMESTAMP)', $data['level']);
-
$this->addMessage(sprintf($this->_('%d patch(es) executed.'), $changed));
}
Modified: trunk/library/classes/Gems/Util/DatabasePatcher.php
===================================================================
--- trunk/library/classes/Gems/Util/DatabasePatcher.php 2011-11-04 11:39:43 UTC (rev 182)
+++ trunk/library/classes/Gems/Util/DatabasePatcher.php 2011-11-04 12:47:01 UTC (rev 183)
@@ -130,14 +130,22 @@
'gpa_sql' => $statement
);
}
- }
+ }
}
}
}
}
- public function executePatch($patch, $ignoreCompleted = true, $ignoreExecuted = false)
+ /**
+ * Executes db patches for the given $patchLevel
+ *
+ * @param int $patchLevel Only execute patches for this patchlevel
+ * @param boolean $ignoreCompleted Set to yes to skip patches that where already completed
+ * @param boolean $ignoreExecuted Set to yes to skip patches that where already executed (this includes the ones that are executed but not completed)
+ * @return int The number of executed patches
+ */
+ public function executePatch($patchLevel, $ignoreCompleted = true, $ignoreExecuted = false)
{
$sql = 'SELECT gpa_id_patch, gpa_sql, gpa_completed FROM gems__patches WHERE gpa_level = ?';
if ($ignoreCompleted) {
@@ -151,7 +159,7 @@
$current = new Zend_Db_Expr('CURRENT_TIMESTAMP');
$executed = 0;
- $patches = $this->db->fetchAll($sql, $patch);
+ $patches = $this->db->fetchAll($sql, $patchLevel);
foreach ($patches as $patch) {
$data = array();
@@ -176,6 +184,11 @@
$executed++;
}
+ //Update the patchlevel only when we have executed at least one patch
+ if ($executed>0) {
+ $this->db->query('INSERT IGNORE INTO gems__patch_levels (gpl_level, gpl_created) VALUES (?, CURRENT_TIMESTAMP)', $patchLevel);
+ }
+
return $executed;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|