diff --git a/administrator/components/com_actionlogs/src/Model/ActionlogModel.php b/administrator/components/com_actionlogs/src/Model/ActionlogModel.php index c4fd19f0a77b8..70a62937ecda9 100644 --- a/administrator/components/com_actionlogs/src/Model/ActionlogModel.php +++ b/administrator/components/com_actionlogs/src/Model/ActionlogModel.php @@ -57,16 +57,7 @@ class ActionlogModel extends BaseDatabaseModel implements UserFactoryAwareInterf */ public function addLog($messages, $messageLanguageKey, $context, $userId = 0) { - if (!is_numeric($userId)) { - @trigger_error(\sprintf('User ID must be an integer in %s.', __METHOD__), E_USER_DEPRECATED); - } - - try { - $user = $userId ? $this->getUserFactory()->loadUserById($userId) : $this->getCurrentUser(); - } catch (\UnexpectedValueException $e) { - @trigger_error('UserFactory must be set, this will not be caught anymore in 7.0.', E_USER_DEPRECATED); - $user = Factory::getUser($userId); - } + $user = $userId ? $this->getUserFactory()->loadUserById($userId) : $this->getCurrentUser(); $db = $this->getDatabase(); $date = Factory::getDate(); diff --git a/administrator/components/com_fields/src/Model/FieldModel.php b/administrator/components/com_fields/src/Model/FieldModel.php index 8026a3a99a349..7440f3084240e 100644 --- a/administrator/components/com_fields/src/Model/FieldModel.php +++ b/administrator/components/com_fields/src/Model/FieldModel.php @@ -25,8 +25,6 @@ use Joomla\CMS\Table\Table; use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; use Joomla\Database\DatabaseAwareInterface; -use Joomla\Database\DatabaseInterface; -use Joomla\Database\Exception\DatabaseNotFoundException; use Joomla\Database\ParameterType; use Joomla\Filesystem\Path; use Joomla\Registry\Registry; @@ -349,12 +347,7 @@ private function checkDefaultValue($data) } if ($rule instanceof DatabaseAwareInterface) { - try { - $rule->setDatabase($this->getDatabase()); - } catch (DatabaseNotFoundException) { - @trigger_error('Database must be set, this will not be caught anymore in 7.0.', E_USER_DEPRECATED); - $rule->setDatabase(Factory::getContainer()->get(DatabaseInterface::class)); - } + $rule->setDatabase($this->getDatabase()); } try { diff --git a/administrator/components/com_finder/src/Controller/IndexController.php b/administrator/components/com_finder/src/Controller/IndexController.php index 3faa50301b642..b298da4a3bcfd 100644 --- a/administrator/components/com_finder/src/Controller/IndexController.php +++ b/administrator/components/com_finder/src/Controller/IndexController.php @@ -14,7 +14,6 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\AdminController; use Joomla\CMS\Plugin\PluginHelper; -use Joomla\Component\Finder\Administrator\Indexer\Indexer; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -61,8 +60,7 @@ public function optimise() $dispatcher->dispatch('onFinderGarbageCollection', new GarbageCollectionEvent('onFinderGarbageCollection', [])); // Now run the optimisation method from the indexer - $indexer = new Indexer(); - $indexer->optimize(); + $this->getModel('Indexer')->optimize(); $message = Text::_('COM_FINDER_INDEX_OPTIMISE_FINISHED'); $this->setRedirect('index.php?option=com_finder&view=index', $message); diff --git a/administrator/components/com_finder/src/Controller/IndexerController.php b/administrator/components/com_finder/src/Controller/IndexerController.php index 5b29585264914..8e014f58a0306 100644 --- a/administrator/components/com_finder/src/Controller/IndexerController.php +++ b/administrator/components/com_finder/src/Controller/IndexerController.php @@ -241,8 +241,7 @@ public function optimize() try { // Optimize the index - $indexer = new Indexer(); - $indexer->optimize(); + $this->getModel()->optimize(); // Get the indexer state. $state = Indexer::getState(); @@ -351,9 +350,7 @@ public function debug() try { // Import the finder plugins. class_alias(DebugAdapter::class, Adapter::class); - $plugin = $this->app->bootPlugin($this->app->getInput()->get('plugin'), 'finder'); - $plugin->setIndexer(new DebugIndexer()); - $plugin->debug($this->app->getInput()->get('id')); + $this->getModel()->debug($this->app->bootPlugin($this->app->getInput()->get('plugin'), 'finder'), $this->app->getInput()->get('id')); $output = ''; diff --git a/administrator/components/com_finder/src/Indexer/Indexer.php b/administrator/components/com_finder/src/Indexer/Indexer.php index 07b63920b8674..f6cd91023a9ee 100644 --- a/administrator/components/com_finder/src/Indexer/Indexer.php +++ b/administrator/components/com_finder/src/Indexer/Indexer.php @@ -114,17 +114,12 @@ class Indexer /** * Indexer constructor. * - * @param ?DatabaseInterface $db The database + * @param DatabaseInterface $db The database * * @since 3.8.0 */ - public function __construct(?DatabaseInterface $db = null) + public function __construct(DatabaseInterface $db) { - if ($db === null) { - @trigger_error('Database will be mandatory in 7.0.', E_USER_DEPRECATED); - $db = Factory::getContainer()->get(DatabaseInterface::class); - } - $this->db = $db; // Set up query template for addTokensToDb diff --git a/administrator/components/com_finder/src/Indexer/Query.php b/administrator/components/com_finder/src/Indexer/Query.php index 405adc3fbca59..4b4cefdbfd1ac 100644 --- a/administrator/components/com_finder/src/Indexer/Query.php +++ b/administrator/components/com_finder/src/Indexer/Query.php @@ -199,19 +199,14 @@ class Query /** * Method to instantiate the query object. * - * @param array $options An array of query options. - * @param ?DatabaseInterface $db The database + * @param array $options An array of query options. + * @param DatabaseInterface $db The database * * @since 2.5 * @throws \Exception on database error. */ - public function __construct($options, ?DatabaseInterface $db = null) + public function __construct($options, DatabaseInterface $db) { - if ($db === null) { - @trigger_error('Database will be mandatory in 7.0.', E_USER_DEPRECATED); - $db = Factory::getContainer()->get(DatabaseInterface::class); - } - $this->setDatabase($db); // Get the input string. diff --git a/administrator/components/com_finder/src/Model/IndexerModel.php b/administrator/components/com_finder/src/Model/IndexerModel.php index 4319a660ab417..4c66d94273aa3 100644 --- a/administrator/components/com_finder/src/Model/IndexerModel.php +++ b/administrator/components/com_finder/src/Model/IndexerModel.php @@ -12,6 +12,10 @@ use Joomla\CMS\Form\Form; use Joomla\CMS\MVC\Model\FormModel; +use Joomla\Component\Finder\Administrator\Indexer\Adapter; +use Joomla\Component\Finder\Administrator\Indexer\DebugAdapter; +use Joomla\Component\Finder\Administrator\Indexer\DebugIndexer; +use Joomla\Component\Finder\Administrator\Indexer\Indexer; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -40,4 +44,33 @@ public function getForm($data = [], $loadData = true) { return $this->loadForm('com_finder.indexer', 'indexer', ['control' => '', 'load_data' => $loadData]); } + + /** + * Method to optimize the index by removing orphaned entries. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function optimize() + { + $indexer = new Indexer($this->getDatabase()); + $indexer->optimize(); + } + + /** + * Method to debug the adapter. + * + * @param DebugAdapter $adapter The adapter to debug. + * @param integer $id The id of the item to debug. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function debug(DebugAdapter $adapter, int $id) + { + $adapter->setIndexer(new DebugIndexer($this->getDatabase())); + $adapter->debug($id); + } } diff --git a/administrator/components/com_menus/src/Field/Modal/MenuField.php b/administrator/components/com_menus/src/Field/Modal/MenuField.php index f86ce5e4364b1..3335ecc4d1152 100644 --- a/administrator/components/com_menus/src/Field/Modal/MenuField.php +++ b/administrator/components/com_menus/src/Field/Modal/MenuField.php @@ -39,96 +39,6 @@ class MenuField extends ModalSelectField */ protected $type = 'Modal_Menu'; - /** - * Method to get certain otherwise inaccessible properties from the form field object. - * - * @param string $name The property name for which to get the value. - * - * @return mixed The property value or null. - * - * @since 3.7.0 - */ - public function __get($name) - { - switch ($name) { - case 'allowSelect': - case 'allowClear': - case 'allowNew': - case 'allowEdit': - case 'allowPropagate': - // @TODO: The override only for backward compatibility. Remove in Joomla 6. - $map = [ - 'allowSelect' => 'select', - 'allowClear' => 'clear', - 'allowNew' => 'new', - 'allowEdit' => 'edit', - 'allowPropagate' => 'propagate', - ]; - $newName = $map[$name]; - - @trigger_error( - \sprintf( - 'MenuField::__get property "%s" is deprecated, and will not work in Joomla 6. Use "%s" property instead.', - $name, - $newName - ), - E_USER_DEPRECATED - ); - - return parent::__get($newName); - } - - return parent::__get($name); - } - - /** - * Method to set certain otherwise inaccessible properties of the form field object. - * - * @param string $name The property name for which to set the value. - * @param mixed $value The value of the property. - * - * @return void - * - * @since 3.7.0 - */ - public function __set($name, $value) - { - switch ($name) { - case 'allowSelect': - case 'allowClear': - case 'allowNew': - case 'allowEdit': - case 'allowPropagate': - // @TODO: The override only for backward compatibility. Remove in Joomla 6. - $map = [ - 'allowSelect' => 'select', - 'allowClear' => 'clear', - 'allowNew' => 'new', - 'allowEdit' => 'edit', - 'allowPropagate' => 'propagate', - ]; - $newName = $map[$name]; - - @trigger_error( - \sprintf( - 'MenuField::__set property "%s" is deprecated, and will not work in Joomla 6. Use "%s" property instead.', - $name, - $newName - ), - E_USER_DEPRECATED - ); - - $value = (string) $value; - $value = !($value === 'false' || $value === 'off' || $value === '0'); - - parent::__set($newName, $value); - break; - - default: - parent::__set($name, $value); - } - } - /** * Method to attach a Form object to the field. * diff --git a/administrator/modules/mod_menu/src/Menu/CssMenu.php b/administrator/modules/mod_menu/src/Menu/CssMenu.php index 0b6fa25f280a6..9990df3e3a8ea 100644 --- a/administrator/modules/mod_menu/src/Menu/CssMenu.php +++ b/administrator/modules/mod_menu/src/Menu/CssMenu.php @@ -13,7 +13,6 @@ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Event\Menu\PreprocessMenuItemsEvent; -use Joomla\CMS\Factory; use Joomla\CMS\Language\Associations; use Joomla\CMS\Language\Text; use Joomla\CMS\Menu\AdministratorMenuItem; @@ -96,21 +95,12 @@ class CssMenu implements DatabaseAwareInterface * CssMenu constructor. * * @param CMSApplication $application The application - * @param ?DatabaseInterface $db The database + * @param DatabaseInterface $db The database * * @since 4.0.0 */ - public function __construct(CMSApplication $application, ?DatabaseInterface $db = null) + public function __construct(CMSApplication $application, DatabaseInterface $db) { - if ($db === null) { - @trigger_error( - __CLASS__ . ': The $db parameter must be set for the constructor.', - \E_USER_DEPRECATED - ); - - $db = Factory::getContainer()->get(DatabaseInterface::class); - } - $this->setDatabase($db); $this->application = $application; diff --git a/components/com_ajax/ajax.php b/components/com_ajax/ajax.php index b54a0ba7201a2..65aa7d7984c82 100644 --- a/components/com_ajax/ajax.php +++ b/components/com_ajax/ajax.php @@ -251,20 +251,14 @@ // Return the results in the desired format switch ($format) { case 'json': - if (!($results instanceof Throwable) && $results instanceof StringableInterface) { + if (!($results instanceof Throwable) && ($results instanceof StringableInterface || $results instanceof \Stringable)) { echo $results; - } else { - if (\is_object($results) && !($results instanceof Throwable) && $results instanceof \Stringable) { - @trigger_error( - 'Ajax result object (except Throwable) which implements Stringable interface (implicitly or explicitly), will be rendered directly. Starting from 7.0', - \E_USER_DEPRECATED - ); - } - - // JSONized - echo new JsonResponse($results, null, false, $input->get('ignoreMessages', true, 'bool')); + break; } + // JSONized + echo new JsonResponse($results, null, false, $input->get('ignoreMessages', true, 'bool')); + break; default: diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c41731663f051..881d32fe1e014 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11,18 +11,6 @@ parameters: count: 1 path: administrator/components/com_actionlogs/src/Helper/ActionlogsHelper.php - - - message: ''' - #^Call to deprecated method getUser\(\) of class Joomla\\CMS\\Factory\: - 4\.3 will be removed in 7\.0 - Load the user service from the dependency injection container or get from the application object - Example\: - Factory\:\:getApplication\(\)\-\>getIdentity\(\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: administrator/components/com_actionlogs/src/Model/ActionlogModel.php - - message: ''' #^Call to deprecated method setError\(\) of class Joomla\\CMS\\MVC\\Model\\BaseModel\: