1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-24 01:20:40 +01:00

[ticket/11150] Cache the list of available packages for 24 hours

PHPBB3-11150
This commit is contained in:
Tristan Darricau 2015-09-12 17:07:28 +02:00 committed by Tristan Darricau
parent 8b1284594b
commit c49cd29e96
No known key found for this signature in database
GPG Key ID: 817043C2E29DB881
4 changed files with 33 additions and 15 deletions

View File

@ -21,6 +21,7 @@ services:
class: phpbb\composer\extension_manager
arguments:
- @ext.composer.installer
- @cache.driver
- @ext.manager
- @filesystem
- phpbb-extension
@ -30,6 +31,7 @@ services:
class: phpbb\composer\manager
arguments:
- @ext.composer.installer
- @cache.driver
- phpbb-style
- STYLES_
@ -37,5 +39,6 @@ services:
class: phpbb\composer\manager
arguments:
- @ext.composer.installer
- @cache.driver
- phpbb-language
- LANGUAGES_

View File

@ -14,6 +14,7 @@
namespace phpbb\composer;
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_enable_error_exception;
use phpbb\composer\exception\managed_with_error_exception;
@ -38,18 +39,19 @@ class extension_manager extends manager
protected $filesystem;
/**
* @param installer $installer Installer object
* @param ext_manager $extension_manager phpBB extension manager
* @param filesystem $filesystem Filesystem object
* @param string $package_type Composer type of managed packages
* @param string $exception_prefix Exception prefix to use
* @param installer $installer Installer object
* @param driver_interface $cache Cache object
* @param ext_manager $extension_manager phpBB extension manager
* @param filesystem $filesystem Filesystem object
* @param string $package_type Composer type of managed packages
* @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->filesystem = $filesystem;
parent::__construct($installer, $package_type, $exception_prefix);
parent::__construct($installer, $cache, $package_type, $exception_prefix);
}
/**

View File

@ -233,7 +233,7 @@ class installer
if ($package instanceof CompletePackage)
{
$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)
{
$available[$package->getName()] = ['name' => $package];
$available[$package->getName()] = ['name' => $package->getPrettyName()];
if ($package instanceof CompletePackage)
{
$available[$package->getName()]['description'] = $package->getDescription();
$available[$package->getName()]['url'] = $package->getDistUrl();//getHomepage();
$available[$package->getName()]['url'] = $package->getHomepage();
}
}
}

View File

@ -14,6 +14,7 @@
namespace phpbb\composer;
use Composer\IO\IOInterface;
use phpbb\cache\driver\driver_interface;
use phpbb\composer\exception\runtime_exception;
/**
@ -26,6 +27,11 @@ class manager implements manager_interface
*/
protected $installer;
/**
* @var driver_interface Cache instance
*/
protected $cache;
/**
* @var string Type of packages (phpbb-packages per example)
*/
@ -52,13 +58,15 @@ class manager implements manager_interface
private $available_packages;
/**
* @param installer $installer Installer object
* @param string $package_type Composer type of managed packages
* @param string $exception_prefix Exception prefix to use
* @param installer $installer Installer object
* @param driver_interface $cache Cache object
* @param string $package_type Composer type of managed packages
* @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->cache = $cache;
$this->package_type = $package_type;
$this->exception_prefix = $exception_prefix;
}
@ -178,7 +186,12 @@ class manager implements manager_interface
{
if ($this->available_packages === null)
{
$this->available_packages = $this->installer->get_available_packages($this->package_type);
$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->cache->put('_composer_' . $this->package_type . '_available', $this->available_packages, 24*60*60);
}
}
return $this->available_packages;