diff --git a/core/lib/Drupal/Core/Render/Render.php b/core/lib/Drupal/Core/Render/Render.php index 168d3e9..eef825b 100644 --- a/core/lib/Drupal/Core/Render/Render.php +++ b/core/lib/Drupal/Core/Render/Render.php @@ -445,8 +445,7 @@ protected static function getCachePlaceholder($callback, array $context, $token) * * @return string */ - protected static function preRenderCachePlaceholder(array $element) { - protected static function generateCacheToken() { + public static function generateCacheToken() { return Crypt::randomBytesBase64(55); } @@ -497,7 +496,7 @@ protected static function processPostRenderCache(array &$elements) { * drupal_render()ed). On top of that, the theme system transforms render arrays * into HTML strings. These two facts combined imply that it is impossible for * #post_render_cache callbacks to bubble up to the root of the render array. - * Therefore, collectPostRenderCache() must be called *before* + * Therefore, Render::collectPostRenderCache() must be called *before* * #theme callbacks, so that it has a chance to examine the full render array. * In short: in order to examine the full render array for #post_render_cache * callbacks, it must use post-order tree traversal, whereas drupal_render() diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index 02e427f..3584bbb 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -17,6 +17,7 @@ use Drupal\entity\Entity\EntityViewDisplay; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManagerInterface; +use Drupal\Core\Render\Render; use Drupal\field\FieldInfo; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -132,7 +133,7 @@ public function buildComponents(array &$build, array $entities, array $displays, 'commented_entity_type' => $commented_entity->getEntityTypeId(), 'commented_entity_id' => $commented_entity->id(), 'in_preview' => !empty($entity->in_preview), - 'token' => drupal_render_cache_generate_token(), + 'token' => Render::generateCacheToken(), ); $build[$id]['links'] = array( '#post_render_cache' => array( diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index 19dd00f..0e46fee 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -15,6 +15,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Render\Render; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -181,7 +182,7 @@ public function viewElements(FieldItemListInterface $items) { 'entity_type' => $entity->getEntityTypeId(), 'entity_id' => $entity->id(), 'field_name' => $field_name, - 'token' => drupal_render_cache_generate_token(), + 'token' => Render::generateCacheToken(), ); $output['comment_form'] = array( '#post_render_cache' => array( diff --git a/core/modules/node/lib/Drupal/node/NodeViewBuilder.php b/core/modules/node/lib/Drupal/node/NodeViewBuilder.php index 494183f..7b936e1 100644 --- a/core/modules/node/lib/Drupal/node/NodeViewBuilder.php +++ b/core/modules/node/lib/Drupal/node/NodeViewBuilder.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityViewBuilder; +use Drupal\Core\Render\Render; /** * Render controller for nodes. @@ -40,7 +41,7 @@ public function buildComponents(array &$build, array $entities, array $displays, 'view_mode' => $view_mode, 'langcode' => $langcode, 'in_preview' => !empty($entity->in_preview), - 'token' => drupal_render_cache_generate_token(), + 'token' => Render::generateCacheToken(), ); $build[$id]['links'] = array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php index dea2332..e8f6818 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php @@ -772,7 +772,7 @@ function testDrupalRenderChildrenPostRenderCache() { function testDrupalRenderRenderCachePlaceholder() { $context = array( 'bar' => $this->randomContextValue(), - 'token' => drupal_render_cache_generate_token(), + 'token' => Render::generateCacheToken(), ); $callback = 'common_test_post_render_cache_placeholder'; $test_element = array( @@ -861,7 +861,7 @@ function testDrupalRenderChildElementRenderCachePlaceholder() { ); $context = array( 'bar' => $this->randomContextValue(), - 'token' => drupal_render_cache_generate_token(), + 'token' => Render::generateCacheToken(), ); $callback = 'common_test_post_render_cache_placeholder'; $test_element = array(