Parent issue: #2393329: Replace all drupal_render calls with the service, and inject it, if possible.

Problem/Motivation

drupal_render() was marked as deprecated, though its still called in quite some places.

Proposed resolution

While there are tons of documentation references to drupal_render(), the majority of actual usages are related to the render system itself.

The render system is being overhauled here: #2463009: Introduce CacheableResponseInterface: consolidate ways of setting X-Drupal-Cache-Tags/Contexts headers so I suggest that any changes related to the Renderer class or it's associates in the render system be left out of patches here.

  1. Avoid rendering manually by letting the template who is printing the variable render it.
  2. Inject the renderer service into service, which uses drupal_render()
  3. Use \Drupal::service('renderer')->render() for old prodecural code.

Remaining tasks

  1. Find all the actionable fixes: Search for drupal_render(
  2. Create a Patch
  3. Review

User interface changes

None

API changes

None

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because this removes usages of a deprecated function.
Issue priority Not critical because the function in question is not to be removed in this release cycle.

Comments

Mile23’s picture

See related issue here: #2463009: Introduce CacheableResponseInterface: consolidate ways of setting X-Drupal-Cache-Tags/Contexts headers. This issue is almost postponed on that one, but we can do some work here with the docblocks.

Mile23’s picture

Status: Postponed » Active
webchick’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Active » Closed (duplicate)

Thanks @willzyx for all your work on these! Unfortunately, these issues need to be postponed to 8.1.x at least. See the allowed beta changes policy and the comment in #2393329-39: Replace all drupal_render calls with the service, and inject it, if possible..

Mile23’s picture

Status: Closed (duplicate) » Postponed

I'm guessing you meant postponed.

webchick’s picture

Status: Postponed » Closed (duplicate)

No; the other piece if that is doing them all in one go rather than 50 sub-issues.