.../Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php | 2 +- core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php | 2 +- core/modules/editor/src/Form/EditorImageDialog.php | 2 +- core/modules/editor/src/Form/EditorLinkDialog.php | 2 +- .../file/src/Controller/FileWidgetAjaxController.php | 14 +++++++------- core/modules/quickedit/src/QuickEditController.php | 6 +++--- core/modules/simpletest/src/KernelTestBase.php | 2 +- core/modules/system/core.api.php | 2 +- core/modules/system/form.api.php | 4 ++-- .../system/src/Plugin/Block/SystemPageMessagesBlock.php | 3 ++- core/modules/system/src/Tests/Theme/MessageTest.php | 2 +- core/modules/views/src/Plugin/views/area/Messages.php | 2 +- .../views/tests/src/Unit/Plugin/area/MessagesTest.php | 4 ++-- core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php | 6 +++--- 14 files changed, 27 insertions(+), 26 deletions(-) diff --git a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php index e3f31b9..fe117e1 100644 --- a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php +++ b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php @@ -35,7 +35,7 @@ protected function getRenderedContent() { $this->attachedAssets = new AttachedAssets(); if (is_array($this->content)) { - $html = \Drupal::service('renderer')->render($this->content); + $html = \Drupal::service('renderer')->renderRoot($this->content); $this->attachedAssets = AttachedAssets::createFromRenderArray($this->content); return $html; } diff --git a/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php b/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php index 6cddc0c..6900b6e 100644 --- a/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php @@ -71,7 +71,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // replace the element making the Ajax call. The default 'replaceWith' // behavior can be changed with #ajax['method']. $response->addCommand(new InsertCommand(NULL, $html)); - $status_messages = array('#theme' => 'status_messages'); + $status_messages = array('#type' => 'status_messages'); $output = $this->drupalRenderRoot($status_messages); if (!empty($output)) { $response->addCommand(new PrependCommand(NULL, $output)); diff --git a/core/modules/editor/src/Form/EditorImageDialog.php b/core/modules/editor/src/Form/EditorImageDialog.php index e3d592a..b2fed13 100644 --- a/core/modules/editor/src/Form/EditorImageDialog.php +++ b/core/modules/editor/src/Form/EditorImageDialog.php @@ -227,7 +227,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getErrors()) { unset($form['#prefix'], $form['#suffix']); $form['status_messages'] = [ - '#theme' => 'status_messages', + '#type' => 'status_messages', '#weight' => -10, ]; $response->addCommand(new HtmlCommand('#editor-image-dialog-form', $form)); diff --git a/core/modules/editor/src/Form/EditorLinkDialog.php b/core/modules/editor/src/Form/EditorLinkDialog.php index feb1d1f..c576389 100644 --- a/core/modules/editor/src/Form/EditorLinkDialog.php +++ b/core/modules/editor/src/Form/EditorLinkDialog.php @@ -86,7 +86,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getErrors()) { unset($form['#prefix'], $form['#suffix']); $form['status_messages'] = [ - '#theme' => 'status_messages', + '#type' => 'status_messages', '#weight' => -10, ]; $response->addCommand(new HtmlCommand('#editor-link-dialog-form', $form)); diff --git a/core/modules/file/src/Controller/FileWidgetAjaxController.php b/core/modules/file/src/Controller/FileWidgetAjaxController.php index e449caf..9b75801 100644 --- a/core/modules/file/src/Controller/FileWidgetAjaxController.php +++ b/core/modules/file/src/Controller/FileWidgetAjaxController.php @@ -38,8 +38,8 @@ public function upload(Request $request) { // Invalid request. drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error'); $response = new AjaxResponse(); - $status_messages = array('#theme' => 'status_messages'); - return $response->addCommand(new ReplaceCommand(NULL, drupal_render($status_messages))); + $status_messages = array('#type' => 'status_messages'); + return $response->addCommand(new ReplaceCommand(NULL, drupal_render_root($status_messages))); } try { @@ -53,8 +53,8 @@ public function upload(Request $request) { // Invalid form_build_id. drupal_set_message(t('An unrecoverable error occurred. Use of this form has expired. Try reloading the page and submitting again.'), 'error'); $response = new AjaxResponse(); - $status_messages = array('#theme' => 'status_messages'); - return $response->addCommand(new ReplaceCommand(NULL, drupal_render($status_messages))); + $status_messages = array('#type' => 'status_messages'); + return $response->addCommand(new ReplaceCommand(NULL, drupal_render_root($status_messages))); } // Get the current element and count the number of files. @@ -76,9 +76,9 @@ public function upload(Request $request) { $form['#suffix'] .= ''; } - $status_messages = array('#theme' => 'status_messages'); - $form['#prefix'] .= drupal_render($status_messages); - $output = drupal_render($form); + $status_messages = array('#type' => 'status_messages'); + $form['#prefix'] .= drupal_render_root($status_messages); + $output = drupal_render_root($form); $response = new AjaxResponse(); $response->setAttachments($form['#attached']); diff --git a/core/modules/quickedit/src/QuickEditController.php b/core/modules/quickedit/src/QuickEditController.php index 3747609..45b0561 100644 --- a/core/modules/quickedit/src/QuickEditController.php +++ b/core/modules/quickedit/src/QuickEditController.php @@ -204,7 +204,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view $response->addCommand(new FieldFormSavedCommand($output, $other_view_modes)); } else { - $output = drupal_render($form); + $output = drupal_render_root($form); // When working with a hidden form, we don't want its CSS/JS to be loaded. if ($request->request->get('nocssjs') !== 'true') { $response->setAttachments($form['#attached']); @@ -214,9 +214,9 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view $errors = $form_state->getErrors(); if (count($errors)) { $status_messages = array( - '#theme' => 'status_messages' + '#type' => 'status_messages' ); - $response->addCommand(new FieldFormValidationErrorsCommand(drupal_render($status_messages))); + $response->addCommand(new FieldFormValidationErrorsCommand(drupal_render_root($status_messages))); } } diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php index 89930ad..14b839b 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -560,7 +560,7 @@ protected function registerStreamWrapper($scheme, $class, $type = StreamWrapperI * The rendered string output (typically HTML). */ protected function render(array &$elements) { - $content = drupal_render($elements); + $content = $this->container->get('renderer')->renderRoot($elements); drupal_process_attached($elements); $this->setRawContent($content); $this->verbose('
' . String::checkPlain($content));
diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php
index 407e439..090d914 100644
--- a/core/modules/system/core.api.php
+++ b/core/modules/system/core.api.php
@@ -1991,7 +1991,7 @@ function hook_display_variant_plugin_alter(array &$definitions) {
  * 'wrapper' method and return HTML markup. This is not the case if you return
  * commands, but if you would like to show status messages, you can add
  * @code
- * array('#theme' => 'status_messages')
+ * array('#type' => 'status_messages')
  * @endcode
  * to a render array, use drupal_render() to render it, and add a command to
  * place the messages in an appropriate location.
diff --git a/core/modules/system/form.api.php b/core/modules/system/form.api.php
index 9ec09e0..bd75ee0 100644
--- a/core/modules/system/form.api.php
+++ b/core/modules/system/form.api.php
@@ -153,8 +153,8 @@ function callback_batch_finished($success, $results, $operations) {
  */
 function hook_ajax_render_alter(array &$data) {
   // Inject any new status messages into the content area.
-  $status_messages = array('#theme' => 'status_messages');
-  $command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', drupal_render($status_messages));
+  $status_messages = array('#type' => 'status_messages');
+  $command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', drupal_render_root($status_messages));
   $data[] = $command->render();
 }
 
diff --git a/core/modules/system/src/Plugin/Block/SystemPageMessagesBlock.php b/core/modules/system/src/Plugin/Block/SystemPageMessagesBlock.php
index e317820..5fdc4a1 100644
--- a/core/modules/system/src/Plugin/Block/SystemPageMessagesBlock.php
+++ b/core/modules/system/src/Plugin/Block/SystemPageMessagesBlock.php
@@ -10,6 +10,7 @@
 use Drupal\Component\Utility\Crypt;
 use Drupal\Core\Block\BlockBase;
 use Drupal\Core\Block\MessagesBlockPluginInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Site\Settings;
 
@@ -47,7 +48,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
 
     // @see ::isCacheable()
     $form['cache']['#description'] = $this->t('This block is cacheable forever, it is not configurable.');
-    $form['cache']['max_age']['#value'] = -1;
+    $form['cache']['max_age']['#value'] = Cache::PERMANENT;
     $form['cache']['max_age']['#disabled'] = TRUE;
     // Don't allow cache contexts to be configured, this block is globally
     // cacheable.
diff --git a/core/modules/system/src/Tests/Theme/MessageTest.php b/core/modules/system/src/Tests/Theme/MessageTest.php
index 3e8da82..db27d2a 100644
--- a/core/modules/system/src/Tests/Theme/MessageTest.php
+++ b/core/modules/system/src/Tests/Theme/MessageTest.php
@@ -32,7 +32,7 @@ function testMessages() {
     drupal_set_message('An error occurred', 'error');
     drupal_set_message('But then something nice happened');
     $messages = array(
-      '#theme' => 'status_messages',
+      '#type' => 'status_messages',
     );
     $this->render($messages);
     $this->assertRaw('messages messages--error');
diff --git a/core/modules/views/src/Plugin/views/area/Messages.php b/core/modules/views/src/Plugin/views/area/Messages.php
index e00739f..56bd4e4 100644
--- a/core/modules/views/src/Plugin/views/area/Messages.php
+++ b/core/modules/views/src/Plugin/views/area/Messages.php
@@ -32,7 +32,7 @@ protected function defineOptions() {
   public function render($empty = FALSE) {
     if (!$empty || !empty($this->options['empty'])) {
       return array(
-        '#theme' => 'status_messages',
+        '#type' => 'status_messages',
       );
     }
     return array();
diff --git a/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php b/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php
index 6380021..3c18e79 100644
--- a/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/area/MessagesTest.php
@@ -48,13 +48,13 @@ protected function setUp() {
   public function testRender() {
     // The handler is configured to show with empty views by default, so should
     // appear.
-    $this->assertSame(array('#theme' => 'status_messages'), $this->messagesHandler->render());
+    $this->assertSame(array('#type' => 'status_messages'), $this->messagesHandler->render());
 
     // Turn empty off, and make sure it isn't rendered.
     $this->messagesHandler->options['empty'] = FALSE;
     // $empty parameter passed to render will still be FALSE, so should still
     // appear.
-    $this->assertSame(array('#theme' => 'status_messages'), $this->messagesHandler->render());
+    $this->assertSame(array('#type' => 'status_messages'), $this->messagesHandler->render());
     // Should now be empty as both the empty option and parameter are empty.
     $this->assertSame(array(), $this->messagesHandler->render(TRUE));
   }
diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
index 6dd609e..4c161da 100644
--- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
+++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
@@ -203,7 +203,7 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state)
     $form_state->disableCache();
 
     $form = \Drupal::formBuilder()->buildForm($form_class, $form_state);
-    $output = drupal_render($form);
+    $output = drupal_render_root($form);
     drupal_process_attached($form);
 
     // These forms have the title built in, so set the title here:
@@ -220,8 +220,8 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state)
       $response->setAttachments($form['#attached']);
 
       $display = '';
-      $status_messages = array('#theme' => 'status_messages');
-      if ($messages = drupal_render($status_messages)) {
+      $status_messages = array('#type' => 'status_messages');
+      if ($messages = drupal_render_root($status_messages)) {
         $display = '
' . $messages . '
'; } $display .= $output;