Changeset 1027


Ignore:
Timestamp:
Feb 6, 2006, 10:52:16 PM (18 years ago)
Author:
plg
Message:

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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/common.inc.php

    r960 r1027  
    135135if ($conf['check_upgrade_feed'])
    136136{
    137   define('PREFIX_TABLE', $prefixeTable);
    138   define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
    139  
    140137  // retrieve already applied upgrades
    141138  $query = '
    142139SELECT id
    143   FROM '.PREFIX_TABLE.'upgrade
     140  FROM '.UPGRADE_TABLE.'
    144141;';
    145142  $applied = array_from_query($query, 'id');
    146143
    147144  // retrieve existing upgrades
    148   $existing = array();
    149 
    150   if ($contents = opendir(UPGRADES_PATH))
    151   {
    152     while (($node = readdir($contents)) !== false)
    153     {
    154       if (is_file(UPGRADES_PATH.'/'.$node)
    155           and preg_match('/^(.*?)-database\.php$/', $node, $match))
    156       {
    157         array_push($existing, $match[1]);
    158       }
    159     }
    160   }
    161   natcasesort($existing);
     145  $existing = get_available_upgrade_ids();
    162146
    163147  // which upgrades need to be applied?
  • trunk/include/functions.inc.php

    r1021 r1027  
    489489function redirect( $url )
    490490{
    491   global $user, $template, $lang_info, $conf, $lang, $t2, $page;
     491  global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug;
    492492
    493493  // $refresh, $url_link and $title are required for creating an automated
     
    973973  return $email;
    974974}
     975
     976/**
     977 * which upgrades are available ?
     978 *
     979 * @return array
     980 */
     981function get_available_upgrade_ids()
     982{
     983  $upgrades_path = PHPWG_ROOT_PATH.'install/db';
     984
     985  $available_upgrade_ids = array();
     986 
     987  if ($contents = opendir($upgrades_path))
     988  {
     989    while (($node = readdir($contents)) !== false)
     990    {
     991      if (is_file($upgrades_path.'/'.$node)
     992          and preg_match('/^(.*?)-database\.php$/', $node, $match))
     993      {
     994        array_push($available_upgrade_ids, $match[1]);
     995      }
     996    }
     997  }
     998  natcasesort($available_upgrade_ids);
     999
     1000  return $available_upgrade_ids;
     1001}
    9751002?>
  • trunk/install.php

    r860 r1027  
    339339;';
    340340    mysql_query($query);
     341
     342    // Available upgrades must be ignored after a fresh installation. To
     343    // make PWG avoid upgrading, we must tell it upgrades have already been
     344    // made.
     345    foreach (get_available_upgrade_ids() as $upgrade_id)
     346    {
     347      $query = '
     348INSERT INTO '.UPGRADE_TABLE.'
     349  (id, applied, description)
     350  VALUES
     351  ('.$upgrade_id.', NOW(), \'upgrade included in installation\')
     352';
     353      mysql_query($query);
     354    }
    341355  }
    342356}
  • trunk/upgrade_feed.php

    r953 r1027  
    5757
    5858// retrieve existing upgrades
    59 $existing = array();
    60 
    61 if ($contents = opendir(UPGRADES_PATH))
    62 {
    63   while (($node = readdir($contents)) !== false)
    64   {
    65     if (is_file(UPGRADES_PATH.'/'.$node)
    66         and preg_match('/^(.*?)-database\.php$/', $node, $match))
    67     {
    68       array_push($existing, $match[1]);
    69     }
    70   }
    71 }
    72 natcasesort($existing);
     59$existing = get_available_upgrade_ids();
    7360
    7461// which upgrades need to be applied?
Note: See TracChangeset for help on using the changeset viewer.