diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 9ef9f6a553d66e785666efe44627836977993bdf..de9f4e7e02ba2b42b80f564163b058dae5107161 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -630,6 +630,10 @@ function drupal_static_reset($name = NULL) { @trigger_error("Using drupal_static_reset() with 'taxonomy_vocabulary_get_names' as parameter is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3039041", E_USER_DEPRECATED); break; + case 'node_mark': + @trigger_error("Calling drupal_static_reset() with 'node_mark' as argument is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3037203", E_USER_DEPRECATED); + break; + } drupal_static($name, NULL, TRUE); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 7a40ca534904c37236724302adc75f3a9f30cb1e..35176e5973a314e2cd8aa0a36779c582398345f7 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -187,19 +187,14 @@ function node_title_list(StatementInterface $result, $title = NULL) { * One of the MARK constants. */ function node_mark($nid, $timestamp) { - - $cache = &drupal_static(__FUNCTION__, []); - if (\Drupal::currentUser()->isAnonymous() || !\Drupal::moduleHandler()->moduleExists('history')) { return MARK_READ; } - if (!isset($cache[$nid])) { - $cache[$nid] = history_read($nid); - } - if ($cache[$nid] == 0 && $timestamp > HISTORY_READ_LIMIT) { + $read_timestamp = history_read($nid); + if ($read_timestamp === 0 && $timestamp > HISTORY_READ_LIMIT) { return MARK_NEW; } - elseif ($timestamp > $cache[$nid] && $timestamp > HISTORY_READ_LIMIT) { + elseif ($timestamp > $read_timestamp && $timestamp > HISTORY_READ_LIMIT) { return MARK_UPDATED; } return MARK_READ; diff --git a/core/modules/node/tests/src/Kernel/NodeDeprecationTest.php b/core/modules/node/tests/src/Kernel/NodeDeprecationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f00b7889714559ccbd15a295377281ef92ce31ac --- /dev/null +++ b/core/modules/node/tests/src/Kernel/NodeDeprecationTest.php @@ -0,0 +1,26 @@ +<?php + +namespace Drupal\Tests\node\Kernel; + +use Drupal\KernelTests\KernelTestBase; + +/** + * @group node + * @group legacy + */ +class NodeDeprecationTest extends KernelTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = ['node']; + + /** + * @see node_mark() + */ + public function testNodeMarkDeprecation() { + $this->expectDeprecation("Calling drupal_static_reset() with 'node_mark' as argument is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. There is no replacement for this usage. See https://www.drupal.org/node/3037203"); + drupal_static_reset('node_mark'); + } + +}