aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/common.inc.php20
-rw-r--r--include/functions.inc.php29
-rw-r--r--install.php14
-rw-r--r--upgrade_feed.php15
4 files changed, 45 insertions, 33 deletions
diff --git a/include/common.inc.php b/include/common.inc.php
index 3b6900000..6e8bbf697 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -134,31 +134,15 @@ or die ( "Could not connect to database" );
if ($conf['check_upgrade_feed'])
{
- define('PREFIX_TABLE', $prefixeTable);
- define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
-
// retrieve already applied upgrades
$query = '
SELECT id
- FROM '.PREFIX_TABLE.'upgrade
+ FROM '.UPGRADE_TABLE.'
;';
$applied = array_from_query($query, 'id');
// retrieve existing upgrades
- $existing = array();
-
- if ($contents = opendir(UPGRADES_PATH))
- {
- while (($node = readdir($contents)) !== false)
- {
- if (is_file(UPGRADES_PATH.'/'.$node)
- and preg_match('/^(.*?)-database\.php$/', $node, $match))
- {
- array_push($existing, $match[1]);
- }
- }
- }
- natcasesort($existing);
+ $existing = get_available_upgrade_ids();
// which upgrades need to be applied?
if (count(array_diff($existing, $applied)) > 0)
diff --git a/include/functions.inc.php b/include/functions.inc.php
index cf865d6c8..d49317d22 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -488,7 +488,7 @@ function pwg_debug( $string )
*/
function redirect( $url )
{
- global $user, $template, $lang_info, $conf, $lang, $t2, $page;
+ global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug;
// $refresh, $url_link and $title are required for creating an automated
// refresh page in header.tpl
@@ -972,4 +972,31 @@ SELECT '.$conf['user_fields']['email'].'
return $email;
}
+
+/**
+ * which upgrades are available ?
+ *
+ * @return array
+ */
+function get_available_upgrade_ids()
+{
+ $upgrades_path = PHPWG_ROOT_PATH.'install/db';
+
+ $available_upgrade_ids = array();
+
+ if ($contents = opendir($upgrades_path))
+ {
+ while (($node = readdir($contents)) !== false)
+ {
+ if (is_file($upgrades_path.'/'.$node)
+ and preg_match('/^(.*?)-database\.php$/', $node, $match))
+ {
+ array_push($available_upgrade_ids, $match[1]);
+ }
+ }
+ }
+ natcasesort($available_upgrade_ids);
+
+ return $available_upgrade_ids;
+}
?>
diff --git a/install.php b/install.php
index e2c2f5eca..68b98547d 100644
--- a/install.php
+++ b/install.php
@@ -338,6 +338,20 @@ INSERT INTO '.USER_INFOS_TABLE.'
(2, \'guest\', \''.$language.'\')
;';
mysql_query($query);
+
+ // Available upgrades must be ignored after a fresh installation. To
+ // make PWG avoid upgrading, we must tell it upgrades have already been
+ // made.
+ foreach (get_available_upgrade_ids() as $upgrade_id)
+ {
+ $query = '
+INSERT INTO '.UPGRADE_TABLE.'
+ (id, applied, description)
+ VALUES
+ ('.$upgrade_id.', NOW(), \'upgrade included in installation\')
+';
+ mysql_query($query);
+ }
}
}
diff --git a/upgrade_feed.php b/upgrade_feed.php
index c26390a0d..ca9f9d0c3 100644
--- a/upgrade_feed.php
+++ b/upgrade_feed.php
@@ -56,20 +56,7 @@ SELECT id
$applied = array_from_query($query, 'id');
// retrieve existing upgrades
-$existing = array();
-
-if ($contents = opendir(UPGRADES_PATH))
-{
- while (($node = readdir($contents)) !== false)
- {
- if (is_file(UPGRADES_PATH.'/'.$node)
- and preg_match('/^(.*?)-database\.php$/', $node, $match))
- {
- array_push($existing, $match[1]);
- }
- }
-}
-natcasesort($existing);
+$existing = get_available_upgrade_ids();
// which upgrades need to be applied?
$to_apply = array_diff($existing, $applied);