aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-04-07 09:11:11 +0000
committerpatdenice <patdenice@piwigo.org>2011-04-07 09:11:11 +0000
commit49dd77f05b78b3a82ec12c6c7fbf3a5972c784ce (patch)
tree624868ea29670b7674048ed989abe982f2deb2a8
parentce1c5b862dacf1f73e4f3840b6b5fd181f401bbe (diff)
feature:2250
Add expire parameter. Clean code. git-svn-id: http://piwigo.org/svn/trunk@10128 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/include/plugins.class.php33
-rw-r--r--admin/plugins_list.php3
-rw-r--r--include/common.inc.php2
3 files changed, 20 insertions, 18 deletions
diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php
index 7ae27a00f..4cb1370fb 100644
--- a/admin/include/plugins.class.php
+++ b/admin/include/plugins.class.php
@@ -371,14 +371,15 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
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))
@@ -558,25 +559,29 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
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'];
}
diff --git a/admin/plugins_list.php b/admin/plugins_list.php
index 18a9c06d3..1af2e239b 100644
--- a/admin/plugins_list.php
+++ b/admin/plugins_list.php
@@ -77,8 +77,7 @@ foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
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(
diff --git a/include/common.inc.php b/include/common.inc.php
index fe4a2c152..048290e19 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -156,8 +156,6 @@ else
{
define('PEM_URL', 'http://'.PHPWG_DOMAIN.'/ext');
}
-define('MERGED_EXTENSIONS_URL', 'http://'.PHPWG_DOMAIN.'/download/merged_extensions.txt');
-
// language files
load_language('common.lang');