mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-06 14:35:56 +02:00
[ticket/10614] Tweak list output, show state, purge cache, handle missing exts
PHPBB3-10614
This commit is contained in:
parent
b222030ca7
commit
5ccd6b0c7a
@ -22,8 +22,9 @@ function usage()
|
|||||||
echo " Lists all extensions in the database and the filesystem.\n";
|
echo " Lists all extensions in the database and the filesystem.\n";
|
||||||
echo " Next to each extension name are two flags:\n";
|
echo " Next to each extension name are two flags:\n";
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo " * P|M - present|missing: whether the extension exists in the filesystem\n";
|
echo " * present|missing: whether the extension exists in the filesystem\n";
|
||||||
echo " * A|I - active|inactive: whether the extension is activated in the database\n";
|
echo " * active|inactive: whether the extension is activated in the database\n";
|
||||||
|
echo " * state: the current persisted installation state\n";
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo "enable NAME:\n";
|
echo "enable NAME:\n";
|
||||||
echo " Enables the specified extension.\n";
|
echo " Enables the specified extension.\n";
|
||||||
@ -35,15 +36,18 @@ function usage()
|
|||||||
|
|
||||||
function list_extensions()
|
function list_extensions()
|
||||||
{
|
{
|
||||||
global $db, $phpbb_root_path;
|
global $db, $cache, $phpbb_root_path;
|
||||||
|
|
||||||
$sql = "SELECT ext_name, ext_active from " . EXT_TABLE;
|
$cache->destroy('_ext');
|
||||||
|
|
||||||
|
$sql = "SELECT ext_name, ext_active, ext_state from " . EXT_TABLE;
|
||||||
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
$extensions = array();
|
$extensions = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$extensions[$row['ext_name']]['active'] = (bool) $row['ext_active'];
|
$extensions[$row['ext_name']]['active'] = (bool) $row['ext_active'];
|
||||||
|
$extensions[$row['ext_name']]['state'] = (bool) $row['ext_state'];
|
||||||
if (file_exists($phpbb_root_path . 'ext/' . $row['ext_name']))
|
if (file_exists($phpbb_root_path . 'ext/' . $row['ext_name']))
|
||||||
{
|
{
|
||||||
$extensions[$row['ext_name']]['present'] = true;
|
$extensions[$row['ext_name']]['present'] = true;
|
||||||
@ -64,7 +68,7 @@ function list_extensions()
|
|||||||
{
|
{
|
||||||
if (!array_key_exists($file, $extensions))
|
if (!array_key_exists($file, $extensions))
|
||||||
{
|
{
|
||||||
$extensions[$file] = array('active' => false, 'present' => true);
|
$extensions[$file] = array('active' => false, 'present' => true, 'state' => false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,22 +76,27 @@ function list_extensions()
|
|||||||
ksort($extensions);
|
ksort($extensions);
|
||||||
foreach ($extensions as $name => $ext)
|
foreach ($extensions as $name => $ext)
|
||||||
{
|
{
|
||||||
$present = $ext['active'] ? 'P' : 'M';
|
$present = $ext['present'] ? 'present' : 'missing';
|
||||||
$active = $ext['active'] ? 'A' : 'I';
|
$active = $ext['active'] ? 'active' : 'inactive';
|
||||||
printf("%-20s %s %s\n", $name, $present, $active);
|
$state = json_encode(unserialize($ext['state']));
|
||||||
|
printf("%-20s %-7s %-7s %-20s\n", $name, $present, $active, $state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function enable_extension($name)
|
function enable_extension($name)
|
||||||
{
|
{
|
||||||
global $phpbb_extension_manager;
|
global $phpbb_extension_manager, $cache;
|
||||||
|
|
||||||
|
$cache->destroy('_ext');
|
||||||
|
|
||||||
$phpbb_extension_manager->enable($name);
|
$phpbb_extension_manager->enable($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function disable_extension($name)
|
function disable_extension($name)
|
||||||
{
|
{
|
||||||
global $phpbb_extension_manager;
|
global $phpbb_extension_manager, $cache;
|
||||||
|
|
||||||
|
$cache->destroy('_ext');
|
||||||
|
|
||||||
$phpbb_extension_manager->disable($name);
|
$phpbb_extension_manager->disable($name);
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,12 @@ class phpbb_extension_manager
|
|||||||
*/
|
*/
|
||||||
public function enable_step($name)
|
public function enable_step($name)
|
||||||
{
|
{
|
||||||
|
$ext_path = $this->get_extension_path($name);
|
||||||
|
if (!file_exists($ext_path))
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException('The provided extension does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
// ignore extensions that are already enabled
|
// ignore extensions that are already enabled
|
||||||
if (isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'])
|
if (isset($this->extensions[$name]) && $this->extensions[$name]['ext_active'])
|
||||||
{
|
{
|
||||||
@ -152,7 +158,7 @@ class phpbb_extension_manager
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->extensions[$name] = $extension_data;
|
$this->extensions[$name] = $extension_data;
|
||||||
$this->extensions[$name]['ext_path'] = $this->get_extension_path($extension_data['ext_name']);
|
$this->extensions[$name]['ext_path'] = $ext_path;
|
||||||
ksort($this->extensions);
|
ksort($this->extensions);
|
||||||
|
|
||||||
$sql = 'UPDATE ' . $this->extension_table . '
|
$sql = 'UPDATE ' . $this->extension_table . '
|
||||||
@ -195,6 +201,12 @@ class phpbb_extension_manager
|
|||||||
*/
|
*/
|
||||||
public function disable_step($name)
|
public function disable_step($name)
|
||||||
{
|
{
|
||||||
|
$ext_path = $this->get_extension_path($name);
|
||||||
|
if (!file_exists($ext_path))
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException('The provided extension does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
// ignore extensions that are already disabled
|
// ignore extensions that are already disabled
|
||||||
if (!isset($this->extensions[$name]) || !$this->extensions[$name]['ext_active'])
|
if (!isset($this->extensions[$name]) || !$this->extensions[$name]['ext_active'])
|
||||||
{
|
{
|
||||||
@ -262,6 +274,12 @@ class phpbb_extension_manager
|
|||||||
*/
|
*/
|
||||||
public function purge_step($name)
|
public function purge_step($name)
|
||||||
{
|
{
|
||||||
|
$ext_path = $this->get_extension_path($name);
|
||||||
|
if (!file_exists($ext_path))
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException('The provided extension does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
// ignore extensions that do not exist
|
// ignore extensions that do not exist
|
||||||
if (!isset($this->extensions[$name]))
|
if (!isset($this->extensions[$name]))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user