mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/11150] Cache the list of available packages for 24 hours
PHPBB3-11150
This commit is contained in:
parent
8b1284594b
commit
c49cd29e96
4 changed files with 33 additions and 15 deletions
|
@ -21,6 +21,7 @@ services:
|
||||||
class: phpbb\composer\extension_manager
|
class: phpbb\composer\extension_manager
|
||||||
arguments:
|
arguments:
|
||||||
- @ext.composer.installer
|
- @ext.composer.installer
|
||||||
|
- @cache.driver
|
||||||
- @ext.manager
|
- @ext.manager
|
||||||
- @filesystem
|
- @filesystem
|
||||||
- phpbb-extension
|
- phpbb-extension
|
||||||
|
@ -30,6 +31,7 @@ services:
|
||||||
class: phpbb\composer\manager
|
class: phpbb\composer\manager
|
||||||
arguments:
|
arguments:
|
||||||
- @ext.composer.installer
|
- @ext.composer.installer
|
||||||
|
- @cache.driver
|
||||||
- phpbb-style
|
- phpbb-style
|
||||||
- STYLES_
|
- STYLES_
|
||||||
|
|
||||||
|
@ -37,5 +39,6 @@ services:
|
||||||
class: phpbb\composer\manager
|
class: phpbb\composer\manager
|
||||||
arguments:
|
arguments:
|
||||||
- @ext.composer.installer
|
- @ext.composer.installer
|
||||||
|
- @cache.driver
|
||||||
- phpbb-language
|
- phpbb-language
|
||||||
- LANGUAGES_
|
- LANGUAGES_
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
namespace phpbb\composer;
|
namespace phpbb\composer;
|
||||||
|
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
|
use phpbb\cache\driver\driver_interface;
|
||||||
use phpbb\composer\exception\managed_with_clean_error_exception;
|
use phpbb\composer\exception\managed_with_clean_error_exception;
|
||||||
use phpbb\composer\exception\managed_with_enable_error_exception;
|
use phpbb\composer\exception\managed_with_enable_error_exception;
|
||||||
use phpbb\composer\exception\managed_with_error_exception;
|
use phpbb\composer\exception\managed_with_error_exception;
|
||||||
|
@ -39,17 +40,18 @@ class extension_manager extends manager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param installer $installer Installer object
|
* @param installer $installer Installer object
|
||||||
|
* @param driver_interface $cache Cache object
|
||||||
* @param ext_manager $extension_manager phpBB extension manager
|
* @param ext_manager $extension_manager phpBB extension manager
|
||||||
* @param filesystem $filesystem Filesystem object
|
* @param filesystem $filesystem Filesystem object
|
||||||
* @param string $package_type Composer type of managed packages
|
* @param string $package_type Composer type of managed packages
|
||||||
* @param string $exception_prefix Exception prefix to use
|
* @param string $exception_prefix Exception prefix to use
|
||||||
*/
|
*/
|
||||||
public function __construct(installer $installer, ext_manager $extension_manager, filesystem $filesystem, $package_type, $exception_prefix)
|
public function __construct(installer $installer, driver_interface $cache, ext_manager $extension_manager, filesystem $filesystem, $package_type, $exception_prefix)
|
||||||
{
|
{
|
||||||
$this->extension_manager = $extension_manager;
|
$this->extension_manager = $extension_manager;
|
||||||
$this->filesystem = $filesystem;
|
$this->filesystem = $filesystem;
|
||||||
|
|
||||||
parent::__construct($installer, $package_type, $exception_prefix);
|
parent::__construct($installer, $cache, $package_type, $exception_prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -233,7 +233,7 @@ class installer
|
||||||
if ($package instanceof CompletePackage)
|
if ($package instanceof CompletePackage)
|
||||||
{
|
{
|
||||||
$available[$package->getName()]['description'] = $package->getDescription();
|
$available[$package->getName()]['description'] = $package->getDescription();
|
||||||
$available[$package->getName()]['url'] = $package->getDistUrl();//getHomepage();
|
$available[$package->getName()]['url'] = $package->getHomepage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,12 +245,12 @@ class installer
|
||||||
{
|
{
|
||||||
if ($package->getType() === $type)
|
if ($package->getType() === $type)
|
||||||
{
|
{
|
||||||
$available[$package->getName()] = ['name' => $package];
|
$available[$package->getName()] = ['name' => $package->getPrettyName()];
|
||||||
|
|
||||||
if ($package instanceof CompletePackage)
|
if ($package instanceof CompletePackage)
|
||||||
{
|
{
|
||||||
$available[$package->getName()]['description'] = $package->getDescription();
|
$available[$package->getName()]['description'] = $package->getDescription();
|
||||||
$available[$package->getName()]['url'] = $package->getDistUrl();//getHomepage();
|
$available[$package->getName()]['url'] = $package->getHomepage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
namespace phpbb\composer;
|
namespace phpbb\composer;
|
||||||
|
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
|
use phpbb\cache\driver\driver_interface;
|
||||||
use phpbb\composer\exception\runtime_exception;
|
use phpbb\composer\exception\runtime_exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +27,11 @@ class manager implements manager_interface
|
||||||
*/
|
*/
|
||||||
protected $installer;
|
protected $installer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var driver_interface Cache instance
|
||||||
|
*/
|
||||||
|
protected $cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Type of packages (phpbb-packages per example)
|
* @var string Type of packages (phpbb-packages per example)
|
||||||
*/
|
*/
|
||||||
|
@ -53,12 +59,14 @@ class manager implements manager_interface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param installer $installer Installer object
|
* @param installer $installer Installer object
|
||||||
|
* @param driver_interface $cache Cache object
|
||||||
* @param string $package_type Composer type of managed packages
|
* @param string $package_type Composer type of managed packages
|
||||||
* @param string $exception_prefix Exception prefix to use
|
* @param string $exception_prefix Exception prefix to use
|
||||||
*/
|
*/
|
||||||
public function __construct(installer $installer, $package_type, $exception_prefix)
|
public function __construct(installer $installer, driver_interface $cache, $package_type, $exception_prefix)
|
||||||
{
|
{
|
||||||
$this->installer = $installer;
|
$this->installer = $installer;
|
||||||
|
$this->cache = $cache;
|
||||||
$this->package_type = $package_type;
|
$this->package_type = $package_type;
|
||||||
$this->exception_prefix = $exception_prefix;
|
$this->exception_prefix = $exception_prefix;
|
||||||
}
|
}
|
||||||
|
@ -177,8 +185,13 @@ class manager implements manager_interface
|
||||||
public function get_available_packages()
|
public function get_available_packages()
|
||||||
{
|
{
|
||||||
if ($this->available_packages === null)
|
if ($this->available_packages === null)
|
||||||
|
{
|
||||||
|
$this->available_packages = $this->cache->get('_composer_' . $this->package_type . '_available');
|
||||||
|
if ($this->available_packages === false)
|
||||||
{
|
{
|
||||||
$this->available_packages = $this->installer->get_available_packages($this->package_type);
|
$this->available_packages = $this->installer->get_available_packages($this->package_type);
|
||||||
|
$this->cache->put('_composer_' . $this->package_type . '_available', $this->available_packages, 24*60*60);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->available_packages;
|
return $this->available_packages;
|
||||||
|
|
Loading…
Add table
Reference in a new issue