aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/extension
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-11-18 18:15:39 +0100
committerNils Adermann <naderman@naderman.de>2011-11-18 18:24:18 +0100
commit5068c0588733f80a8433aea1cd6f763819caa9f7 (patch)
treece2c10c6473270b8c6510ee56d72e1942db9b67d /phpBB/includes/extension
parent21117c69f313929d23592e3e705de3e4974afaa0 (diff)
downloadforums-5068c0588733f80a8433aea1cd6f763819caa9f7.tar
forums-5068c0588733f80a8433aea1cd6f763819caa9f7.tar.gz
forums-5068c0588733f80a8433aea1cd6f763819caa9f7.tar.bz2
forums-5068c0588733f80a8433aea1cd6f763819caa9f7.tar.xz
forums-5068c0588733f80a8433aea1cd6f763819caa9f7.zip
[feature/extension-manager] Split disabling extensions up into steps as well
PHPBB3-10323
Diffstat (limited to 'phpBB/includes/extension')
-rw-r--r--phpBB/includes/extension/base.php10
-rw-r--r--phpBB/includes/extension/interface.php7
-rw-r--r--phpBB/includes/extension/manager.php46
3 files changed, 52 insertions, 11 deletions
diff --git a/phpBB/includes/extension/base.php b/phpBB/includes/extension/base.php
index fed120c51b..d9159d57d2 100644
--- a/phpBB/includes/extension/base.php
+++ b/phpBB/includes/extension/base.php
@@ -25,6 +25,7 @@ class phpbb_extension_base implements phpbb_extension_interface
/**
* Single enable step that does nothing
*
+ * @param mixed $old_state State returned by previous call of this method
* @return false Indicates no further steps are required
*/
public function enable_step($old_state)
@@ -33,17 +34,20 @@ class phpbb_extension_base implements phpbb_extension_interface
}
/**
- * Empty disable method
+ * Single disable step that does nothing
*
- * @return null
+ * @param mixed $old_state State returned by previous call of this method
+ * @return false Indicates no further steps are required
*/
- public function disable()
+ public function disable_step($old_state)
{
+ return false;
}
/**
* Single purge step that does nothing
*
+ * @param mixed $old_state State returned by previous call of this method
* @return false Indicates no further steps are required
*/
public function purge_step($old_state)
diff --git a/phpBB/includes/extension/interface.php b/phpBB/includes/extension/interface.php
index 7d0ecd72c7..b37cd24d77 100644
--- a/phpBB/includes/extension/interface.php
+++ b/phpBB/includes/extension/interface.php
@@ -40,11 +40,14 @@ interface phpbb_extension_interface
/**
* Disables the extension.
*
- * Must be a quick operation, that finishes within max_execution_time.
+ * Calls to this function can be made in subsequent requests, when the
+ * function is invoked through a webserver with a too low max_execution_time.
*
+ * @param mixed $old_state The return value of the previous call
+ * of this method, or false on the first call
* @return null
*/
- public function disable();
+ public function disable_step($old_state);
/**
* purge_step is executed on purging an extension until it returns false.
diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php
index 29cd89fb34..bcdd21f7f1 100644
--- a/phpBB/includes/extension/manager.php
+++ b/phpBB/includes/extension/manager.php
@@ -128,7 +128,7 @@ class phpbb_extension_manager
* in the extensions table.
*
* @param string $name The extension's name
- * @return bool Whether another run of enable_step is required
+ * @return bool False if enabling is finished, true otherwise
*/
public function enable_step($name)
{
@@ -191,18 +191,36 @@ class phpbb_extension_manager
* process the event.
*
* @param string $name The extension's name
- * @return null
+ * @return bool False if disabling is finished, true otherwise
*/
- public function disable($name)
+ public function disable_step($name)
{
// ignore extensions that are already disabled
if (!isset($this->extensions[$name]) || !$this->extensions[$name]['ext_active'])
{
- return;
+ return false;
}
+ $old_state = unserialize($this->extensions[$name]['ext_state']);
+
$extension = $this->get_extension($name);
- $extension->disable();
+ $state = $extension->disable_step($old_state);
+
+ // continue until the state is false
+ if ($state !== false)
+ {
+ $extension_data = array(
+ 'ext_state' => serialize($state),
+ );
+ $this->extensions[$name]['ext_state'] = serialize($state);
+
+ $sql = 'UPDATE ' . $this->extension_table . '
+ SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . "
+ WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
+ $this->db->sql_query($sql);
+
+ return true;
+ }
$extension_data = array(
'ext_active' => false,
@@ -215,6 +233,22 @@ class phpbb_extension_manager
SET ' . $this->db->sql_build_array('UPDATE', $extension_data) . "
WHERE ext_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
+
+ return false;
+ }
+
+ /**
+ * Disables an extension
+ *
+ * Disables an extension completely at once. This process could run for a
+ * while so never call this in a script that has a max_execution time.
+ *
+ * @param string $name The extension's name
+ * @return null
+ */
+ public function disable($name)
+ {
+ while ($this->disable_step($name));
}
/**
@@ -224,7 +258,7 @@ class phpbb_extension_manager
* extension's meta class to delete the extension's database content.
*
* @param string $name The extension's name
- * @return null
+ * @return bool False if purging is finished, true otherwise
*/
public function purge_step($name)
{