Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 1 addition & 8 deletions administrator/components/com_fields/src/Model/FieldModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,8 +60,7 @@ public function optimise()
$dispatcher->dispatch('onFinderGarbageCollection', new GarbageCollectionEvent('onFinderGarbageCollection', []));

// Now run the optimisation method from the indexer
$indexer = new Indexer();
Comment thread
laoneo marked this conversation as resolved.
$indexer->optimize();
$this->getModel('Indexer')->optimize();

$message = Text::_('COM_FINDER_INDEX_OPTIMISE_FINISHED');
$this->setRedirect('index.php?option=com_finder&view=index', $message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -351,9 +350,7 @@ public function debug()
try {
// Import the finder plugins.
class_alias(DebugAdapter::class, Adapter::class);
Comment thread
laoneo marked this conversation as resolved.
$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 = '';

Expand Down
9 changes: 2 additions & 7 deletions administrator/components/com_finder/src/Indexer/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions administrator/components/com_finder/src/Indexer/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
laoneo marked this conversation as resolved.
{
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.
Expand Down
33 changes: 33 additions & 0 deletions administrator/components/com_finder/src/Model/IndexerModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
90 changes: 0 additions & 90 deletions administrator/components/com_menus/src/Field/Modal/MenuField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
14 changes: 2 additions & 12 deletions administrator/modules/mod_menu/src/Menu/CssMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 5 additions & 11 deletions components/com_ajax/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 0 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\:
Expand Down
Loading