Problem/Motivation

Core has a tendency to add more and more preprocess variables and never remove them.

Steps to reproduce

Proposed resolution

Identify stale/crufty preprocess variables, and deprecate them in 11.1 for removal in Drupal 12. This should result in:

1. Less runtime code/smaller preprocess
2. Less verbose template documentation.
3. Less encouraging people to use things in templates they'd be better off doing another way.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

catch created an issue. See original summary.

catch’s picture

#3458183: Deprecate $variables['teaser'] got committed.

Opened #3458589: Deprecate $variables['page'] for node.html.twig and node_is_page().

I think we also have some node template variables that are documented but no longer exist:

 * - metadata: Metadata for this node.
 * - readmore: Flag for more state. Will be true if the teaser content of the
 *   node cannot hold the main body content.

readmore for example was added in 2004

commit 744405e3169a40d24da40b9f4b23769d91649fd0
Author: Dries Buytaert <dries@buytaert.net>
Date:   Sat Mar 6 10:57:53 2004 +0000

    - Patch 6140 by Goba: fix the 'read more'-link behavior.

Remove from node.tpl.php on November 7th 2012

commit b7f577a2a8182fabc1417b0a84ba6c756d21f319
Author: webchick <webchick@24967.no-reply.drupal.org>
Date:   Wed Nov 7 02:33:34 2012 -0800

    Issue #1810710 by Berdir, Fabianx: Remove copying of node properties wholesale into theme variables.

But added to node.html.twig on November 3rd 2012.

commit ee2acd68cca6ecfb2a1f3436c6adb593659489a8
Author: Dries <dries@buytaert.net>
Date:   Sat Nov 3 10:36:10 2012 -0700

    Issue #1696786 by Fabianx, jenlampton, stevector, steveoliver, jwilson3, amateescu, chx: Integrate Twig into core: Implementation issue.

Additionally these are set by template_preprocess and are not node specific, so can be removed from the docs.

 * - logged_in: Flag for authenticated user status. Will be true when the
 *   current user is a logged-in member.
 * - is_admin: Flag for admin user status. Will be true when the current user
 *   is an administrator.
catch’s picture

Status: Active » Needs work
catch’s picture

Status: Needs work » Active

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.