diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -4801,7 +4801,7 @@ */ function _drupal_flush_css_js() { // The timestamp is converted to base 36 in order to make it more compact. - Drupal::state()->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); + variable_set('css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); } /** @@ -4845,7 +4845,7 @@ */ function _drupal_flush_css_js() { // The timestamp is converted to base 36 in order to make it more compact. - variable_set('css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); + Drupal::state()->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); } /** diff -u b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php --- b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Asset; use Drupal\Core\Asset\AssetCollectionRendererInterface; +use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Drupal\Component\Utility\String; /** @@ -15,6 +16,23 @@ class CssCollectionRenderer implements AssetCollectionRendererInterface { /** + * The state key/value store. + * + * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + */ + protected $state; + + /** + * Constructs a CssCollectionRenderer. + * + * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * The state key/value store. + */ + public function __construct(KeyValueStoreInterface $state) { + $this->state = $state; + } + + /** * {@inheritdoc} */ public function render(array $css_assets) { @@ -24,7 +42,7 @@ // browser-caching. The string changes on every update or full cache // flush, forcing browsers to load a new copy of the files, as the // URL changed. - $query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; + $query_string = $this->state->get('system.css_js_query_string') ?: '0'; // Defaults for LINK and STYLE elements. $link_element_defaults = array( diff -u b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php --- b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php @@ -1,6 +1,5 @@ 'CSS asset collection renderer functionality', @@ -82,7 +89,9 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->renderer = new CssCollectionRenderer(); + $this->state = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + + $this->renderer = new CssCollectionRenderer($this->state); $this->file_css_group = array( 'group' => -100, 'every_page' => TRUE, @@ -540,6 +549,10 @@ function testRenderProvider() { * @dataProvider testRenderProvider */ function testRender(array $css_assets, array $render_elements) { + $this->state->expects($this->once()) + ->method('get') + ->with('system.css_js_query_string') + ->will($this->returnValue(NULL)); $this->assertSame($render_elements, $this->renderer->render($css_assets)); } @@ -547,6 +560,10 @@ function testRender(array $css_assets, array $render_elements) { * Tests a CSS asset group with the invalid 'type' => 'internal'. */ function testRenderInvalidType() { + $this->state->expects($this->once()) + ->method('get') + ->with('system.css_js_query_string') + ->will($this->returnValue(NULL)); $this->setExpectedException('Exception', 'Invalid CSS asset type.'); $css_group = array(