diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php
index af48c1f..e67453d 100644
--- a/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php
+++ b/core/modules/system/lib/Drupal/system/Controller/SystemInfoController.php
@@ -53,7 +53,11 @@ public function __construct(SystemManager $systemManager) {
   public function status() {
     $requirements = $this->systemManager->listRequirements();
     $this->systemManager->fixAnonymousUid();
-    return theme('status_report', array('requirements' => $requirements));
+    $status_report = array(
+      '#theme' => 'status_report',
+      '#requirements' => $requirements,
+    );
+    return drupal_render($status_report);
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php
index 7edd34b..710034a 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemPoweredByBlock.php
@@ -26,9 +26,7 @@ class SystemPoweredByBlock extends BlockBase {
    * {@inheritdoc}
    */
   public function build() {
-    return array(
-      '#children' => theme('system_powered_by'),
-    );
+    return array('#theme' => 'system_powered_by');
   }
 
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
index 1cea46a..e9748e5 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
@@ -25,9 +25,13 @@ public static function getInfo() {
    * Tableheader.js provides 'sticky' table headers, and is included by default.
    */
   function testThemeTableStickyHeaders() {
-    $header = array('one', 'two', 'three');
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
-    $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => TRUE));
+    $table = array(
+      '#theme' => 'table',
+      '#header' => array('one', 'two', 'three'),
+      '#rows' => array(array(1,2,3), array(4,5,6), array(7,8,9)),
+      '#sticky' => TRUE,
+    );
+    $this->content = drupal_render($table);
     $js = drupal_add_js();
     $this->assertTrue(isset($js['core/misc/tableheader.js']), 'tableheader.js was included when $sticky = TRUE.');
     $this->assertRaw('sticky-enabled',  'Table has a class of sticky-enabled when $sticky = TRUE.');
@@ -38,12 +42,16 @@ function testThemeTableStickyHeaders() {
    * If $sticky is FALSE, no tableheader.js should be included.
    */
   function testThemeTableNoStickyHeaders() {
-    $header = array('one', 'two', 'three');
-    $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
-    $attributes = array();
-    $caption = NULL;
-    $colgroups = array();
-    $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE));
+    $table = array(
+      '#theme' => 'table',
+      '#header' => array('one', 'two', 'three'),
+      '#rows' => array(array(1,2,3), array(4,5,6), array(7,8,9)),
+      '#attributes' => array(),
+      '#caption' => NULL,
+      '#colgroups' => array(),
+      '#sticky' => FALSE,
+    );
+    $this->content = drupal_render($table);
     $js = drupal_add_js();
     $this->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js was not included because $sticky = FALSE.');
     $this->assertNoRaw('sticky-enabled',  'Table does not have a class of sticky-enabled because $sticky = FALSE.');
@@ -62,7 +70,13 @@ function testThemeTableWithEmptyMessage() {
         'colspan' => 2,
       ),
     );
-    $this->content = theme('table', array('header' => $header, 'rows' => array(), 'empty' => t('No strings available.')));
+    $table = array(
+      '#theme' => 'table',
+      '#header' => $header,
+      '#rows' => array(),
+      '#empty' => t('No strings available.'),
+    );
+    $this->content = drupal_render($table);
     $this->assertRaw('<tr class="odd"><td colspan="3" class="empty message">No strings available.</td>', 'Correct colspan was set on empty message.');
     $this->assertRaw('<thead><tr><th>Header 1</th>', 'Table header was printed.');
   }
@@ -77,7 +91,11 @@ function testThemeTableWithNoStriping() {
         'no_striping' => TRUE,
       ),
     );
-    $this->content = theme('table', array('rows' => $rows));
+    $table = array(
+      '#theme' => 'table',
+      '#rows' => $rows,
+    );
+    $this->content = drupal_render($table);
     $this->assertNoRaw('class="odd"', 'Odd/even classes were not added because $no_striping = TRUE.');
     $this->assertNoRaw('no_striping', 'No invalid no_striping HTML attribute was printed.');
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
index f10d83d..2def866 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
@@ -41,7 +41,7 @@ function setUp() {
    * Render arrays that use a render element and templates (and hence call
    * template_preprocess()) must ensure the attributes at different occassions
    * are all merged correctly:
-   *   - $variables['attributes'] as passed in to theme()
+   *   - $variables['attributes'] as passed in to drupal_render()
    *   - the render element's #attributes
    *   - any attributes set in the template's preprocessing function
    */
@@ -204,44 +204,47 @@ function testThemeGetSetting() {
    * Ensures the theme registry is rebuilt when modules are disabled/enabled.
    */
   function testRegistryRebuild() {
-    $this->assertIdentical(theme('theme_test_foo', array('foo' => 'a')), 'a', 'The theme registry contains theme_test_foo.');
+    $theme_test_foo = array('#theme' => 'theme_test_foo', '#foo' => 'a');
+    $this->assertIdentical(drupal_render($theme_test_foo), 'a', 'The theme registry contains theme_test_foo.');
 
     module_disable(array('theme_test'), FALSE);
     // After enabling/disabling a module during a test, we need to rebuild the
-    // container and ensure the extension handler is loaded, otherwise theme()
-    // throws an exception.
+    // container and ensure the extension handler is loaded, otherwise
+    // drupal_render() throws an exception.
     $this->rebuildContainer();
     $this->container->get('module_handler')->loadAll();
-    $this->assertIdentical(theme('theme_test_foo', array('foo' => 'b')), FALSE, 'The theme registry does not contain theme_test_foo, because the module is disabled.');
+    $theme_test_foo = array('#theme' => 'theme_test_foo', '#foo' => 'b');
+    $this->assertIdentical(drupal_render($theme_test_foo), '', 'The theme registry does not contain theme_test_foo, because the module is disabled.');
 
     module_enable(array('theme_test'), FALSE);
     // After enabling/disabling a module during a test, we need to rebuild the
-    // container and ensure the extension handler is loaded, otherwise theme()
-    // throws an exception.
+    // container and ensure the extension handler is loaded, otherwise
+    // drupal_render() throws an exception.
     $this->rebuildContainer();
     $this->container->get('module_handler')->loadAll();
-    $this->assertIdentical(theme('theme_test_foo', array('foo' => 'c')), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.');
+    $theme_test_foo = array('#theme' => 'theme_test_foo', '#foo' => 'c');
+    $this->assertIdentical(drupal_render($theme_test_foo), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.');
   }
 
   /**
    * Tests child element rendering for 'render element' theme hooks.
    */
   function testDrupalRenderChildren() {
-    $element = array(
+    $theme_test_render_element_children = array(
       '#theme' => 'theme_test_render_element_children',
       'child' => array(
         '#markup' => 'Foo',
       ),
     );
-    $this->assertIdentical(theme('theme_test_render_element_children', $element), 'Foo', 'drupal_render() avoids #theme recursion loop when rendering a render element.');
+    $this->assertIdentical(drupal_render($theme_test_render_element_children), 'Foo', 'drupal_render() avoids #theme recursion loop when rendering a render element.');
 
-    $element = array(
+    $theme_test_render_element_children = array(
       '#theme_wrappers' => array('theme_test_render_element_children'),
       'child' => array(
         '#markup' => 'Foo',
       ),
     );
-    $this->assertIdentical(theme('theme_test_render_element_children', $element), 'Foo', 'drupal_render() avoids #theme_wrappers recursion loop when rendering a render element.');
+    $this->assertIdentical(drupal_render($theme_test_render_element_children), 'Foo', 'drupal_render() avoids #theme_wrappers recursion loop when rendering a render element.');
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
index 38e183b..94c8238 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
@@ -52,7 +52,8 @@ function testTwigDebugMarkup() {
 
     // Create a node and test different features of the debug markup.
     $node = $this->drupalCreateNode();
-    $output = theme('node', node_view($node));
+    $node_view = node_view($node);
+    $output = drupal_render($node_view);
     $this->assertTrue(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup found in theme output when debug is enabled.');
     $this->assertTrue(strpos($output, "CALL: theme('node')") !== FALSE, 'Theme call information found.');
     $this->assertTrue(strpos($output, 'x node--1' . $extension) !== FALSE, 'Node ID specific template shown as current template.');
@@ -63,7 +64,8 @@ function testTwigDebugMarkup() {
     // Create another node and make sure the template suggestions shown in the
     // debug markup are correct.
     $node2 = $this->drupalCreateNode();
-    $output = theme('node', node_view($node2));
+    $node_view2 = node_view($node2);
+    $output = drupal_render($node_view2);
     $this->assertTrue(strpos($output, '* node--2' . $extension) !== FALSE, 'Node ID specific template suggestion found.');
     $this->assertTrue(strpos($output, 'x node' . $extension) !== FALSE, 'Base template file shown as current template.');
 
@@ -72,7 +74,8 @@ function testTwigDebugMarkup() {
     $this->rebuildContainer();
     $this->resetAll();
 
-    $output = theme('node', node_view($node));
+    $node_view = node_view($node);
+    $output = drupal_render($node_view);
     $this->assertFalse(strpos($output, '<!-- THEME DEBUG -->') !== FALSE, 'Twig debug markup not found in theme output when debug is disabled.');
   }
 
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index a5bb0f1..59dca72 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -45,8 +45,11 @@ function system_admin_config_page() {
           unset($item['localized_options']['attributes']['title']);
         }
         $block = $item;
-        $block['content'] = '';
-        $block['content'] .= theme('admin_block_content', array('content' => system_admin_menu_block($item)));
+        $admin_block_content = array(
+          '#theme' => 'admin_block_content',
+          '#content' => system_admin_menu_block($item),
+        );
+        $block['content'] = drupal_render($admin_block_content);
         if (!empty($block['content'])) {
           $block['show'] = TRUE;
         }
@@ -59,7 +62,11 @@ function system_admin_config_page() {
   }
   if ($blocks) {
     ksort($blocks);
-    return theme('admin_page', array('blocks' => $blocks));
+    $admin_page = array(
+      '#theme' => 'admin_page',
+      '#blocks' => $blocks,
+    );
+    return drupal_render($admin_page);
   }
   else {
     return t('You do not have any administrative items.');
@@ -79,8 +86,9 @@ function system_admin_config_page() {
  */
 function system_admin_menu_block_page() {
   $item = menu_get_item();
-  if ($content = system_admin_menu_block($item)) {
-    $output = theme('admin_block_content', array('content' => $content));
+  $admin_block_content = array('#theme' => 'admin_block_content');
+  if ($admin_block_content['#content'] = system_admin_menu_block($item)) {
+    $output = drupal_render($admin_block_content);
   }
   else {
     $output = t('You do not have any administrative items.');
@@ -215,7 +223,12 @@ function system_themes_page() {
   drupal_alter('system_themes_page', $theme_groups);
 
   $admin_form = drupal_get_form('system_themes_admin_form', $admin_theme_options);
-  return theme('system_themes_page', array('theme_groups' => $theme_groups, 'theme_group_titles' => $theme_group_titles)) . drupal_render($admin_form);
+  $system_themes_page = array(
+    '#theme' => 'system_themes_page',
+    '#theme_groups' => $theme_groups,
+    '#theme_group_titles' => $theme_group_titles,
+  );
+  return drupal_render($system_themes_page) . drupal_render($admin_form);
 }
 
 /**
@@ -614,9 +627,15 @@ function _system_modules_build_row($info, $extra) {
   }
   else {
     $form['enable'] = array(
-      '#markup' =>  theme('image', array('uri' => 'core/misc/watchdog-error.png', 'alt' => $status_short, 'title' => $status_short)),
+      '#theme' => 'image',
+      '#uri' => 'core/misc/watchdog-error.png',
+      '#alt' => $status_short,
+      '#title' => $status_short,
+    );
+    $form['description']['system_modules_incompatible'] = array(
+      '#theme' => 'system_modules_incompatible',
+      '#message' => $status_long,
     );
-    $form['description']['#markup'] .= theme('system_modules_incompatible', array('message' => $status_long));
   }
 
   // Build operation links.
@@ -983,7 +1002,11 @@ function theme_admin_page($variables) {
   $container = array();
 
   foreach ($blocks as $block) {
-    if ($block_output = theme('admin_block', array('block' => $block))) {
+    $admin_block = array(
+      '#theme' => 'admin_block',
+      '#block' => $block,
+    );
+    if ($block_output = drupal_render($admin_block)) {
       if (empty($block['position'])) {
         // perform automatic striping.
         $block['position'] = ++$stripe % 2 ? 'left' : 'right';
@@ -995,8 +1018,9 @@ function theme_admin_page($variables) {
     }
   }
 
+  $system_compact_link = array('#theme' => 'system_compact_link');
   $output = '<div class="admin clearfix">';
-  $output .= theme('system_compact_link');
+  $output .= drupal_render($system_compact_link);
 
   foreach ($container as $id => $data) {
     $output .= '<div class="' . $id . ' clearfix">';
@@ -1030,13 +1054,21 @@ function theme_system_admin_index($variables) {
 
     // Output links.
     if (count($items)) {
+      $admin_block_content = array(
+        '#theme' => 'admin_block_content',
+        '#content' => $items,
+      );
       $block = array();
       $block['title'] = $module;
-      $block['content'] = theme('admin_block_content', array('content' => $items));
+      $block['content'] = drupal_render($admin_block_content);
       $block['description'] = t($description);
       $block['show'] = TRUE;
 
-      if ($block_output = theme('admin_block', array('block' => $block))) {
+      $admin_block = array(
+        '#theme' => 'admin_block',
+        '#block' => $block,
+      );
+      if ($block_output = drupal_render($admin_block)) {
         if (!isset($block['position'])) {
           // Perform automatic striping.
           $block['position'] = $position;
@@ -1047,8 +1079,9 @@ function theme_system_admin_index($variables) {
     }
   }
 
+  $system_compact_link = array('#theme' => 'system_compact_link');
   $output = '<div class="admin clearfix">';
-  $output .= theme('system_compact_link');
+  $output .= drupal_render($system_compact_link);
   foreach ($container as $id => $data) {
     $output .= '<div class="' . $id . ' clearfix">';
     $output .= $data;
@@ -1198,7 +1231,12 @@ function theme_system_modules_details($variables) {
     $rows[] = $row;
   }
 
-  return theme('table', array('header' => $form['#header'], 'rows' => $rows));
+  $table = array(
+    '#theme' => 'table',
+    '#header' => $form['#header'],
+    '#rows' => $rows,
+  );
+  return drupal_render($table);
 }
 
 /**
@@ -1257,7 +1295,13 @@ function theme_system_modules_uninstall($variables) {
     );
   }
 
-  $output  = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No modules are available to uninstall.')));
+  $table = array(
+    '#theme' => 'table',
+    '#header' => $header,
+    '#rows' => $rows,
+    '#empty' => t('No modules are available to uninstall.'),
+  );
+  $output  = drupal_render($table);
   $output .= drupal_render_children($form);
 
   return $output;
@@ -1269,6 +1313,7 @@ function theme_system_modules_uninstall($variables) {
  * @param $variables
  *   An associative array containing:
  *   - theme_groups: An associative array containing groups of themes.
+ *   - theme_group_titles: An associative array containing titles of themes.
  *
  * @ingroup themeable
  */
@@ -1376,7 +1421,12 @@ function system_date_format_language_overview_page() {
     $rows[] = $row;
   }
 
-  return theme('table', array('header' => $header, 'rows' => $rows));
+  $table = array(
+    '#theme' => 'table',
+    '#header' => $header,
+    '#rows' => $rows,
+  );
+  return drupal_render($table);
 }
 
 /**
@@ -1484,8 +1534,13 @@ function theme_system_date_format_localize_form($variables) {
     $rows[] = $row;
   }
 
+  $table = array(
+    '#theme' => 'table',
+    '#header' => $header,
+    '#rows' => $rows,
+  );
   $output = drupal_render($form['language']);
-  $output .= theme('table', array('header' => $header, 'rows' => $rows));
+  $output .= drupal_render($table);
   $output .= drupal_render_children($form);
 
   return $output;
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index a8dcd13..c92de4e 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -410,7 +410,8 @@ function hook_css_alter(&$css) {
  */
 function hook_ajax_render_alter($commands) {
   // Inject any new status messages into the content area.
-  $commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages'));
+  $status_messages = array('#theme' => 'status_messages');
+  $commands[] = ajax_command_prepend('#block-system-main .content', drupal_render($status_messages));
 }
 
 /**
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index d246507..008ec34 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -132,7 +132,11 @@ function system_requirements($phase) {
       '@system_requirements' => 'http://drupal.org/requirements',
     ));
 
-    $description .= theme('item_list', array('items' => $missing_extensions));
+    $item_list = array(
+      '#theme' => 'item_list',
+      '#items' => $missing_extensions,
+    );
+    $description .= drupal_render($item_list);
 
     $requirements['php_extensions']['value'] = t('Disabled');
     $requirements['php_extensions']['severity'] = REQUIREMENT_ERROR;
@@ -247,7 +251,11 @@ function system_requirements($phase) {
         $description = $conf_errors[0];
       }
       else {
-        $description = theme('item_list', array('items' => $conf_errors));
+        $item_list = array(
+          '#theme' => 'item_list',
+          '#items' => $conf_errors,
+        );
+        $description = drupal_render($item_list);
       }
       $requirements['settings.php'] = array(
         'value' => t('Not protected'),
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index c15f95d..1f19d7d 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -139,7 +139,10 @@ function system_help($path, $arg) {
 function system_theme() {
   return array_merge(drupal_common_theme(), array(
     'system_themes_page' => array(
-      'variables' => array('theme_groups' => NULL),
+      'variables' => array(
+        'theme_groups' => NULL,
+        'theme_group_titles' => NULL,
+      ),
       'file' => 'system.admin.inc',
     ),
     'system_config_form' => array(
@@ -3431,7 +3434,12 @@ function theme_exposed_filters($variables) {
     foreach (element_children($form['current']) as $key) {
       $items[] = $form['current'][$key];
     }
-    $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters'))));
+    $item_list = array(
+      '#theme' => 'item_list',
+      '#items' => $items,
+      '#attributes' => array('class' => array('clearfix', 'current-filters')),
+    );
+    $output .= drupal_render($item_list);
   }
 
   $output .= drupal_render_children($form);
diff --git a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php
index bea8b13..3bfe755 100644
--- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php
+++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php
@@ -34,7 +34,12 @@ public function onRequest(GetResponseEvent $event) {
       // theme_test_request_listener_page_callback() to test that even when the
       // theme system is initialized this early, it is still capable of
       // returning output and theming the page as a whole.
-      $GLOBALS['theme_test_output'] = theme('more_link', array('url' => 'user', 'title' => 'Themed output generated in a KernelEvents::REQUEST listener'));
+      $more_link = array(
+        '#theme' => 'more_link',
+        '#url' => 'user',
+        '#title' => 'Themed output generated in a KernelEvents::REQUEST listener',
+      );
+      $GLOBALS['theme_test_output'] = drupal_render($more_link);
     }
     if (strpos($current_path, 'user/autocomplete') === 0) {
       // Register a fake registry loading callback. If it gets called by
diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module
index 51cb6d3..13a0243 100644
--- a/core/modules/system/tests/modules/theme_test/theme_test.module
+++ b/core/modules/system/tests/modules/theme_test/theme_test.module
@@ -9,9 +9,11 @@ function theme_test_theme($existing, $type, $theme, $path) {
     'variables' => array('foo' => ''),
   );
   $items['theme_test_template_test'] = array(
+    'variables' => array(),
     'template' => 'theme_test.template_test',
   );
   $items['theme_test_template_test_2'] = array(
+    'variables' => array(),
     'template' => 'theme_test.template_test',
   );
   $items['theme_test_foo'] = array(
@@ -100,7 +102,8 @@ function theme_test_request_listener_page_callback() {
  * Menu callback for testing template overridding based on filename.
  */
 function theme_test_template_test_page_callback() {
-  return theme('theme_test_template_test');
+  $theme_test_template_test = array('#theme' => 'theme_test_template_test');
+  return drupal_render($theme_test_template_test);
 }
 
 /**
@@ -146,7 +149,8 @@ function _theme_test_alter() {
  * Page callback, calls a theme hook suggestion.
  */
 function _theme_test_suggestion() {
-  return theme(array('theme_test__suggestion', 'theme_test'), array());
+  $theme_test = array('#theme' => array('theme_test__suggestion', 'theme_test'));
+  return drupal_render($theme_test);
 }
 
 /**
diff --git a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
index ef5fb70..5299481 100644
--- a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
+++ b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
@@ -26,7 +26,8 @@ public static function create(ContainerInterface $container) {
    * Menu callback for testing PHP variables in a Twig template.
    */
   public function phpVariablesRender() {
-    return theme('twig_theme_test_php_variables');
+    $twig_theme_test_php_variables = array('#theme' => 'twig_theme_test_php_variables');
+    return drupal_render($twig_theme_test_php_variables);
   }
 
 }
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
index 2ca2cd0..9a3c4eb 100644
--- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
+++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
@@ -5,6 +5,7 @@
  */
 function twig_theme_test_theme($existing, $type, $theme, $path) {
   $items['twig_theme_test_php_variables'] = array(
+    'variables' => array(),
     'template' => 'twig_theme_test.php_variables',
   );
   return $items;
diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php
index aedc6b0..169e1aa 100644
--- a/core/modules/system/theme.api.php
+++ b/core/modules/system/theme.api.php
@@ -186,7 +186,13 @@ function hook_process(&$variables, $hook) {
         'variable_name' => $variable_name,
         'variables' => $variables,
       );
-      $variables[$variable_name] = theme('rdf_template_variable_wrapper', array('content' => $variables[$variable_name], 'attributes' => $attributes, 'context' => $context));
+      $rdf_template_variable_wrapper = array(
+        '#theme' => 'rdf_template_variable_manager',
+        '#content' => $variables[$variable_name],
+        '#attributes' => $attributes,
+        '#context' => $context,
+      );
+      $variables[$variable_name] = drupal_render($rdf_template_variable_wrapper);
     }
   }
 }
