diff --git a/administrator/components/com_languages/View/Installed/HtmlView.php b/administrator/components/com_languages/View/Installed/HtmlView.php index cbe0df2ba3e2b..ba9d571e64f40 100644 --- a/administrator/components/com_languages/View/Installed/HtmlView.php +++ b/administrator/components/com_languages/View/Installed/HtmlView.php @@ -24,7 +24,7 @@ class HtmlView extends BaseHtmlView /** * True, if FTP settings should be shown, or an exception. * - * @var boolean|\JException + * @var boolean|\Exception */ protected $ftp = null; diff --git a/administrator/components/com_menus/Controller/MenusController.php b/administrator/components/com_menus/Controller/MenusController.php index 0ae050d00df1a..9b67d4395b7d8 100644 --- a/administrator/components/com_menus/Controller/MenusController.php +++ b/administrator/components/com_menus/Controller/MenusController.php @@ -142,7 +142,7 @@ public function rebuild() /** * Temporary method. This should go into the 1.5 to 1.6 upgrade routines. * - * @return \JException|void \JException instance on error + * @return void * * @since 1.6 */ diff --git a/administrator/components/com_menus/Model/ItemModel.php b/administrator/components/com_menus/Model/ItemModel.php index b42ed0e367b67..62c9dd7835352 100644 --- a/administrator/components/com_menus/Model/ItemModel.php +++ b/administrator/components/com_menus/Model/ItemModel.php @@ -1263,7 +1263,7 @@ protected function preprocessForm(\JForm $form, $data, $group = 'content') /** * Method rebuild the entire nested set tree. * - * @return boolean|\JException Boolean true on success, boolean false or \JException instance on error + * @return boolean Boolean true on success, boolean false * * @since 1.6 */ @@ -1304,7 +1304,9 @@ public function rebuild() } catch (\RuntimeException $e) { - return \JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + \JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + + return false; } foreach ($items as &$item) @@ -1323,7 +1325,9 @@ public function rebuild() } catch (\RuntimeException $e) { - return \JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + \JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + + return false; } unset($registry); diff --git a/administrator/components/com_modules/Model/ModuleModel.php b/administrator/components/com_modules/Model/ModuleModel.php index a890fca2aebad..2338998d06b4c 100644 --- a/administrator/components/com_modules/Model/ModuleModel.php +++ b/administrator/components/com_modules/Model/ModuleModel.php @@ -384,7 +384,7 @@ public function delete(&$pks) * * @param array &$pks An array of primary key IDs. * - * @return boolean|\JException Boolean true on success, \JException instance on error + * @return boolean Boolean true on success * * @since 1.6 * @throws \Exception @@ -463,7 +463,9 @@ public function duplicate(&$pks) } catch (\RuntimeException $e) { - return \JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + \JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error'); + + return false; } } diff --git a/administrator/components/com_users/Model/LevelsModel.php b/administrator/components/com_users/Model/LevelsModel.php index b5b22edc25314..8f7478cea238b 100644 --- a/administrator/components/com_users/Model/LevelsModel.php +++ b/administrator/components/com_users/Model/LevelsModel.php @@ -181,7 +181,7 @@ public function reorder($pk, $direction = 0) * @param array $pks An array of primary key ids. * @param integer $order Order position * - * @return boolean|\JException Boolean true on success, boolean false or \JException instance on error + * @return boolean Boolean true on success, boolean false */ public function saveorder($pks, $order) { @@ -191,7 +191,9 @@ public function saveorder($pks, $order) if (empty($pks)) { - return \JFactory::getApplication()->enqueueMessage(\JText::_('COM_USERS_ERROR_LEVELS_NOLEVELS_SELECTED'), 'error'); + \JFactory::getApplication()->enqueueMessage(\JText::_('COM_USERS_ERROR_LEVELS_NOLEVELS_SELECTED'), 'error'); + + return false; } // Update ordering values diff --git a/components/com_content/Model/ArticleModel.php b/components/com_content/Model/ArticleModel.php index 9965c7ca9ad72..447d37934110f 100644 --- a/components/com_content/Model/ArticleModel.php +++ b/components/com_content/Model/ArticleModel.php @@ -70,7 +70,7 @@ protected function populateState() * * @param integer $pk The id of the article. * - * @return object|boolean|\JException Menu item data object on success, boolean false or JException instance on error + * @return object|boolean Menu item data object on success, boolean false */ public function getItem($pk = null) { diff --git a/components/com_users/Model/ResetModel.php b/components/com_users/Model/ResetModel.php index 63e4b7db39672..a64e2906ff7a6 100644 --- a/components/com_users/Model/ResetModel.php +++ b/components/com_users/Model/ResetModel.php @@ -137,7 +137,7 @@ protected function populateState() * * @param array $data The data expected for the form. * - * @return mixed \Exception | \JException | boolean + * @return mixed \Exception | boolean * * @since 1.6 */ @@ -183,7 +183,7 @@ public function processResetComplete($data) // Check the token and user id. if (empty($token) || empty($userId)) { - return new \JException(\JText::_('COM_USERS_RESET_COMPLETE_TOKENS_MISSING'), 403); + return new \Exception(\JText::_('COM_USERS_RESET_COMPLETE_TOKENS_MISSING'), 403); } // Get the user object. @@ -221,7 +221,7 @@ public function processResetComplete($data) // Save the user to the database. if (!$user->save(true)) { - return new \JException(\JText::sprintf('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500); + return new \Exception(\JText::sprintf('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500); } // Flush the user data from the session. @@ -236,7 +236,7 @@ public function processResetComplete($data) * * @param array $data The data expected for the form. * - * @return mixed \Exception | \JException | boolean + * @return mixed \Exception | boolean * * @since 1.6 */ @@ -292,7 +292,7 @@ public function processResetConfirm($data) } catch (\RuntimeException $e) { - return new \JException(\JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500); + return new \Exception(\JText::sprintf('COM_USERS_DATABASE_ERROR', $e->getMessage()), 500); } // Check for a user. @@ -339,7 +339,7 @@ public function processResetConfirm($data) * * @param array $data The data expected for the form. * - * @return mixed \Exception | \JException | boolean + * @return mixed \Exception | boolean * * @since 1.6 */ @@ -446,7 +446,7 @@ public function processResetRequest($data) // Save the user to the database. if (!$user->save(true)) { - return new \JException(\JText::sprintf('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500); + return new \Exception(\JText::sprintf('COM_USERS_USER_SAVE_FAILED', $user->getError()), 500); } // Assemble the password reset confirmation link. diff --git a/installation/src/Controller/LanguageController.php b/installation/src/Controller/LanguageController.php index cbd61978d5f5c..42da0c513ba86 100644 --- a/installation/src/Controller/LanguageController.php +++ b/installation/src/Controller/LanguageController.php @@ -156,7 +156,6 @@ public function setdefault() } // Add menus - \JLoader::registerPrefix('J', JPATH_PLATFORM . '/legacy'); Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/tables/'); $siteLanguages = $model->getInstalledlangsFrontend(); diff --git a/installation/src/Model/LanguagesModel.php b/installation/src/Model/LanguagesModel.php index e4e2b515d1344..72c11d6d4b0ab 100644 --- a/installation/src/Model/LanguagesModel.php +++ b/installation/src/Model/LanguagesModel.php @@ -851,7 +851,6 @@ public function addLanguage($itemLanguage, $sefLangString) public function addMenuGroup($itemLanguage) { // Add menus. - \JLoader::registerPrefix('J', JPATH_PLATFORM . '/legacy'); Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/tables/'); // Add Menu Group. diff --git a/libraries/bootstrap.php b/libraries/bootstrap.php index 7ea83dc67704c..ef9f1ff907ebb 100644 --- a/libraries/bootstrap.php +++ b/libraries/bootstrap.php @@ -33,9 +33,6 @@ // Setup the autoloaders. JLoader::setup(); -// Register the library base path for the legacy libraries. -JLoader::registerPrefix('J', JPATH_PLATFORM . '/legacy'); - // Register the library base path for CMS libraries. JLoader::registerPrefix('J', JPATH_PLATFORM . '/cms', false, true); diff --git a/libraries/import.legacy.php b/libraries/import.legacy.php index 02de26a63a84c..5e59a082887e6 100644 --- a/libraries/import.legacy.php +++ b/libraries/import.legacy.php @@ -52,8 +52,6 @@ // Setup the autoloaders. JLoader::setup(); -JLoader::registerPrefix('J', JPATH_PLATFORM . '/legacy'); - // Check if the JsonSerializable interface exists already if (!interface_exists('JsonSerializable')) { diff --git a/libraries/legacy/exception/exception.php b/libraries/legacy/exception/exception.php deleted file mode 100644 index 48fb0b3ce323e..0000000000000 --- a/libraries/legacy/exception/exception.php +++ /dev/null @@ -1,409 +0,0 @@ -level = $level; - $this->code = $code; - $this->message = $msg; - - if ($info != null) - { - $this->info = $info; - } - - if ($backtrace && function_exists('debug_backtrace')) - { - $this->backtrace = debug_backtrace(); - - for ($i = count($this->backtrace) - 1; $i >= 0; --$i) - { - ++$i; - - if (isset($this->backtrace[$i]['file'])) - { - $this->file = $this->backtrace[$i]['file']; - } - - if (isset($this->backtrace[$i]['line'])) - { - $this->line = $this->backtrace[$i]['line']; - } - - if (isset($this->backtrace[$i]['class'])) - { - $this->class = $this->backtrace[$i]['class']; - } - - if (isset($this->backtrace[$i]['function'])) - { - $this->function = $this->backtrace[$i]['function']; - } - - if (isset($this->backtrace[$i]['type'])) - { - $this->type = $this->backtrace[$i]['type']; - } - - $this->args = false; - - if (isset($this->backtrace[$i]['args'])) - { - $this->args = $this->backtrace[$i]['args']; - } - - break; - } - } - - parent::__construct($msg, (int) $code); - } - - /** - * Returns to error message - * - * @return string Error message - * - * @since 1.6 - * @deprecated 1.7 - */ - public function __toString() - { - JLog::add('JException::__toString is deprecated.', JLog::WARNING, 'deprecated'); - - return $this->message; - } - - /** - * Returns to error message - * - * @return string Error message - * - * @since 1.5 - * @deprecated 1.7 - */ - public function toString() - { - JLog::add('JException::toString is deprecated.', JLog::WARNING, 'deprecated'); - - return (string) $this; - } - - /** - * Returns a property of the object or the default value if the property is not set. - * - * @param string $property The name of the property - * @param mixed $default The default value - * - * @return mixed The value of the property or null - * - * @since 1.6 - * @deprecated 1.7 - * @see JException::getProperties() - */ - public function get($property, $default = null) - { - JLog::add('JException::get is deprecated.', JLog::WARNING, 'deprecated'); - - if (isset($this->$property)) - { - return $this->$property; - } - - return $default; - } - - /** - * Returns an associative array of object properties - * - * @param boolean $public If true, returns only the public properties - * - * @return array Object properties - * - * @since 1.6 - * @deprecated 1.7 - * @see JException::get() - */ - public function getProperties($public = true) - { - JLog::add('JException::getProperties is deprecated.', JLog::WARNING, 'deprecated'); - - $vars = get_object_vars($this); - - if ($public) - { - foreach ($vars as $key => $value) - { - if (strpos($key, '_') === 0) - { - unset($vars[$key]); - } - } - } - - return $vars; - } - - /** - * Get the most recent error message - * - * @param integer $i Option error index - * @param boolean $toString Indicates if Exception objects should return their error message - * - * @return string Error message - * - * @since 1.6 - * @deprecated 1.7 - */ - public function getError($i = null, $toString = true) - { - JLog::add('JException::getError is deprecated.', JLog::WARNING, 'deprecated'); - - // Find the error - if ($i === null) - { - // Default, return the last message - $error = end($this->_errors); - } - elseif (!array_key_exists($i, $this->_errors)) - { - // If $i has been specified but does not exist, return false - return false; - } - else - { - $error = $this->_errors[$i]; - } - - // Check if only the string is requested - if ($error instanceof Exception && $toString) - { - return (string) $error; - } - - return $error; - } - - /** - * Return all errors, if any - * - * @return array Array of error messages or Exception objects - * - * @since 1.6 - * @deprecated 1.7 - */ - public function getErrors() - { - JLog::add('JException::getErrors is deprecated.', JLog::WARNING, 'deprecated'); - - return $this->_errors; - } - - /** - * Modifies a property of the object, creating it if it does not already exist. - * - * @param string $property The name of the property - * @param mixed $value The value of the property to set - * - * @return mixed Previous value of the property - * - * @since 1.6 - * @deprecated 1.7 - * @see JException::setProperties() - */ - public function set($property, $value = null) - { - JLog::add('JException::set is deprecated.', JLog::WARNING, 'deprecated'); - - $previous = $this->$property ?? null; - $this->$property = $value; - - return $previous; - } - - /** - * Set the object properties based on a named array/hash - * - * @param mixed $properties Either and associative array or another object - * - * @return boolean - * - * @since 1.6 - * @deprecated 1.7 - * @see JException::set() - */ - public function setProperties($properties) - { - JLog::add('JException::setProperties is deprecated.', JLog::WARNING, 'deprecated'); - - // Cast to an array - $properties = (array) $properties; - - if (is_array($properties)) - { - foreach ($properties as $k => $v) - { - $this->$k = $v; - } - - return true; - } - - return false; - } - - /** - * Add an error message - * - * @param string $error Error message - * - * @return void - * - * @since 1.6 - * @deprecated 1.7 - */ - public function setError($error) - { - JLog::add('JException::setErrors is deprecated.', JLog::WARNING, 'deprecated'); - - $this->_errors[] = $error; - } -} diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index 984bd355a0599..92ccff0f2ff5e 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -845,7 +845,7 @@ protected function loadLibraryLanguage() * @param array $credentials Array('username' => string, 'password' => string) * @param array $options Array('remember' => boolean) * - * @return boolean|\JException True on success, false if failed or silent handling is configured, or a \JException object on authentication error. + * @return boolean|\Exception True on success, false if failed or silent handling is configured, or a \Exception object on authentication error. * * @since 3.2 */ @@ -884,13 +884,19 @@ public function login($credentials, $options = array()) switch ($authorisation->status) { case Authentication::STATUS_EXPIRED: - return \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_LOGIN_EXPIRED'), 'error'); + \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_LOGIN_EXPIRED'), 'error'); + + return false; case Authentication::STATUS_DENIED: - return \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_LOGIN_DENIED'), 'error'); + \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_LOGIN_DENIED'), 'error'); + + return false; default: - return \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_LOGIN_AUTHORISATION'), 'error'); + \JFactory::getApplication()->enqueueMessage(\JText::_('JLIB_LOGIN_AUTHORISATION'), 'error'); + + return false; } } } diff --git a/libraries/src/Form/Rule/CaptchaRule.php b/libraries/src/Form/Rule/CaptchaRule.php index 35f886918d646..350cd973471ac 100644 --- a/libraries/src/Form/Rule/CaptchaRule.php +++ b/libraries/src/Form/Rule/CaptchaRule.php @@ -70,7 +70,7 @@ public function test(\SimpleXMLElement $element, $value, $group = null, Registry } else { - return new \JException($error); + return new \Exception($error); } } diff --git a/libraries/src/MVC/Model/AdminModel.php b/libraries/src/MVC/Model/AdminModel.php index ec5f5db7e9eaa..bc17bf823437d 100644 --- a/libraries/src/MVC/Model/AdminModel.php +++ b/libraries/src/MVC/Model/AdminModel.php @@ -1296,7 +1296,7 @@ public function save($data) * @param array $pks An array of primary key ids. * @param integer $order +1 or -1 * - * @return boolean|\JException Boolean true on success, false on failure, or \JException if no items are selected + * @return boolean Boolean true on success, false on failure * * @since 1.6 */ @@ -1309,7 +1309,9 @@ public function saveorder($pks = array(), $order = null) if (empty($pks)) { - return \JFactory::getApplication()->enqueueMessage(\JText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED'), 'error'); + \JFactory::getApplication()->enqueueMessage(\JText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED'), 'error'); + + return false; } $orderingField = $this->table->getColumnAlias('ordering'); diff --git a/libraries/src/MVC/View/CategoryView.php b/libraries/src/MVC/View/CategoryView.php index d1aed0535dda7..57975928915ee 100644 --- a/libraries/src/MVC/View/CategoryView.php +++ b/libraries/src/MVC/View/CategoryView.php @@ -101,7 +101,7 @@ class CategoryView extends HtmlView /** * Method with common display elements used in category list displays * - * @return boolean|\JException|void Boolean false or \JException instance on error, nothing otherwise + * @return void * * @since 3.2 */ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3dc8bbe8b3e72..9959861bafaf2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -21,9 +21,6 @@ tests/unit/suites/libraries/joomla - - tests/unit/suites/libraries/legacy - tests/unit/suites/administrator @@ -45,7 +42,6 @@ libraries/cms libraries/joomla - libraries/legacy libraries/src administrator/components/com_finder/helpers/indexer plugins diff --git a/tests/unit/suites/libraries/joomla/JLoaderTest.php b/tests/unit/suites/libraries/joomla/JLoaderTest.php index 8f7f17625fc4b..15284084a08fc 100644 --- a/tests/unit/suites/libraries/joomla/JLoaderTest.php +++ b/tests/unit/suites/libraries/joomla/JLoaderTest.php @@ -555,7 +555,6 @@ public function testRegisterPrefix() // Add the libraries/joomla and libraries/legacy folders to the array JLoader::registerPrefix('J', JPATH_PLATFORM . '/joomla'); - JLoader::registerPrefix('J', JPATH_PLATFORM . '/legacy'); // Get the current prefixes array $prefixes = TestReflection::getValue('JLoader', 'prefixes'); diff --git a/travisci-phpunit.xml b/travisci-phpunit.xml index 1df5ee03265d8..3868f59cb0fbb 100644 --- a/travisci-phpunit.xml +++ b/travisci-phpunit.xml @@ -14,9 +14,6 @@ tests/unit/suites/libraries/joomla - - tests/unit/suites/libraries/legacy - tests/unit/suites/finderIndexer