Changeset 15680


Ignore:
Timestamp:
06/14/12 23:46:47 (7 years ago)
Author:
plg
Message:

feature 2632: add a test on upgrade.php, if a remote site is detected downgrade to 2.3.4

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/updates.class.php

    r13467 r15680  
    360360  } 
    361361 
    362   function upgrade_to($upgrade_to, &$step) 
     362  function upgrade_to($upgrade_to, &$step, $check_current_version=true) 
    363363  { 
    364364    global $page, $conf, $template; 
    365365 
    366     if (!version_compare($_POST['upgrade_to'], PHPWG_VERSION, '>')) 
     366    if ($check_current_version and !version_compare($upgrade_to, PHPWG_VERSION, '>')) 
    367367    { 
    368368      redirect(get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))); 
     
    372372    { 
    373373      preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches); 
    374       $code =  $matches[1].'.x_to_'.$_POST['upgrade_to']; 
     374      $code =  $matches[1].'.x_to_'.$upgrade_to; 
    375375      $dl_code = str_replace(array('.', '_'), '', $code); 
    376376      $remove_path = $code; 
     
    379379    else 
    380380    { 
    381       $code = $_POST['upgrade_to']; 
     381      $code = $upgrade_to; 
    382382      $dl_code = $code; 
    383383      $remove_path = version_compare($code, '2.0.8', '>=') ? 'piwigo' : 'piwigo-'.$code; 
  • trunk/upgrade.php

    r15679 r15680  
    229229  ) 
    230230); 
     231 
     232// +-----------------------------------------------------------------------+ 
     233// | Remote sites are not compatible with Piwigo 2.4+                      | 
     234// +-----------------------------------------------------------------------+ 
     235 
     236$has_remote_site = false; 
     237 
     238$query = 'SELECT galleries_url FROM '.SITES_TABLE.';'; 
     239$result = pwg_query($query); 
     240while ($row = pwg_db_fetch_assoc($result)) 
     241{ 
     242  if (url_is_remote($row['galleries_url'])) 
     243  { 
     244    $has_remote_site = true; 
     245  } 
     246} 
     247 
     248if ($has_remote_site) 
     249{ 
     250  include_once(PHPWG_ROOT_PATH.'admin/include/updates.class.php'); 
     251  include_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 
     252 
     253  $page['errors'] = array(); 
     254  $step = 3; 
     255  updates::upgrade_to('2.3.4', $step, false); 
     256 
     257  if (!empty($page['errors'])) 
     258  { 
     259    echo '<ul>'; 
     260    foreach ($page['errors'] as $error) 
     261    { 
     262      echo '<li>'.$error.'</li>'; 
     263    } 
     264    echo '</ul>'; 
     265  } 
     266 
     267  exit(); 
     268} 
    231269 
    232270// +-----------------------------------------------------------------------+ 
Note: See TracChangeset for help on using the changeset viewer.