Skip to content
This repository

Fix for Renderer::_render() with no set $request property. #624

Closed
wants to merge 1 commit into from

3 participants

Mike Greiling Don't Add Me To Your Organization a.k.a The Travis Bot Nate Abele
Mike Greiling

Quick fix in the renderer class for instances when $_request is null. I encountered this when attaching my own error handler method which was not attached to Dispatch::run() as the example error handler is, and thus the request object was not available.

My error template called $this->_render() to include a template element and this raised an ErrorException "Trying to get property of non-object in [...]/Projects/Lithium/dev/li3_core/libraries/lithium/template/view/Renderer.php on line 490";

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged 6387beb into c3419a4).

Nate Abele
Owner

Looks good. Once we get a test case and this is submitted against the dev branch, we'll get it merged in.

Nate Abele
Owner

Merged to dev in 51d1770

Mike Greiling

sorry, got a little busy. I see this had been merged now, do you still need a test case for this?

Nate Abele
Owner

No, it's fine. @mehlah is actually rewriting the affected code not to rely on $_request.

Mehdi Lahmam mehlah referenced this pull request
Closed

Renderer options #642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 03, 2012
Mike Greiling mikegreiling Fix for unset `_request` property when calling `_render()` 6387beb
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. +4 2 template/view/Renderer.php
6 template/view/Renderer.php
@@ -486,8 +486,10 @@ public function set(array $data = array()) {
486 486 * @return string Returns a the rendered template content as a string.
487 487 */
488 488 protected function _render($type, $template, array $data = array(), array $options = array()) {
489   - $library = $this->_request->library;
490   - $options += compact('library');
  489 + if ($this->_request) {
  490 + $library = $this->_request->library;
  491 + $options += compact('library');
  492 + }
491 493 return $this->_view->render($type, $data + $this->_data, compact('template') + $options);
492 494 }
493 495 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.