Ticket #379 (closed Bug: fixed)

Opened 10 months ago

Last modified 10 months ago

Bug in Profiler Config

Reported by: marcus Owned by: PugFish
Priority: minor Milestone: 2.1.2
Component: Libraries Version: SVN HEAD
Keywords: profiler empty data Cc:

Description

he bug is in the Profiler config (config/profiler.php) because when I change all the settings to FALSE except for the database, I have the following error:

Runtime Message

An error was detected which prevented the loading of this page. If this problem persists, please contact the website administrator.

Undefined variable: data

Error occurred at line 80 of C:/marcus/projetos/MusicalCarioca/src/kohana21/system/libraries/Profiler.php.
Stack Trace

    *

      Profiler_Core->render(  )

    * system\core\Event.php [217]:

      call_user_func( Array
      (
          [0] => Profiler Object
              (
              )

          [1] => render
      )
       )

    * system\core\Kohana.php [340]:

      Event::run( system.display, 

      	
      	
      	


      	
      	

      )

    *

      Kohana::shutdown(  )

    * system\core\Event.php [217]:

      call_user_func( Array
      (
          [0] => Kohana
          [1] => shutdown
      )
       )

    * system\core\Bootstrap.php [56]:

      Event::run( system.shutdown )

    * admin.php [83]:

      require( system\core\Bootstrap.php )

application/config/profiler.php:

$config['benchmarks'] = FALSE;

/**
 * Show database queries.
 */
$config['database'] = TRUE;

/**
 * Show POST data.
 */
$config['post'] = FALSE;

/**
 * Show session data.
 */
$config['session'] = FALSE;

/**
 * Show cookie data.
 */
$config['cookie'] = FALSE;

Change History

  Changed 10 months ago by Shadowhand

  • keywords profiler empty data added
  • owner changed from - No owner - to PugFish
  • version set to SVN HEAD
  • component changed from Core to Libraries
  • milestone changed from 2.2 to 2.1.2

in reply to: ↑ description   Changed 10 months ago by marcus

Replying to marcus:

he bug is in the Profiler config (config/profiler.php) because when I change all the settings to FALSE except for the database, I have the following error: {{{ Runtime Message An error was detected which prevented the loading of this page. If this problem persists, please contact the website administrator. Undefined variable: data Error occurred at line 80 of C:/marcus/projetos/MusicalCarioca/src/kohana21/system/libraries/Profiler.php. Stack Trace * Profiler_Core->render( ) * system\core\Event.php [217]: call_user_func( Array ( [0] => Profiler Object ( ) [1] => render ) ) * system\core\Kohana.php [340]: Event::run( system.display, ) * Kohana::shutdown( ) * system\core\Event.php [217]: call_user_func( Array ( [0] => Kohana [1] => shutdown ) ) * system\core\Bootstrap.php [56]: Event::run( system.shutdown ) * admin.php [83]: require( system\core\Bootstrap.php ) }}} application/config/profiler.php: {{{ $configbenchmarks? = FALSE; /** * Show database queries. */ $configdatabase? = TRUE; /** * Show POST data. */ $configpost? = FALSE; /** * Show session data. */ $configsession? = FALSE; /** * Show cookie data. */ $configcookie? = FALSE; }}}

I fixed this problem adding this line in line 48 of libraries/Profiler.php

$data = array();

The complete code of libraries/Profiler.php

<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Adds useful information to the bottom of the current page for debugging and optimization purposes.
 *
 * Benchmarks   - The times and memory usage of benchmarks run by the <Benchmark> library
 * Database     - The raw SQL and number of affected rows of <Database> queries
 * POST Data    - The name and values of any POST data submitted to the current page
 * Session Data - Data stored in the current session if using the <Session> library
 *
 * $Id: Profiler.php 1911 2008-02-04 16:13:16Z PugFish $
 *
 * @package    Core
 * @author     Kohana Team
 * @copyright  (c) 2007-2008 Kohana Team
 * @license    http://kohanaphp.com/license.html
 */
class Profiler_Core {

	/**
	 * 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');
	}

	/**
	 * Disables the profiler for this page only.
	 * Best used when profiler is autoloaded.
	 */
	public function disable()
	{
		// Removes itself from the event queue
		Event::clear('system.display', array($this, 'render'));
	}

	/**
	 * Render the profiler. Output is added to the bottom of the page by default.
	 *
	 * @param   boolean  return the output if TRUE
	 * @return  void|string
	 */
	public function render($return = FALSE)
	{
		'''$data = array();'''
		
		if (Config::item('profiler.benchmarks'))
		{
			// Clean unique id from system benchmark names
			foreach (Benchmark::get(TRUE) as $name => $time)
			{
				$data['benchmarks'][str_replace(SYSTEM_BENCHMARK.'_', '', $name)] = $time;
			}
		}

		// Load database benchmarks, if Database has been loaded
		if (Config::item('profiler.database') AND class_exists('Database', FALSE))
		{
			$data['queries'] = Database::$benchmarks;
		}

		// Load POST data
		if (Config::item('profiler.post'))
		{
			$data['post'] = TRUE;
		}

		if (Config::item('profiler.session'))
		{
			$data['session'] = TRUE;
		}

		if (Config::item('profiler.cookie'))
		{
			$data['cookie'] = TRUE;
		}

		// Load the profiler view
		$view = new View('kohana_profiler', $data);

		// Return rendered view if $return is TRUE
		if ($return == TRUE)
			return $view->render();

		// Add profiler data to the output
		if (stripos(Kohana::$output, '</body>') !== FALSE)
		{
			// Closing body tag was found, insert the profiler data before it
			Kohana::$output = str_ireplace('</body>', $view->render().'</body>', Kohana::$output);
		}
		else
		{
			// Append the profiler data to the output
			Kohana::$output .= $view->render();
		}
	}

	/**
	 * Magically convert this object to a string, the rendered profiler.
	 *
	 * @return  string
	 */
	public function __toString()
	{
		return $this->render(TRUE);
	}

} // End Profiler Class

  Changed 10 months ago by PugFish

  • priority changed from critical to minor
  • status changed from new to assigned

  Changed 10 months ago by PugFish

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r2018. Just a note; rather than disabling all the sections you should just not load the profiler.

Note: See TracTickets for help on using tickets.