mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge pull request #6091 from rxu/ticket/16654
[ticket/16654] Upgrade Twig to version 3
This commit is contained in:
commit
1306e63fd7
14 changed files with 83 additions and 79 deletions
|
@ -43,17 +43,20 @@
|
||||||
<dt><label for="{{ storage.get_name }}">{{ lang('STORAGE_SELECT') }}{{ lang('COLON') }}</label><br /><span>{{ lang('STORAGE_SELECT_DESC') }}</span></dt>
|
<dt><label for="{{ storage.get_name }}">{{ lang('STORAGE_SELECT') }}{{ lang('COLON') }}</label><br /><span>{{ lang('STORAGE_SELECT_DESC') }}</span></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<select id="{{ storage.get_name }}" name="{{ storage.get_name }}[provider]" data-togglable-settings="true">
|
<select id="{{ storage.get_name }}" name="{{ storage.get_name }}[provider]" data-togglable-settings="true">
|
||||||
{% for provider in PROVIDERS if provider.is_available %}
|
{% for provider in PROVIDERS %}
|
||||||
|
{% if provider.is_available %}
|
||||||
<option value="{{ get_class(provider) }}"{{ attribute(config, 'storage\\' ~ storage.get_name ~ '\\provider') == get_class(provider) ? ' selected' : '' }} data-toggle-setting="#{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
<option value="{{ get_class(provider) }}"{{ attribute(config, 'storage\\' ~ storage.get_name ~ '\\provider') == get_class(provider) ? ' selected' : '' }} data-toggle-setting="#{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
||||||
{{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}
|
{{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}
|
||||||
</option>
|
</option>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
{% for provider in PROVIDERS if provider.is_available %}
|
{% for provider in PROVIDERS %}
|
||||||
|
{% if provider.is_available %}
|
||||||
<fieldset id="{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
<fieldset id="{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
||||||
<legend>{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}</legend>
|
<legend>{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}</legend>
|
||||||
{% for name, options in provider.get_options %}
|
{% for name, options in provider.get_options %}
|
||||||
|
@ -90,6 +93,7 @@
|
||||||
</dl>
|
</dl>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
"symfony/routing": "~5.2",
|
"symfony/routing": "~5.2",
|
||||||
"symfony/twig-bridge": "~5.2",
|
"symfony/twig-bridge": "~5.2",
|
||||||
"symfony/yaml": "~5.2",
|
"symfony/yaml": "~5.2",
|
||||||
"twig/twig": "^1.0 || ^2.0"
|
"twig/twig": "^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fabpot/goutte": "~3.2",
|
"fabpot/goutte": "~3.2",
|
||||||
|
|
35
phpBB/composer.lock
generated
35
phpBB/composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "f33ff5b8d67189b9b8c2bf749f8fd4e0",
|
"content-hash": "8b28fd874f1be23586736a9c2155f5c4",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bantu/ini-get-wrapper",
|
"name": "bantu/ini-get-wrapper",
|
||||||
|
@ -1553,24 +1553,26 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laminas/laminas-zendframework-bridge",
|
"name": "laminas/laminas-zendframework-bridge",
|
||||||
"version": "1.1.1",
|
"version": "1.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/laminas/laminas-zendframework-bridge.git",
|
"url": "https://github.com/laminas/laminas-zendframework-bridge.git",
|
||||||
"reference": "6ede70583e101030bcace4dcddd648f760ddf642"
|
"reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6ede70583e101030bcace4dcddd648f760ddf642",
|
"url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6cccbddfcfc742eb02158d6137ca5687d92cee32",
|
||||||
"reference": "6ede70583e101030bcace4dcddd648f760ddf642",
|
"reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.6 || ^7.0 || ^8.0"
|
"php": "^7.3 || ^8.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3",
|
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3",
|
||||||
"squizlabs/php_codesniffer": "^3.5"
|
"psalm/plugin-phpunit": "^0.15.1",
|
||||||
|
"squizlabs/php_codesniffer": "^3.5",
|
||||||
|
"vimeo/psalm": "^4.6"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -1609,7 +1611,7 @@
|
||||||
"type": "community_bridge"
|
"type": "community_bridge"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2020-09-14T14:23:00+00:00"
|
"time": "2021-02-25T21:54:58+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lusitanian/oauth",
|
"name": "lusitanian/oauth",
|
||||||
|
@ -4883,16 +4885,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v2.14.3",
|
"version": "v3.3.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "8bc568d460d88b25c00c046256ec14a787ea60d9"
|
"reference": "1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/8bc568d460d88b25c00c046256ec14a787ea60d9",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5",
|
||||||
"reference": "8bc568d460d88b25c00c046256ec14a787ea60d9",
|
"reference": "1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -4907,13 +4909,10 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.14-dev"
|
"dev-master": "3.3-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
|
||||||
"Twig_": "lib/"
|
|
||||||
},
|
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Twig\\": "src/"
|
"Twig\\": "src/"
|
||||||
}
|
}
|
||||||
|
@ -4946,7 +4945,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v2.14.3"
|
"source": "https://github.com/twigphp/Twig/tree/v3.3.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -4958,7 +4957,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-01-05T15:34:33+00:00"
|
"time": "2021-02-08T09:54:36+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
|
|
|
@ -181,7 +181,7 @@ class environment extends \Twig\Environment
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function render($name, array $context = [])
|
public function render($name, array $context = []) : string
|
||||||
{
|
{
|
||||||
return $this->display_with_assets($name, $context);
|
return $this->display_with_assets($name, $context);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ class environment extends \Twig\Environment
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function display($name, array $context = [])
|
public function display($name, array $context = []) : void
|
||||||
{
|
{
|
||||||
echo $this->display_with_assets($name, $context);
|
echo $this->display_with_assets($name, $context);
|
||||||
}
|
}
|
||||||
|
@ -259,12 +259,13 @@ class environment extends \Twig\Environment
|
||||||
/**
|
/**
|
||||||
* Loads a template by name.
|
* Loads a template by name.
|
||||||
*
|
*
|
||||||
|
* @param string $cls The template class associated with the given template name
|
||||||
* @param string $name The template name
|
* @param string $name The template name
|
||||||
* @param integer $index The index if it is an embedded template
|
* @param integer $index The index if it is an embedded template
|
||||||
* @return \Twig\Template A template instance representing the given template name
|
* @return \Twig\Template A template instance representing the given template name
|
||||||
* @throws \Twig\Error\LoaderError
|
* @throws \Twig\Error\LoaderError
|
||||||
*/
|
*/
|
||||||
public function loadTemplate($name, $index = null)
|
public function loadTemplate(string $cls, string $name, int $index = null) : \Twig\Template
|
||||||
{
|
{
|
||||||
if (strpos($name, '@') === false)
|
if (strpos($name, '@') === false)
|
||||||
{
|
{
|
||||||
|
@ -274,10 +275,10 @@ class environment extends \Twig\Environment
|
||||||
{
|
{
|
||||||
if ($namespace === '__main__')
|
if ($namespace === '__main__')
|
||||||
{
|
{
|
||||||
return parent::loadTemplate($name, $index);
|
return parent::loadTemplate($cls, $name, $index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::loadTemplate('@' . $namespace . '/' . $name, $index);
|
return parent::loadTemplate($this->getTemplateClass('@' . $namespace . '/' . $name), '@' . $namespace . '/' . $name, $index);
|
||||||
}
|
}
|
||||||
catch (\Twig\Error\LoaderError $e)
|
catch (\Twig\Error\LoaderError $e)
|
||||||
{
|
{
|
||||||
|
@ -289,7 +290,7 @@ class environment extends \Twig\Environment
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return parent::loadTemplate($name, $index);
|
return parent::loadTemplate($cls, $name, $index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig;
|
||||||
|
|
||||||
class lexer extends \Twig\Lexer
|
class lexer extends \Twig\Lexer
|
||||||
{
|
{
|
||||||
public function tokenize(\Twig\Source $source)
|
public function tokenize(\Twig\Source $source) : \Twig\TokenStream
|
||||||
{
|
{
|
||||||
$code = $source->getCode();
|
$code = $source->getCode();
|
||||||
$filename = $source->getName();
|
$filename = $source->getName();
|
||||||
|
|
|
@ -99,9 +99,9 @@ class loader extends \Twig\Loader\FilesystemLoader
|
||||||
*
|
*
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
|
public function addPath($path, $namespace = self::MAIN_NAMESPACE) : void
|
||||||
{
|
{
|
||||||
return parent::addPath(filesystem_helper::realpath($path), $namespace);
|
parent::addPath(filesystem_helper::realpath($path), $namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -65,7 +65,7 @@ class event extends \Twig\Node\Node
|
||||||
|
|
||||||
// We set the namespace lookup order to be this extension first, then the main path
|
// We set the namespace lookup order to be this extension first, then the main path
|
||||||
->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
|
->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
|
||||||
->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")
|
->write("\$this->env->loadTemplate(\$this->env->getTemplateClass('@{$ext_namespace}/{$location}.html'), '@{$ext_namespace}/{$location}.html')->display(\$context);\n")
|
||||||
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
|
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig\node\expression\binary;
|
||||||
|
|
||||||
class equalequal extends \Twig\Node\Expression\Binary\AbstractBinary
|
class equalequal extends \Twig\Node\Expression\Binary\AbstractBinary
|
||||||
{
|
{
|
||||||
public function operator(\Twig\Compiler $compiler)
|
public function operator(\Twig\Compiler $compiler) : \Twig\Compiler
|
||||||
{
|
{
|
||||||
return $compiler->raw('===');
|
return $compiler->raw('===');
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig\node\expression\binary;
|
||||||
|
|
||||||
class notequalequal extends \Twig\Node\Expression\Binary\AbstractBinary
|
class notequalequal extends \Twig\Node\Expression\Binary\AbstractBinary
|
||||||
{
|
{
|
||||||
public function operator(\Twig\Compiler $compiler)
|
public function operator(\Twig\Compiler $compiler) : \Twig\Compiler
|
||||||
{
|
{
|
||||||
return $compiler->raw('!==');
|
return $compiler->raw('!==');
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class includenode extends \Twig\Node\IncludeNode
|
||||||
*
|
*
|
||||||
* @param \Twig\Compiler A Twig\Compiler instance
|
* @param \Twig\Compiler A Twig\Compiler instance
|
||||||
*/
|
*/
|
||||||
public function compile(\Twig\Compiler $compiler)
|
public function compile(\Twig\Compiler $compiler) : void
|
||||||
{
|
{
|
||||||
$compiler->addDebugInfo($this);
|
$compiler->addDebugInfo($this);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class defineparser extends \Twig\TokenParser\AbstractTokenParser
|
||||||
{
|
{
|
||||||
// This would happen if someone improperly formed their DEFINE syntax
|
// This would happen if someone improperly formed their DEFINE syntax
|
||||||
// e.g. <!-- DEFINE $VAR = foo -->
|
// e.g. <!-- DEFINE $VAR = foo -->
|
||||||
throw new \Twig\Error\SyntaxError('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext()->getPath());
|
throw new \Twig\Error\SyntaxError('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream->expect(\Twig\Token::BLOCK_END_TYPE);
|
$stream->expect(\Twig\Token::BLOCK_END_TYPE);
|
||||||
|
|
|
@ -23,7 +23,7 @@ class includeparser extends \Twig\TokenParser\IncludeTokenParser
|
||||||
*
|
*
|
||||||
* @return \Twig\Node\Node A Twig\Node instance
|
* @return \Twig\Node\Node A Twig\Node instance
|
||||||
*/
|
*/
|
||||||
public function parse(\Twig\Token $token)
|
public function parse(\Twig\Token $token) : \Twig\Node\Node
|
||||||
{
|
{
|
||||||
$expr = $this->parser->getExpressionParser()->parseExpression();
|
$expr = $this->parser->getExpressionParser()->parseExpression();
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class includeparser extends \Twig\TokenParser\IncludeTokenParser
|
||||||
*
|
*
|
||||||
* @return string The tag name
|
* @return string The tag name
|
||||||
*/
|
*/
|
||||||
public function getTag()
|
public function getTag() : string
|
||||||
{
|
{
|
||||||
return 'INCLUDE';
|
return 'INCLUDE';
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
<!-- IF AUTHOR_AVATAR --><a href="{U_MESSAGE_AUTHOR}" class="avatar">{AUTHOR_AVATAR}</a><!-- ENDIF -->
|
<!-- IF AUTHOR_AVATAR --><a href="{U_MESSAGE_AUTHOR}" class="avatar">{AUTHOR_AVATAR}</a><!-- ENDIF -->
|
||||||
<!-- EVENT ucp_pm_viewmessage_avatar_after -->
|
<!-- EVENT ucp_pm_viewmessage_avatar_after -->
|
||||||
</div>
|
</div>
|
||||||
{% spaceless %}
|
{% apply spaceless %}
|
||||||
{% EVENT ucp_pm_viewmessage_author_full_before %}
|
{% EVENT ucp_pm_viewmessage_author_full_before %}
|
||||||
{MESSAGE_AUTHOR_FULL}
|
{MESSAGE_AUTHOR_FULL}
|
||||||
{% EVENT ucp_pm_viewmessage_author_full_after %}
|
{% EVENT ucp_pm_viewmessage_author_full_after %}
|
||||||
<!-- IF S_ONLINE --> {{ Icon('iconify', 'fa:circle', lang('ONLINE'), true, 'c-online-icon') }}<!-- ENDIF -->
|
<!-- IF S_ONLINE --> {{ Icon('iconify', 'fa:circle', lang('ONLINE'), true, 'c-online-icon') }}<!-- ENDIF -->
|
||||||
{% endspaceless %}
|
{% endapply %}
|
||||||
</dt>
|
</dt>
|
||||||
|
|
||||||
<!-- EVENT ucp_pm_viewmessage_rank_before -->
|
<!-- EVENT ucp_pm_viewmessage_rank_before -->
|
||||||
|
|
|
@ -522,7 +522,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||||
$this->template->set_filenames(array('test' => $filename));
|
$this->template->set_filenames(array('test' => $filename));
|
||||||
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
|
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
|
||||||
|
|
||||||
$this->expectException('Twig_Error_Loader');
|
$this->expectException(\Twig\Error\LoaderError::class);
|
||||||
|
|
||||||
$this->display('test');
|
$this->display('test');
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||||
|
|
||||||
public function test_invalid_handle()
|
public function test_invalid_handle()
|
||||||
{
|
{
|
||||||
$this->expectException('Twig_Error_Loader');
|
$this->expectException(\Twig\Error\LoaderError::class);
|
||||||
|
|
||||||
$this->display('test');
|
$this->display('test');
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1076,7 @@ EOT
|
||||||
|
|
||||||
public function test_define_error()
|
public function test_define_error()
|
||||||
{
|
{
|
||||||
$this->expectException('Twig_Error_Syntax');
|
$this->expectException(\Twig\Error\SyntaxError::class);
|
||||||
$this->run_template('define_error.html', array(), array(), array(), '');
|
$this->run_template('define_error.html', array(), array(), array(), '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue