From 67b3340d828d6756e8b1054782baba81456ca4fb Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 15 May 2017 23:48:51 -0500 Subject: [PATCH] Bugfix: mistakes in path parameters and return values, also add a return value to breadcrumb processing function --- common/standard/classes/standard_path.php | 6 ++++++ common/standard/classes/standard_paths.php | 30 ++++++++++++++++++------------ common/standard/internal/access_denied.php | 16 ++++++++++++++-- common/standard/internal/bad_method.php | 16 ++++++++++++++-- common/standard/internal/index.php | 4 +++- common/standard/internal/not_found.php | 16 ++++++++++++++-- common/standard/internal/server_error.php | 16 ++++++++++++++-- 7 files changed, 83 insertions(+), 21 deletions(-) diff --git a/common/standard/classes/standard_path.php b/common/standard/classes/standard_path.php index a9bc1ef..030d908 100644 --- a/common/standard/classes/standard_path.php +++ b/common/standard/classes/standard_path.php @@ -199,6 +199,10 @@ class c_standard_path extends c_base_path { /** * Build the breadcrumb. + * + * @return c_base_return_status + * TRUE on success, FALSE otherwise. + * FALSE with error bit set is returned on error. */ protected function pr_build_breadcrumbs() { $this->breadcrumbs = new c_base_menu_item(); @@ -221,6 +225,8 @@ class c_standard_path extends c_base_path { #} #$this->get_breadcrumbs(); + + return new c_base_return_true(); } /** diff --git a/common/standard/classes/standard_paths.php b/common/standard/classes/standard_paths.php index 8384adc..5d6d532 100644 --- a/common/standard/classes/standard_paths.php +++ b/common/standard/classes/standard_paths.php @@ -441,9 +441,11 @@ class c_standard_paths extends c_base_return { // execute path handler, using custom-language if defined. if (empty($handler_settings['handler'])) { - $path_server_error = $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); - $path_server_error->set_path_tree($path_tree); + $handler_server_error = $this->get_handler_server_error(); + $handler_server_error->set_path_tree($path_tree); + $path_server_error = $handler_server_error->do_execute($this->http, $this->database, $this->session, $this->settings); + unset($handler_server_error); unset($handler_settings); unset($path_tree); @@ -463,9 +465,11 @@ class c_standard_paths extends c_base_return { // attempt to fallback to default handler if the language-specific handler class is not found. if (!class_exists($handler_settings['handler'])) { - $path_server_error = $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); - $path_server_error->set_path_tree($path_tree); + $handler_server_error = $this->get_handler_server_error(); + $handler_server_error->set_path_tree($path_tree); + $path_server_error = $handler_server_error->do_execute($this->http, $this->database, $this->session, $this->settings); + unset($handler_server_error); unset($handler_settings); unset($path_tree); @@ -483,9 +487,11 @@ class c_standard_paths extends c_base_return { $this->handler->set_path_tree($path_tree); } else { - $path_server_error = $this->get_handler_server_error()->do_execute($this->http, $this->database, $this->session, $this->settings); - $path_server_error->set_path_tree($path_tree); + $handler_server_error = $this->get_handler_server_error(); + $handler_server_error->set_path_tree($path_tree); + $path_server_error = $handler_server_error->do_execute($this->http, $this->database, $this->session, $this->settings); + unset($handler_server_error); unset($handler_settings); unset($path_tree); @@ -533,17 +539,17 @@ class c_standard_paths extends c_base_return { // user paths $this->paths->add_path(self::URI_USER_CREATE, self::HANDLER_USER_CREATE, self::PATH_USER, self::NAME_USER_CREATE); - $this->paths->add_path(self::URI_USER_CREATE, self::HANDLER_USER_CREATE, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_CREATE); + $this->paths->add_path(self::URI_USER_CREATE . self::WILDCARD_PATH, self::HANDLER_USER_CREATE, self::PATH_USER, self::NAME_USER_CREATE); $this->paths->add_path(self::URI_USER_VIEW, self::HANDLER_USER_VIEW, self::PATH_USER, self::NAME_USER_VIEW); - $this->paths->add_path(self::URI_USER_VIEW, self::HANDLER_USER_VIEW, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_VIEW); + $this->paths->add_path(self::URI_USER_VIEW . self::WILDCARD_PATH, self::HANDLER_USER_VIEW, self::PATH_USER, self::NAME_USER_VIEW); $this->paths->add_path(self::URI_USER_SETTINGS, self::HANDLER_USER_SETTINGS, self::PATH_USER, self::NAME_USER_SETTINGS); - $this->paths->add_path(self::URI_USER_SETTINGS, self::HANDLER_USER_SETTINGS, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_SETTINGS); + $this->paths->add_path(self::URI_USER_SETTINGS . self::WILDCARD_PATH, self::HANDLER_USER_SETTINGS, self::PATH_USER, self::NAME_USER_SETTINGS); $this->paths->add_path(self::URI_USER_LOCK, self::HANDLER_USER_LOCK, self::PATH_USER, self::NAME_USER_LOCK); - $this->paths->add_path(self::URI_USER_LOCK, self::HANDLER_USER_LOCK, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_LOCK); + $this->paths->add_path(self::URI_USER_LOCK . self::WILDCARD_PATH, self::HANDLER_USER_LOCK, self::PATH_USER, self::NAME_USER_LOCK); $this->paths->add_path(self::URI_USER_UNLOCK, self::HANDLER_USER_UNLOCK, self::PATH_USER, self::NAME_USER_UNLOCK); - $this->paths->add_path(self::URI_USER_UNLOCK, self::HANDLER_USER_UNLOCK, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_UNLOCK); + $this->paths->add_path(self::URI_USER_UNLOCK . self::WILDCARD_PATH, self::HANDLER_USER_UNLOCK, self::PATH_USER, self::NAME_USER_UNLOCK); $this->paths->add_path(self::URI_USER_DELETE, self::HANDLER_USER_DELETE, self::PATH_USER, self::NAME_USER_DELETE); - $this->paths->add_path(self::URI_USER_DELETE, self::HANDLER_USER_DELETE, self::PATH_USER . self::WILDCARD_PATH, self::NAME_USER_DELETE); + $this->paths->add_path(self::URI_USER_DELETE . self::WILDCARD_PATH, self::HANDLER_USER_DELETE, self::PATH_USER, self::NAME_USER_DELETE); } /** diff --git a/common/standard/internal/access_denied.php b/common/standard/internal/access_denied.php index 9ff65a3..c299ef0 100644 --- a/common/standard/internal/access_denied.php +++ b/common/standard/internal/access_denied.php @@ -14,10 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_access_denied extends c_standard_path { /** - * Build the breadcrumb. + * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $handler_settings = $this->path_tree->get_item_reset()->get_value(); + if (!is_object($this->path_tree)) { + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $this->path_tree->get_item_reset(); + if ($handler_settings instanceof c_base_return_false) { + unset($handler_settings); + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $handler_settings->get_value(); if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { return parent::pr_build_breadcrumbs(); @@ -57,6 +67,8 @@ class c_standard_path_access_denied extends c_standard_path { $this->breadcrumbs = $handler->get_breadcrumbs(); unset($handler); + + return new c_base_return_true(); } /** diff --git a/common/standard/internal/bad_method.php b/common/standard/internal/bad_method.php index fe9f8a4..9bef3e0 100644 --- a/common/standard/internal/bad_method.php +++ b/common/standard/internal/bad_method.php @@ -14,10 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_bad_method extends c_standard_path { /** - * Build the breadcrumb. + * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $handler_settings = $this->path_tree->get_item_reset()->get_value(); + if (!is_object($this->path_tree)) { + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $this->path_tree->get_item_reset(); + if ($handler_settings instanceof c_base_return_false) { + unset($handler_settings); + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $handler_settings->get_value(); if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { return parent::pr_build_breadcrumbs(); @@ -57,6 +67,8 @@ class c_standard_path_bad_method extends c_standard_path { $this->breadcrumbs = $handler->get_breadcrumbs(); unset($handler); + + return new c_base_return_true(); } /** diff --git a/common/standard/internal/index.php b/common/standard/internal/index.php index 06ee70f..587f94d 100644 --- a/common/standard/internal/index.php +++ b/common/standard/internal/index.php @@ -15,7 +15,7 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_index extends c_standard_path { /** - * Build the breadcrumb. + * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { $this->breadcrumbs = new c_base_menu_item(); @@ -23,6 +23,8 @@ class c_standard_path_index extends c_standard_path { $item = $this->pr_create_breadcrumbs_item($this->pr_get_text_breadcrumbs(0), ''); $this->breadcrumbs->set_item($item); unset($item); + + return new c_base_return_true(); } /** diff --git a/common/standard/internal/not_found.php b/common/standard/internal/not_found.php index 7c63e89..621dc50 100644 --- a/common/standard/internal/not_found.php +++ b/common/standard/internal/not_found.php @@ -14,10 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_not_found extends c_standard_path { /** - * Build the breadcrumb. + * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $handler_settings = $this->path_tree->get_item_reset()->get_value(); + if (!is_object($this->path_tree)) { + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $this->path_tree->get_item_reset(); + if ($handler_settings instanceof c_base_return_false) { + unset($handler_settings); + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $handler_settings->get_value(); if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { return parent::pr_build_breadcrumbs(); @@ -57,6 +67,8 @@ class c_standard_path_not_found extends c_standard_path { $this->breadcrumbs = $handler->get_breadcrumbs(); unset($handler); + + return new c_base_return_true(); } /** diff --git a/common/standard/internal/server_error.php b/common/standard/internal/server_error.php index ea313ce..0930145 100644 --- a/common/standard/internal/server_error.php +++ b/common/standard/internal/server_error.php @@ -14,10 +14,20 @@ require_once('common/theme/classes/theme_html.php'); class c_standard_path_server_error extends c_standard_path { /** - * Build the breadcrumb. + * Implementation of pr_build_breadcrumbs(). */ protected function pr_build_breadcrumbs() { - $handler_settings = $this->path_tree->get_item_reset()->get_value(); + if (!is_object($this->path_tree)) { + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $this->path_tree->get_item_reset(); + if ($handler_settings instanceof c_base_return_false) { + unset($handler_settings); + return parent::pr_build_breadcrumbs(); + } + + $handler_settings = $handler_settings->get_value(); if (!isset($handler_settings['include_name']) || !is_string($handler_settings['include_name'])) { return parent::pr_build_breadcrumbs(); @@ -57,6 +67,8 @@ class c_standard_path_server_error extends c_standard_path { $this->breadcrumbs = $handler->get_breadcrumbs(); unset($handler); + + return new c_base_return_true(); } /** -- 1.8.3.1