Changeset 10128 for trunk


Ignore:
Timestamp:
Apr 7, 2011, 11:11:11 AM (13 years ago)
Author:
patdenice
Message:

feature:2250
Add expire parameter.
Clean code.

Location:
trunk
Files:
3 edited

Legend:

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

    r10098 r10128  
    372372  }
    373373
    374   function get_incompatible_plugins()
    375   {
    376     if (isset($_SESSION['incompatible_plugins']))
     374  function get_incompatible_plugins($actualize=false)
     375  {
     376    if (isset($_SESSION['incompatible_plugins']) and !$actualize
     377      and $_SESSION['incompatible_plugins']['~~expire~~'] > time())
    377378    {
    378379      return $_SESSION['incompatible_plugins'];
    379380    }
    380381
    381     $_SESSION['incompatible_plugins'] = array();
     382    $_SESSION['incompatible_plugins'] = array('~~expire~~' => time() + 300);
    382383
    383384    $versions_to_check = $this->get_versions_to_check();
     
    559560  function get_merged_extensions($version=PHPWG_VERSION)
    560561  {
    561     if (!isset($_SESSION['merged_extensions']))
    562     {
    563       $_SESSION['merged_extensions'] = array();
    564       if (fetchRemote(MERGED_EXTENSIONS_URL, $result))
    565       {
    566         $rows = explode("\n", $result);
    567         foreach ($rows as $row)
    568         {
    569           if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
    570           {
    571             if (version_compare($version, $match[1], '>='))
    572             {
    573               $extensions = explode(',', trim($match[2]));
    574               $_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions);
    575             }
    576           }
    577         }
    578       }
    579     }
     562    if (isset($_SESSION['merged_extensions']) and $_SESSION['merged_extensions']['~~expire~~'] > time())
     563    {
     564      return $_SESSION['merged_extensions'];
     565    }
     566
     567    $_SESSION['merged_extensions'] = array('~~expire~~' => time() + 600);
     568
     569    if (fetchRemote(PHPWG_URL.'/download/merged_extensions.txt', $result))
     570    {
     571      $rows = explode("\n", $result);
     572      foreach ($rows as $row)
     573      {
     574        if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
     575        {
     576          if (version_compare($version, $match[1], '>='))
     577          {
     578            $extensions = explode(',', trim($match[2]));
     579            $_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions);
     580          }
     581        }
     582      }
     583    }
     584
    580585    return $_SESSION['merged_extensions'];
    581586  }
  • trunk/admin/plugins_list.php

    r10101 r10128  
    7878  {
    7979    // Incompatible plugins must be reinitilized
    80     unset($_SESSION['incompatible_plugins']);
    81     $plugins->get_incompatible_plugins();
     80    $plugins->get_incompatible_plugins(true);
    8281  }
    8382
  • trunk/include/common.inc.php

    r10098 r10128  
    157157  define('PEM_URL', 'http://'.PHPWG_DOMAIN.'/ext');
    158158}
    159 define('MERGED_EXTENSIONS_URL', 'http://'.PHPWG_DOMAIN.'/download/merged_extensions.txt');
    160 
    161159
    162160// language files
Note: See TracChangeset for help on using the changeset viewer.