Commit 0e9bec38 authored by catch's avatar catch
Browse files

Issue #3037202 by claudiu.cristea, vsujeetkumar, Hardik_Patel_12, longwave,...

Issue #3037202 by claudiu.cristea, vsujeetkumar, Hardik_Patel_12, longwave, Berdir, martin107: Remove drupal_static() from node_mark()
parent bb02eb5f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
}
+3 −8
Original line number Diff line number Diff line
@@ -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;
+26 −0
Original line number Diff line number Diff line
<?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');
  }

}