mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/14891] Use own proxy instantiator for open_basedir compatibility
Also reverted random_compat lib to 1.4.x. PHPBB3-14891
This commit is contained in:
parent
467e603570
commit
7fedc19cc4
4 changed files with 83 additions and 9 deletions
|
@ -31,7 +31,7 @@
|
||||||
"guzzlehttp/guzzle": "~5.3",
|
"guzzlehttp/guzzle": "~5.3",
|
||||||
"lusitanian/oauth": "^0.8.1",
|
"lusitanian/oauth": "^0.8.1",
|
||||||
"marc1706/fast-image-size": "^1.1",
|
"marc1706/fast-image-size": "^1.1",
|
||||||
"paragonie/random_compat": "^2.0",
|
"paragonie/random_compat": "^1.4",
|
||||||
"patchwork/utf8": "^1.1",
|
"patchwork/utf8": "^1.1",
|
||||||
"s9e/text-formatter": "~0.8.0",
|
"s9e/text-formatter": "~0.8.0",
|
||||||
"symfony/config": "^2.8",
|
"symfony/config": "^2.8",
|
||||||
|
|
14
phpBB/composer.lock
generated
14
phpBB/composer.lock
generated
|
@ -4,8 +4,8 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "9e6c5df052c3e795ad5985862bbb5797",
|
"hash": "067b099cc97334a6a08a77e5648aa260",
|
||||||
"content-hash": "47456b70d82a0df10e5faa0a3dc1c2ae",
|
"content-hash": "90198ca524b93a7e915aa6916b2f55af",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bantu/ini-get-wrapper",
|
"name": "bantu/ini-get-wrapper",
|
||||||
|
@ -460,16 +460,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "paragonie/random_compat",
|
"name": "paragonie/random_compat",
|
||||||
"version": "v2.0.4",
|
"version": "v1.4.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/paragonie/random_compat.git",
|
"url": "https://github.com/paragonie/random_compat.git",
|
||||||
"reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e"
|
"reference": "c7e26a21ba357863de030f0b9e701c7d04593774"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e",
|
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/c7e26a21ba357863de030f0b9e701c7d04593774",
|
||||||
"reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e",
|
"reference": "c7e26a21ba357863de030f0b9e701c7d04593774",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -504,7 +504,7 @@
|
||||||
"pseudorandom",
|
"pseudorandom",
|
||||||
"random"
|
"random"
|
||||||
],
|
],
|
||||||
"time": "2016-11-07 23:38:38"
|
"time": "2016-03-18 20:34:03"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "patchwork/utf8",
|
"name": "patchwork/utf8",
|
||||||
|
|
|
@ -488,7 +488,7 @@ class container_builder
|
||||||
protected function create_container(array $extensions)
|
protected function create_container(array $extensions)
|
||||||
{
|
{
|
||||||
$container = new ContainerBuilder(new ParameterBag($this->get_core_parameters()));
|
$container = new ContainerBuilder(new ParameterBag($this->get_core_parameters()));
|
||||||
$container->setProxyInstantiator(new RuntimeInstantiator());
|
$container->setProxyInstantiator(new proxy_instantiator($this->get_cache_dir()));
|
||||||
|
|
||||||
$extensions_alias = array();
|
$extensions_alias = array();
|
||||||
|
|
||||||
|
|
74
phpBB/phpbb/di/proxy_instantiator.php
Normal file
74
phpBB/phpbb/di/proxy_instantiator.php
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\di;
|
||||||
|
|
||||||
|
use \bantu\IniGetWrapper\IniGetWrapper;
|
||||||
|
use ProxyManager\Configuration;
|
||||||
|
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
|
||||||
|
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
|
||||||
|
use ProxyManager\Proxy\LazyLoadingInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runtime lazy loading proxy generator extended for allowing use while using
|
||||||
|
* open_basedir restrictions
|
||||||
|
*
|
||||||
|
* Original author: Marco Pivetta <ocramius@gmail.com>
|
||||||
|
*/
|
||||||
|
class proxy_instantiator implements InstantiatorInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var LazyLoadingValueHolderFactory
|
||||||
|
*/
|
||||||
|
private $factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* proxy_instantiator constructor
|
||||||
|
* @param string $cache_dir Cache dir for fall back when using open_basedir
|
||||||
|
*/
|
||||||
|
public function __construct($cache_dir)
|
||||||
|
{
|
||||||
|
$config = new Configuration();
|
||||||
|
|
||||||
|
// Prevent trying to write to system temp dir in case of open_basedir
|
||||||
|
// restrictions being in effect
|
||||||
|
$ini_wrapper = new IniGetWrapper();
|
||||||
|
if ($ini_wrapper->getString('open_basedir') || !file_exists(sys_get_temp_dir()))
|
||||||
|
{
|
||||||
|
$config->setProxiesTargetDir($cache_dir);
|
||||||
|
}
|
||||||
|
$config->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
|
||||||
|
|
||||||
|
$this->factory = new LazyLoadingValueHolderFactory($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator)
|
||||||
|
{
|
||||||
|
return $this->factory->createProxy(
|
||||||
|
$definition->getClass(),
|
||||||
|
function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
|
||||||
|
$wrappedInstance = call_user_func($realInstantiator);
|
||||||
|
|
||||||
|
$proxy->setProxyInitializer(null);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue