diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 57b8a01..43bfd70 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -207,7 +207,7 @@ public function removeBin() { * @return int */ protected function getRequestTime() { - return defined('REQUEST_TIME') ? REQUEST_TIME : (int) $_SERVER['REQUEST_TIME']; + return defined('REQUEST_TIME') ? REQUEST_TIME : $_SERVER['REQUEST_TIME']; } /** diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index 364fe67..ce9c04b 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -299,6 +299,6 @@ protected function pathAliasWhitelistRebuild($path = NULL) { * @return int */ protected function getRequestTime() { - return defined('REQUEST_TIME') ? REQUEST_TIME : (int) $_SERVER['REQUEST_TIME']; + return defined('REQUEST_TIME') ? REQUEST_TIME : $_SERVER['REQUEST_TIME']; } } diff --git a/core/lib/Drupal/Core/Render/RenderCache.php b/core/lib/Drupal/Core/Render/RenderCache.php index 934582c..7765704 100644 --- a/core/lib/Drupal/Core/Render/RenderCache.php +++ b/core/lib/Drupal/Core/Render/RenderCache.php @@ -287,7 +287,7 @@ public function set(array &$elements, array $pre_bubbling_elements) { * @see \Drupal\Core\Cache\CacheBackendInterface::set() */ protected function maxAgeToExpire($max_age) { - return ($max_age === Cache::PERMANENT) ? Cache::PERMANENT : (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME') + $max_age; + return ($max_age === Cache::PERMANENT) ? Cache::PERMANENT : $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME') + $max_age; } /** diff --git a/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php b/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php index 5b26919..1e27fc5 100644 --- a/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php +++ b/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php @@ -66,7 +66,7 @@ public function onTerminate(PostResponseEvent $event) { $interval = $this->config->get('interval'); if ($interval > 0) { $cron_next = $this->state->get('system.cron_last', 0) + $interval; - if ((int) $event->getRequest()->server->get('REQUEST_TIME') > $cron_next) { + if ($event->getRequest()->server->get('REQUEST_TIME') > $cron_next) { $this->cron->run(); } } diff --git a/core/modules/user/src/PrivateTempStore.php b/core/modules/user/src/PrivateTempStore.php index 7215805..777f998 100644 --- a/core/modules/user/src/PrivateTempStore.php +++ b/core/modules/user/src/PrivateTempStore.php @@ -128,7 +128,7 @@ public function set($key, $value) { $value = (object) array( 'owner' => $this->getOwner(), 'data' => $value, - 'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'), + 'updated' => $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'), ); $this->storage->setWithExpire($key, $value, $this->expire); $this->lockBackend->release($key); diff --git a/core/modules/user/src/SharedTempStore.php b/core/modules/user/src/SharedTempStore.php index 07e4756..54dab48 100644 --- a/core/modules/user/src/SharedTempStore.php +++ b/core/modules/user/src/SharedTempStore.php @@ -150,7 +150,7 @@ public function setIfNotExists($key, $value) { $value = (object) array( 'owner' => $this->owner, 'data' => $value, - 'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'), + 'updated' => $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'), ); return $this->storage->setWithExpireIfNotExists($key, $value, $this->expire); } @@ -202,7 +202,7 @@ public function set($key, $value) { $value = (object) array( 'owner' => $this->owner, 'data' => $value, - 'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'), + 'updated' => $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'), ); $this->storage->setWithExpire($key, $value, $this->expire); $this->lockBackend->release($key); diff --git a/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php index a2d3d95..33117a5 100644 --- a/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php +++ b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php @@ -89,7 +89,7 @@ protected function setUp() { $this->ownObject = (object) array( 'data' => 'test_data', 'owner' => $this->currentUser->id(), - 'updated' => (int) $request->server->get('REQUEST_TIME'), + 'updated' => $request->server->get('REQUEST_TIME'), ); // Clone the object but change the owner. diff --git a/core/modules/user/tests/src/Unit/SharedTempStoreTest.php b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php index effc4f9..559cd79 100644 --- a/core/modules/user/tests/src/Unit/SharedTempStoreTest.php +++ b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php @@ -84,7 +84,7 @@ protected function setUp() { $this->ownObject = (object) array( 'data' => 'test_data', 'owner' => $this->owner, - 'updated' => (int) $request->server->get('REQUEST_TIME'), + 'updated' => $request->server->get('REQUEST_TIME'), ); // Clone the object but change the owner. diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index f04232e..a7e31f6 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -114,7 +114,7 @@ public function cacheSet($type) { 'total_rows' => isset($this->view->total_rows) ? $this->view->total_rows : 0, 'current_page' => $this->view->getCurrentPage(), ); - $expire = ($this->cacheSetMaxAge($type) === Cache::PERMANENT) ? Cache::PERMANENT : (int) $this->view->getRequest()->server->get('REQUEST_TIME') + $this->cacheSetMaxAge($type); + $expire = ($this->cacheSetMaxAge($type) === Cache::PERMANENT) ? Cache::PERMANENT : $this->view->getRequest()->server->get('REQUEST_TIME') + $this->cacheSetMaxAge($type); \Drupal::cache($this->resultsBin)->set($this->generateResultsKey(), $data, $expire, $this->getCacheTags()); break; } diff --git a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php index c6d7726..cd50b88 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php @@ -99,7 +99,7 @@ public function testIsLocked() { $lock = (object) array( 'owner' => 2, 'data' => array(), - 'updated' => (int) $_SERVER['REQUEST_TIME'], + 'updated' => $_SERVER['REQUEST_TIME'], ); $view_ui->lock = $lock; $this->assertTrue($view_ui->isLocked()); @@ -108,7 +108,7 @@ public function testIsLocked() { $lock = (object) array( 'owner' => 1, 'data' => array(), - 'updated' => (int) $_SERVER['REQUEST_TIME'], + 'updated' => $_SERVER['REQUEST_TIME'], ); $view_ui->lock = $lock; $this->assertFalse($view_ui->isLocked()); diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php index 1d8edcb..1161930 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php @@ -121,7 +121,7 @@ public function testGetFromCache() { $cache = (object) array( 'data' => array($key => $value), - 'created' => (int) $_SERVER['REQUEST_TIME'], + 'created' => $_SERVER['REQUEST_TIME'], ); $this->cacheBackend->expects($this->once()) ->method('get') @@ -229,7 +229,7 @@ public function testUpdateCacheInvalidatedConflict() { $cache = (object) array( 'data' => array($key => $value), - 'created' => (int) $_SERVER['REQUEST_TIME'], + 'created' => $_SERVER['REQUEST_TIME'], ); $this->cacheBackend->expects($this->at(0)) ->method('get') @@ -250,7 +250,7 @@ public function testUpdateCacheInvalidatedConflict() { ->will($this->returnValue(TRUE)); $cache = (object) array( 'data' => array($key => $value), - 'created' => (int) $_SERVER['REQUEST_TIME'] + 1, + 'created' => $_SERVER['REQUEST_TIME'] + 1, ); $this->cacheBackend->expects($this->at(0)) ->method('get') @@ -286,7 +286,7 @@ public function testUpdateCacheMerge() { ->will($this->returnValue(TRUE)); $cache = (object) array( 'data' => array('other key' => 'other value'), - 'created' => (int) $_SERVER['REQUEST_TIME'] + 1, + 'created' => $_SERVER['REQUEST_TIME'] + 1, ); $this->cacheBackend->expects($this->at(0)) ->method('get') @@ -312,7 +312,7 @@ public function testUpdateCacheDelete() { $cache = (object) array( 'data' => array($key => $value), - 'created' => (int) $_SERVER['REQUEST_TIME'], + 'created' => $_SERVER['REQUEST_TIME'], ); $this->cacheBackend->expects($this->at(0)) ->method('get') diff --git a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php index 11e1600..f73d21a 100644 --- a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php @@ -45,7 +45,7 @@ public function testGetDoesntHitConsistentBackend() { $consistent_cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); $timestamp_cid = ChainedFastBackend::LAST_WRITE_TIMESTAMP_PREFIX . 'cache_foo'; // Use the request time because that is what we will be comparing against. - $timestamp_item = (object) array('cid' => $timestamp_cid, 'data' => (int) $_SERVER['REQUEST_TIME'] - 60); + $timestamp_item = (object) array('cid' => $timestamp_cid, 'data' => $_SERVER['REQUEST_TIME'] - 60); $consistent_cache->expects($this->once()) ->method('get')->with($timestamp_cid) ->will($this->returnValue($timestamp_item)); diff --git a/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php b/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php index cc041ce..ade15ff 100644 --- a/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Path/AliasManagerTest.php @@ -207,7 +207,7 @@ public function testGetAliasByPathNoMatch() { // This needs to write out the cache. $this->cache->expects($this->once()) ->method('set') - ->with($this->cacheKey, array($language->getId() => array($path)), (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24)); + ->with($this->cacheKey, array($language->getId() => array($path)), $_SERVER['REQUEST_TIME'] + (60 * 60 * 24)); $this->aliasManager->writeCache(); } @@ -245,7 +245,7 @@ public function testGetAliasByPathMatch() { // This needs to write out the cache. $this->cache->expects($this->once()) ->method('set') - ->with($this->cacheKey, array($language->getId() => array($path)), (int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24)); + ->with($this->cacheKey, array($language->getId() => array($path)), $_SERVER['REQUEST_TIME'] + (60 * 60 * 24)); $this->aliasManager->writeCache(); } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index 48b394e..619d8cc 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -694,7 +694,7 @@ public function testRenderCacheMaxAge($max_age, $is_render_cached, $render_cache public function providerTestRenderCacheMaxAge() { return [ [0, FALSE, NULL], - [60, TRUE, (int) $_SERVER['REQUEST_TIME'] + 60], + [60, TRUE, $_SERVER['REQUEST_TIME'] + 60], [Cache::PERMANENT, TRUE, -1], ]; } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php index 199d170..d445792 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php @@ -226,7 +226,7 @@ protected function setupMemoryCache() { protected function setUpRequest($method = 'GET') { $request = Request::create('/', $method); // Ensure that the request time is set as expected. - $request->server->set('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']); + $request->server->set('REQUEST_TIME', $_SERVER['REQUEST_TIME']); $this->requestStack->push($request); }