MDL-35628 performance: Remove dirname() where possible.
dirname() is a slow function compared with __DIR__ and using '/../'. Moodle has a large number of legacy files that are included each time a page loads and is not able to use an autoloader as it is functional code. This allows those required includes to perform as best as possible in this situation.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentstable.php');
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentstable.php');
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/capability/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php');
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/filter_form.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true); // progress bar is used here
|
||||
|
||||
require(dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php');
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->dirroot.'/'.$CFG->admin.'/tool/customlang/locallib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
define('CLI_SCRIPT', true);
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require(dirname(__FILE__) . '/../../../../config.php');
|
||||
require(__DIR__ . '/../../../../config.php');
|
||||
require_once($CFG->libdir. '/clilib.php');
|
||||
|
||||
// CLI options.
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
define('CLI_SCRIPT', true);
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require(dirname(__FILE__) . '/../../../../config.php');
|
||||
require(__DIR__ . '/../../../../config.php');
|
||||
require_once($CFG->libdir. '/clilib.php');
|
||||
|
||||
// CLI options.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @copyright 2009 Nicolas Connault
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require(dirname(__FILE__) . '/../../../config.php');
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
|
||||
// This index page was previously in use, for now we redirect to the make test
|
||||
// course page - but we might reinstate this page in the future.
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(dirname(__FILE__) . '/../../../config.php');
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('tool_installaddon_index');
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
define('AJAX_SCRIPT', true);
|
||||
|
||||
require(dirname(__FILE__) . '/../../../config.php');
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(dirname(__FILE__) . '/../../../config.php');
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('toolphpunit');
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
require(dirname(__FILE__) . '/../../../config.php');
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$testpath = optional_param('testpath', '', PARAM_PATH);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
|
||||
require_once(dirname(__FILE__) . '/import_form.php');
|
||||
require_once(__DIR__ . '/import_form.php');
|
||||
|
||||
admin_externalpage_setup('toolprofiling');
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
// TODO: it is wrong when core lib references ANY plugin lang strings, maybe more login could be moved here (skodak)
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir . '/xhprof/xhprof_moodle.php');
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
$contextid = required_param('contextid', PARAM_INT);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class generate_all_documentation extends XMLDBAction {
|
||||
$doc = new DOMDocument();
|
||||
$xsl = new XSLTProcessor();
|
||||
|
||||
$doc->load(dirname(__FILE__).'/../generate_documentation/xmldb.xsl');
|
||||
$doc->load(__DIR__.'/../generate_documentation/xmldb.xsl');
|
||||
$xsl->importStyleSheet($doc);
|
||||
|
||||
$dbdirs = get_db_directories();
|
||||
|
||||
@@ -87,7 +87,7 @@ class generate_documentation extends XMLDBAction {
|
||||
$doc = new DOMDocument();
|
||||
$xsl = new XSLTProcessor();
|
||||
|
||||
$doc->load(dirname(__FILE__).'/xmldb.xsl');
|
||||
$doc->load(__DIR__.'/xmldb.xsl');
|
||||
$xsl->importStyleSheet($doc);
|
||||
|
||||
$doc->load($path);
|
||||
|
||||
Reference in New Issue
Block a user