Skip to content

Commit

Permalink
feature:2250
Browse files Browse the repository at this point in the history
Add expire parameter.
Clean code.

git-svn-id: http://piwigo.org/svn/trunk@10128 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed Apr 7, 2011
1 parent ce1c5b8 commit 49dd77f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
33 changes: 19 additions & 14 deletions admin/include/plugins.class.php
Expand Up @@ -371,14 +371,15 @@ function get_server_plugins($new=false)
return false;
}

function get_incompatible_plugins()
function get_incompatible_plugins($actualize=false)
{
if (isset($_SESSION['incompatible_plugins']))
if (isset($_SESSION['incompatible_plugins']) and !$actualize
and $_SESSION['incompatible_plugins']['~~expire~~'] > time())
{
return $_SESSION['incompatible_plugins'];
}

$_SESSION['incompatible_plugins'] = array();
$_SESSION['incompatible_plugins'] = array('~~expire~~' => time() + 300);

$versions_to_check = $this->get_versions_to_check();
if (empty($versions_to_check))
Expand Down Expand Up @@ -558,25 +559,29 @@ function extract_plugin_files($action, $revision, $dest)

function get_merged_extensions($version=PHPWG_VERSION)
{
if (!isset($_SESSION['merged_extensions']))
if (isset($_SESSION['merged_extensions']) and $_SESSION['merged_extensions']['~~expire~~'] > time())
{
$_SESSION['merged_extensions'] = array();
if (fetchRemote(MERGED_EXTENSIONS_URL, $result))
return $_SESSION['merged_extensions'];
}

$_SESSION['merged_extensions'] = array('~~expire~~' => time() + 600);

if (fetchRemote(PHPWG_URL.'/download/merged_extensions.txt', $result))
{
$rows = explode("\n", $result);
foreach ($rows as $row)
{
$rows = explode("\n", $result);
foreach ($rows as $row)
if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
{
if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
if (version_compare($version, $match[1], '>='))
{
if (version_compare($version, $match[1], '>='))
{
$extensions = explode(',', trim($match[2]));
$_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions);
}
$extensions = explode(',', trim($match[2]));
$_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions);
}
}
}
}

return $_SESSION['merged_extensions'];
}

Expand Down
3 changes: 1 addition & 2 deletions admin/plugins_list.php
Expand Up @@ -77,8 +77,7 @@
and $fs_plugin['version'] != $_SESSION['incompatible_plugins'][$plugin_id])
{
// Incompatible plugins must be reinitilized
unset($_SESSION['incompatible_plugins']);
$plugins->get_incompatible_plugins();
$plugins->get_incompatible_plugins(true);
}

$tpl_plugin = array(
Expand Down
2 changes: 0 additions & 2 deletions include/common.inc.php
Expand Up @@ -156,8 +156,6 @@ function sanitize_mysql_kv(&$v, $k)
{
define('PEM_URL', 'http://'.PHPWG_DOMAIN.'/ext');
}
define('MERGED_EXTENSIONS_URL', 'http://'.PHPWG_DOMAIN.'/download/merged_extensions.txt');


// language files
load_language('common.lang');
Expand Down

0 comments on commit 49dd77f

Please sign in to comment.