From 10f8c738b60d3acd42e002c334eee8f8d8dd74d5 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Fri, 3 Aug 2012 01:33:51 -0500 Subject: [PATCH 1/3] [ticket/11043] Update template hook name PHPBB3-11043 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/common.php b/phpBB/common.php index 81fe275008..a3e4af88ec 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -132,7 +132,7 @@ $phpbb_subscriber_loader->load(); // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); -$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); +$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'call_hook'))); foreach ($cache->obtain_hooks() as $hook) { From ae612de663dbcd76074df4ea950a3a94745ca0ec Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 3 Aug 2012 12:34:07 +0200 Subject: [PATCH 2/3] [ticket/11043] Allow call_hook() to be called from more than one location. Allow the helper function call_hook() of class phpbb_template to be called from more than once location and thus for more than one hook (although there is only one) by adding the method name as a parameter. PHPBB3-11043 --- phpBB/includes/template/template.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 13fa845659..b7c3e00dee 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -139,7 +139,7 @@ class phpbb_template */ public function display($handle) { - $result = $this->call_hook($handle); + $result = $this->call_hook($handle, __FUNCTION__); if ($result !== false) { return $result[0]; @@ -174,16 +174,17 @@ class phpbb_template * Calls hook if any is defined. * * @param string $handle Template handle being displayed. + * @param string $method Method name of the caller. */ - private function call_hook($handle) + private function call_hook($handle, $method) { global $phpbb_hook; - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $this)) + if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this)) { - if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__))) + if ($phpbb_hook->hook_return(array(__CLASS__, $method))) { - $result = $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__)); + $result = $phpbb_hook->hook_return_result(array(__CLASS__, $method)); return array($result); } } From 3c71f07a3eddd4fa824c401de2e77ce00e5aec15 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 3 Aug 2012 12:34:19 +0200 Subject: [PATCH 3/3] [ticket/11043] Change hook name back to display, since that's where we hook in. PHPBB3-11043 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/common.php b/phpBB/common.php index a3e4af88ec..5882bbf9fb 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -132,7 +132,7 @@ $phpbb_subscriber_loader->load(); // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); -$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'call_hook'))); +$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display'))); foreach ($cache->obtain_hooks() as $hook) {