From 99a3adfba791baabd27f82429fddfbcb82625523 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 10 Mar 2010 11:09:36 +0100 Subject: [feature/request-class] Instantiate a global request class instance. It should at all cost be avoided to rely on this global variable. Instead either use the request_var method (deprecated) or pass the instance to your function as a parameter or to your object as a contructor argument or through a setter function. PHPBB3-9716 --- phpBB/common.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 6cc7abf118..a4be46f987 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -195,6 +195,9 @@ require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); +require($phpbb_root_path . 'includes/request/deactivated_super_global.' . $phpEx); +require($phpbb_root_path . 'includes/request/request_interface.' . $phpEx); +require($phpbb_root_path . 'includes/request/request.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -206,6 +209,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Instantiate some basic classes +$request = new phpbb_request(); $user = new user(); $auth = new auth(); $template = new template(); @@ -215,6 +219,9 @@ $db = new $sql_db(); $class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache); $class_loader->register(); +// make sure request_var uses this request instance +request_var($request, 0); // "dependency injection" for a function + // Connect to DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false); @@ -233,4 +240,4 @@ foreach ($cache->obtain_hooks() as $hook) @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); } -?> \ No newline at end of file +?> -- cgit v1.2.1 From 0ae7df8a51129f2ece86f959e2e155d988feb081 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 13 Mar 2010 11:28:41 +0100 Subject: [feature/request-class] Request class test now uses a type cast helper mock. Removed the dependency of the request class test on having an actual phpbb_type_cast_helper instance, by replacing it with an object mocking the phpbb_type_cast_helper_interface. PHPBB3-9716 --- phpBB/common.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index a4be46f987..57a1384ee4 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -195,6 +195,8 @@ require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); +require($phpbb_root_path . 'includes/request/type_cast_helper_interface.' . $phpEx); +require($phpbb_root_path . 'includes/request/type_cast_helper.' . $phpEx); require($phpbb_root_path . 'includes/request/deactivated_super_global.' . $phpEx); require($phpbb_root_path . 'includes/request/request_interface.' . $phpEx); require($phpbb_root_path . 'includes/request/request.' . $phpEx); @@ -209,7 +211,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Instantiate some basic classes -$request = new phpbb_request(); +$request = new phpbb_request(new phpbb_type_cast_helper()); $user = new user(); $auth = new auth(); $template = new template(); @@ -220,7 +222,7 @@ $class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache); $class_loader->register(); // make sure request_var uses this request instance -request_var($request, 0); // "dependency injection" for a function +request_var('', 0, false, false, $request); // "dependency injection" for a function // Connect to DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false); -- cgit v1.2.1 From 456de639123ae3da6320bed6140ab69ac9925e74 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 31 Aug 2010 21:26:50 +0200 Subject: [feature/request-class] Refactor request classes to use autoloading All class names have been adjusted to use a phpbb_request prefix, allowing them to be autoloaded. Also introduces some improvements to autoloading in general. PHPBB3-9716 --- phpBB/common.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 57a1384ee4..41df3049a1 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -195,11 +195,6 @@ require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); -require($phpbb_root_path . 'includes/request/type_cast_helper_interface.' . $phpEx); -require($phpbb_root_path . 'includes/request/type_cast_helper.' . $phpEx); -require($phpbb_root_path . 'includes/request/deactivated_super_global.' . $phpEx); -require($phpbb_root_path . 'includes/request/request_interface.' . $phpEx); -require($phpbb_root_path . 'includes/request/request.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -210,12 +205,18 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); +// Cache must be loaded before class loader +$cache = new cache(); + +// Setup class loader first +$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache); +$class_loader->register(); + // Instantiate some basic classes -$request = new phpbb_request(new phpbb_type_cast_helper()); +$request = new phpbb_request(); $user = new user(); $auth = new auth(); $template = new template(); -$cache = new cache(); $db = new $sql_db(); $class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache); -- cgit v1.2.1 From 986935c4745195f45cbff74e541ffc98ecac714e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 27 Sep 2010 22:50:25 +0200 Subject: [feature/request-class] Adjust some trailing newlines PHPBB3-9716 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 41df3049a1..2eba85383d 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -243,4 +243,4 @@ foreach ($cache->obtain_hooks() as $hook) @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); } -?> +?> \ No newline at end of file -- cgit v1.2.1