Ticket #612 (closed Bug: invalid)

Opened 6 months ago

Last modified 5 months ago

Profiler bug with Template_Controller

Reported by: Manuel Parente Owned by: Shadowhand
Priority: minor Milestone: 2.2
Component: Core Version: SVN HEAD
Keywords: Profiler Template_Controller Cc:

Description

When using Template_Controller with :

	// Default to no auto-rendering
	protected $auto_render = TRUE;

the Profiler will appear two time in every page due to:

	/**
	 * Adds event for adding the profile output to the page when displayed.
	 */
	public function __construct()
	{
		// Add profiler to page output automatically
		Event::add('system.display', array($this, 'render'));

		Log::add('debug', 'Profiler Library initialized');
	}

in the Profiler_Core class.

Easy to fix! :)

Change History

  Changed 6 months ago by Geert

  • status changed from new to closed
  • resolution set to invalid

I fail to see what is wrong with that code. It should work correctly. Note that the Template_Controller does not call Profiler in any way. If you are getting the Profiler displayed twice, you are calling new Profiler twice somewhere.

  Changed 6 months ago by Manuel Parente

  • status changed from closed to reopened
  • resolution deleted

Maybe I didn't explain in the best way.

The problem I found is that when I tell the template_controller to display the profiler in every page:

/**
* Website controller
*/
class Website_Controller extends Template_Controller
{
	function __construct()
	{
		parent::__construct();
		
		//Load site wide dependencies
		$this->database = new Database;
		$this->profiler = new Profiler;
	}
}

and set the template controller to auto_render, the profiler will display twice due to the fact that it is already automaticaly displaying.

The profiler will display once because I told it to do so, and again because it already atomatically displays it self.

So, I cannot set the template controller to auto_render and call the profiler, because it will render twice.

Note: I am only calling Profiler once in my website_controller that extends Template_controller.

Please check the constructor in the Profiler_Core, it is missing an if just to check if profiler is set to auto_render.

follow-up: ↓ 4   Changed 6 months ago by Shadowhand

There is not special relationship between Profiler and Template_Controller that would cause it render twice. If you load Profiler twice, then it displays twice.

I don't see a bug here.

in reply to: ↑ 3   Changed 6 months ago by Manuel Parente

Replying to Shadowhand:

There is not special relationship between Profiler and Template_Controller that would cause it render twice. If you load Profiler twice, then it displays twice. I don't see a bug here.

If in Template_Controller you call Profiler to render on every page and set Template_controller to auto_render every view the Profiler displays twice.

It's about two things:

Profiler to render on every page (called in Tempate_controller) setting Template_controller to auto_render

The thing is: or I have the Profiller twice or none! :P

  Changed 6 months ago by Shadowhand

I am still unable to reproduce this.

  Changed 6 months ago by Shadowhand

  • milestone changed from 2.1.2 to 2.2

  Changed 5 months ago by Shadowhand

  • status changed from reopened to closed
  • resolution set to invalid

Unable to reproduce, no additional feedback left by reporter.

Note: See TracTickets for help on using tickets.