aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-07-11 11:28:35 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-07-11 11:28:35 -0500
commit947b907efef43704c620507db17aff4fe115f219 (patch)
tree9eabcae6e2b6a585d3db0767f685379b60420e29
parentabd4159f87db8db5030afc439f072d6aa7b715e3 (diff)
downloadforums-947b907efef43704c620507db17aff4fe115f219.tar
forums-947b907efef43704c620507db17aff4fe115f219.tar.gz
forums-947b907efef43704c620507db17aff4fe115f219.tar.bz2
forums-947b907efef43704c620507db17aff4fe115f219.tar.xz
forums-947b907efef43704c620507db17aff4fe115f219.zip
[ticket/11388] Do not append assets_version if using remote path (e.g. http)
PHPBB3-11388
-rw-r--r--phpBB/includes/template/twig/node/includeasset.php5
-rw-r--r--tests/template/template_includejs_test.php6
2 files changed, 5 insertions, 6 deletions
diff --git a/phpBB/includes/template/twig/node/includeasset.php b/phpBB/includes/template/twig/node/includeasset.php
index 647ae22d81..5abff10e3f 100644
--- a/phpBB/includes/template/twig/node/includeasset.php
+++ b/phpBB/includes/template/twig/node/includeasset.php
@@ -33,8 +33,7 @@ class phpbb_template_twig_node_includeasset extends Twig_Node
->write("\$asset_file = ")
->subcompile($this->getNode('expr'))
->raw(";\n")
- ->write("\$argument_string = '?assets_version={$config['assets_version']}';\n")
- ->write("\$anchor_string = '';\n")
+ ->write("\$argument_string = \$anchor_string = '';\n")
->write("if ((\$argument_string_start = strpos(\$asset_file, '?')) !== false) {\n")
->indent()
->write("\$argument_string = substr(\$asset_file, \$argument_string_start);\n")
@@ -45,12 +44,12 @@ class phpbb_template_twig_node_includeasset extends Twig_Node
->write("\$argument_string = substr(\$argument_string, 0, \$anchor_string_start);\n")
->outdent()
->write("}\n")
- ->write("\$argument_string .= '&assets_version=" . $config['assets_version'] . "';\n")
->outdent()
->write("}\n")
->write("if (strpos(\$asset_file, '//') !== 0 && strpos(\$asset_file, 'http://') !== 0 && strpos(\$asset_file, 'https://') !== 0 && !file_exists(\$asset_file)) {\n")
->indent()
->write("\$asset_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_file);\n")
+ ->write("\$argument_string .= ((\$argument_string) ? '&' : '?') . 'assets_version={$config['assets_version']}';\n")
->outdent()
->write("}\n")
->write("\$asset_file .= \$argument_string . \$anchor_string;\n")
diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php
index d4a384a1c5..ea5c30891b 100644
--- a/tests/template/template_includejs_test.php
+++ b/tests/template/template_includejs_test.php
@@ -78,15 +78,15 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
),
array(
array('TEST' => 15),
- '<script type="text/javascript" src="http://phpbb.com/b.js?c=d&assets_version=1#f"></script>',
+ '<script type="text/javascript" src="http://phpbb.com/b.js?c=d#f"></script>',
),
array(
array('TEST' => 16),
- '<script type="text/javascript" src="http://phpbb.com/b.js?c=d&assets_version=1&assets_version=1#f"></script>',
+ '<script type="text/javascript" src="http://phpbb.com/b.js?c=d&assets_version=1#f"></script>',
),
array(
array('TEST' => 17),
- '<script type="text/javascript" src="//phpbb.com/b.js?assets_version=1"></script>',
+ '<script type="text/javascript" src="//phpbb.com/b.js"></script>',
),
);
}