mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Deprecated Profiler class, removed related debug GET params
Use third party tools like XHProf instead. Removed defunct or unnecessary debug GET parameters: debug_profile, debug_memory, profile_trace, debug_javascript, debug_behaviour
This commit is contained in:
parent
db4cb8de7e
commit
0fe515e182
@ -134,15 +134,7 @@ class Director implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);
|
$res = Injector::inst()->get('RequestProcessor')->postRequest($req, $response, $model);
|
||||||
if ($res !== false) {
|
if ($res !== false) {
|
||||||
// ?debug_memory=1 will output the number of bytes of memory used for this request
|
|
||||||
if(isset($_REQUEST['debug_memory']) && $_REQUEST['debug_memory']) {
|
|
||||||
Debug::message(sprintf(
|
|
||||||
"Peak memory usage in bytes: %s",
|
|
||||||
number_format(memory_get_peak_usage(),0)
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
$response->output();
|
$response->output();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// @TODO Proper response here.
|
// @TODO Proper response here.
|
||||||
throw new SS_HTTPResponse_Exception("Invalid response");
|
throw new SS_HTTPResponse_Exception("Invalid response");
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
/**
|
/**
|
||||||
* Execution time profiler.
|
* Execution time profiler.
|
||||||
*
|
*
|
||||||
|
* @deprecated 3.1 The Profiler class is deprecated, use third party tools like XHProf instead
|
||||||
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage misc
|
* @subpackage misc
|
||||||
*/
|
*/
|
||||||
@ -51,6 +53,7 @@ class Profiler {
|
|||||||
// Public Methods
|
// Public Methods
|
||||||
|
|
||||||
static function init() {
|
static function init() {
|
||||||
|
Deprecation::notice('3.1', 'The Profiler class is deprecated, use third party tools like XHProf instead');
|
||||||
if(!self::$inst) self::$inst = new Profiler(true,true);
|
if(!self::$inst) self::$inst = new Profiler(true,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
docs/en/changelogs/3.1.0.md
Normal file
9
docs/en/changelogs/3.1.0.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# 3.1.0 (unreleased)
|
||||||
|
|
||||||
|
## Overview ##
|
||||||
|
|
||||||
|
## Upgrading
|
||||||
|
|
||||||
|
* Deprecated `Profiler` class, use third-party solutions like [xhprof](https://github.com/facebook/xhprof/)
|
||||||
|
* Removed defunct or unnecessary debug GET parameters:
|
||||||
|
`debug_profile`, `debug_memory`, `profile_trace`, `debug_javascript`, `debug_behaviour`
|
@ -45,15 +45,6 @@ Append the option and corresponding value to your URL in your browser's address
|
|||||||
| showqueries | | 1 | | List all SQL queries executed |
|
| showqueries | | 1 | | List all SQL queries executed |
|
||||||
| previewwrite | | 1 | | List all insert / update SQL queries, and **don't** execute them. Useful for previewing writes to the database. |
|
| previewwrite | | 1 | | List all insert / update SQL queries, and **don't** execute them. Useful for previewing writes to the database. |
|
||||||
|
|
||||||
## Profiling
|
|
||||||
|
|
||||||
| URL Variable | | Values | | Description |
|
|
||||||
| ------------ | | ------ | | ----------- |
|
|
||||||
| debug_memory | | 1 | | Output the number of bytes of memory used for this
|
|
||||||
| debug_memory | | 1 | | Output the number of bytes of memory used for this request |
|
|
||||||
| debug_profile | | 1 | | Enable the [profiler](/topics/debugging) for the duration of the request |
|
|
||||||
| profile_trace | | 1 | | Includes full stack traces, must be used with **debug_profile** |
|
|
||||||
|
|
||||||
## Security Redirects
|
## Security Redirects
|
||||||
|
|
||||||
You can set an URL to redirect back to after a [Security](/topics/security) action. See the section on [URL
|
You can set an URL to redirect back to after a [Security](/topics/security) action. See the section on [URL
|
||||||
|
21
main.php
21
main.php
@ -36,9 +36,6 @@ if (version_compare(phpversion(), '5.3.2', '<')) {
|
|||||||
* After that, it calls {@link Director::direct()}, which is responsible for doing most of the
|
* After that, it calls {@link Director::direct()}, which is responsible for doing most of the
|
||||||
* real work.
|
* real work.
|
||||||
*
|
*
|
||||||
* Finally, main.php will use {@link Profiler} to show a profile if the querystring variable
|
|
||||||
* "debug_profile" is set.
|
|
||||||
*
|
|
||||||
* CONFIGURING THE WEBSERVER
|
* CONFIGURING THE WEBSERVER
|
||||||
*
|
*
|
||||||
* To use SilverStripe, every request that doesn't point directly to a file should be rewritten to
|
* To use SilverStripe, every request that doesn't point directly to a file should be rewritten to
|
||||||
@ -89,12 +86,6 @@ if (isset($_GET['url'])) {
|
|||||||
// Remove base folders from the URL if webroot is hosted in a subfolder
|
// Remove base folders from the URL if webroot is hosted in a subfolder
|
||||||
if (substr(strtolower($url), 0, strlen(BASE_URL)) == strtolower(BASE_URL)) $url = substr($url, strlen(BASE_URL));
|
if (substr(strtolower($url), 0, strlen(BASE_URL)) == strtolower(BASE_URL)) $url = substr($url, strlen(BASE_URL));
|
||||||
|
|
||||||
if (isset($_GET['debug_profile'])) {
|
|
||||||
Profiler::init();
|
|
||||||
Profiler::mark('all_execution');
|
|
||||||
Profiler::mark('main.php init');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect to database
|
// Connect to database
|
||||||
require_once('model/DB.php');
|
require_once('model/DB.php');
|
||||||
|
|
||||||
@ -114,20 +105,8 @@ if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseC
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['debug_profile'])) Profiler::mark('DB::connect');
|
|
||||||
DB::connect($databaseConfig);
|
DB::connect($databaseConfig);
|
||||||
if (isset($_GET['debug_profile'])) Profiler::unmark('DB::connect');
|
|
||||||
|
|
||||||
if (isset($_GET['debug_profile'])) Profiler::unmark('main.php init');
|
|
||||||
|
|
||||||
|
|
||||||
// Direct away - this is the "main" function, that hands control to the appropriate controller
|
// Direct away - this is the "main" function, that hands control to the appropriate controller
|
||||||
DataModel::set_inst(new DataModel());
|
DataModel::set_inst(new DataModel());
|
||||||
Director::direct($url, DataModel::inst());
|
Director::direct($url, DataModel::inst());
|
||||||
|
|
||||||
if (isset($_GET['debug_profile'])) {
|
|
||||||
Profiler::unmark('all_execution');
|
|
||||||
if(!Director::isLive()) {
|
|
||||||
Profiler::show(isset($_GET['profile_trace']));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -455,8 +455,6 @@ abstract class SS_Database {
|
|||||||
$fieldValue = null;
|
$fieldValue = null;
|
||||||
$newTable = false;
|
$newTable = false;
|
||||||
|
|
||||||
Profiler::mark('requireField');
|
|
||||||
|
|
||||||
// backwards compatibility patch for pre 2.4 requireField() calls
|
// backwards compatibility patch for pre 2.4 requireField() calls
|
||||||
$spec_orig=$spec;
|
$spec_orig=$spec;
|
||||||
|
|
||||||
@ -507,10 +505,7 @@ abstract class SS_Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($newTable || $fieldValue=='') {
|
if($newTable || $fieldValue=='') {
|
||||||
Profiler::mark('createField');
|
|
||||||
|
|
||||||
$this->transCreateField($table, $field, $spec_orig);
|
$this->transCreateField($table, $field, $spec_orig);
|
||||||
Profiler::unmark('createField');
|
|
||||||
$this->alterationMessage("Field $table.$field: created as $spec_orig","created");
|
$this->alterationMessage("Field $table.$field: created as $spec_orig","created");
|
||||||
} else if($fieldValue != $specValue) {
|
} else if($fieldValue != $specValue) {
|
||||||
// If enums/sets are being modified, then we need to fix existing data in the table.
|
// If enums/sets are being modified, then we need to fix existing data in the table.
|
||||||
@ -545,12 +540,9 @@ abstract class SS_Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Profiler::mark('alterField');
|
|
||||||
$this->transAlterField($table, $field, $spec_orig);
|
$this->transAlterField($table, $field, $spec_orig);
|
||||||
Profiler::unmark('alterField');
|
|
||||||
$this->alterationMessage("Field $table.$field: changed to $specValue <i style=\"color: #AAA\">(from {$fieldValue})</i>","changed");
|
$this->alterationMessage("Field $table.$field: changed to $specValue <i style=\"color: #AAA\">(from {$fieldValue})</i>","changed");
|
||||||
}
|
}
|
||||||
Profiler::unmark('requireField');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -646,8 +646,6 @@ class Requirements_Backend {
|
|||||||
* @return string HTML content thats augumented with the requirements before the closing <head> tag.
|
* @return string HTML content thats augumented with the requirements before the closing <head> tag.
|
||||||
*/
|
*/
|
||||||
function includeInHTML($templateFile, $content) {
|
function includeInHTML($templateFile, $content) {
|
||||||
if(isset($_GET['debug_profile'])) Profiler::mark("Requirements::includeInHTML");
|
|
||||||
|
|
||||||
if((strpos($content, '</head>') !== false || strpos($content, '</head ') !== false) && ($this->css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) {
|
if((strpos($content, '</head>') !== false || strpos($content, '</head ') !== false) && ($this->css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) {
|
||||||
$requirements = '';
|
$requirements = '';
|
||||||
$jsRequirements = '';
|
$jsRequirements = '';
|
||||||
@ -711,8 +709,6 @@ class Requirements_Backend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_GET['debug_profile'])) Profiler::unmark("Requirements::includeInHTML");
|
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,22 +810,16 @@ class SSViewer {
|
|||||||
$template = $this->chosenTemplates[$key];
|
$template = $this->chosenTemplates[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process", " for $template");
|
|
||||||
$cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\','/',':'), '.', Director::makeRelative(realpath($template)));
|
$cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\','/',':'), '.', Director::makeRelative(realpath($template)));
|
||||||
|
|
||||||
$lastEdited = filemtime($template);
|
$lastEdited = filemtime($template);
|
||||||
|
|
||||||
if(!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
|
if(!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
|
||||||
if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process - compile", " for $template");
|
|
||||||
|
|
||||||
$content = file_get_contents($template);
|
$content = file_get_contents($template);
|
||||||
$content = SSViewer::parseTemplateContent($content, $template);
|
$content = SSViewer::parseTemplateContent($content, $template);
|
||||||
|
|
||||||
$fh = fopen($cacheFile,'w');
|
$fh = fopen($cacheFile,'w');
|
||||||
fwrite($fh, $content);
|
fwrite($fh, $content);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
||||||
if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process - compile", " for $template");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$underlay = array('I18NNamespace' => basename($template));
|
$underlay = array('I18NNamespace' => basename($template));
|
||||||
@ -846,8 +840,6 @@ class SSViewer {
|
|||||||
|
|
||||||
array_pop(SSViewer::$topLevel);
|
array_pop(SSViewer::$topLevel);
|
||||||
|
|
||||||
if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process", " for $template");
|
|
||||||
|
|
||||||
// If we have our crazy base tag, then fix # links referencing the current page.
|
// If we have our crazy base tag, then fix # links referencing the current page.
|
||||||
if($this->rewriteHashlinks && self::$options['rewriteHashlinks']) {
|
if($this->rewriteHashlinks && self::$options['rewriteHashlinks']) {
|
||||||
if(strpos($output, '<base') !== false) {
|
if(strpos($output, '<base') !== false) {
|
||||||
|
@ -351,10 +351,6 @@ class ViewableData extends Object implements IteratorAggregate {
|
|||||||
* @param string $cacheName a custom cache name
|
* @param string $cacheName a custom cache name
|
||||||
*/
|
*/
|
||||||
public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null) {
|
public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null) {
|
||||||
if(isset($_REQUEST['debug_profile'])) {
|
|
||||||
Profiler::mark("obj.$fieldName", "on a $this->class object");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$cacheName) $cacheName = $arguments ? $fieldName . implode(',', $arguments) : $fieldName;
|
if(!$cacheName) $cacheName = $arguments ? $fieldName . implode(',', $arguments) : $fieldName;
|
||||||
|
|
||||||
if(!isset($this->objCache[$cacheName])) {
|
if(!isset($this->objCache[$cacheName])) {
|
||||||
@ -384,10 +380,6 @@ class ViewableData extends Object implements IteratorAggregate {
|
|||||||
$value = $this->objCache[$cacheName];
|
$value = $this->objCache[$cacheName];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_REQUEST['debug_profile'])) {
|
|
||||||
Profiler::unmark("obj.$fieldName", "on a $this->class object");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_object($value) && $forceReturnedObject) {
|
if(!is_object($value) && $forceReturnedObject) {
|
||||||
$default = Config::inst()->get('ViewableData', 'default_cast', Config::FIRST_SET);
|
$default = Config::inst()->get('ViewableData', 'default_cast', Config::FIRST_SET);
|
||||||
$value = new $default($fieldName);
|
$value = new $default($fieldName);
|
||||||
|
Loading…
Reference in New Issue
Block a user