diff options
author | plegall <plg@piwigo.org> | 2006-02-06 21:52:16 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2006-02-06 21:52:16 +0000 |
commit | 3d0c5236e1848cefbf672df7243ff34b855f7000 (patch) | |
tree | d0edd78acc26eb79fb1329a4653fe97c7e2fb73d /include | |
parent | 701350ff0519dcf64d43ea63d122574c1dba10e4 (diff) |
improvement: upgrades id retrieving in include/common.inc.php and
upgrade_feed.php are now made by dedicated function
get_available_upgrade_ids.
bug fixed: after an installation, you had to play all available upgrades,
which was wrong. install.php inserts informations related to all available
upgrades at installation time. Thus avoiding automatic upgrades.
git-svn-id: http://piwigo.org/svn/trunk@1027 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/common.inc.php | 20 | ||||
-rw-r--r-- | include/functions.inc.php | 29 |
2 files changed, 30 insertions, 19 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; +} ?> |