Skip to content

CMSPlugin: Deprecate use of DispatcherAware and LanguageAware #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions migrations/52-53/new-deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ $model = $this->getModel();
$this->items = $model->getItems();
```
#### Explanation
Joomla and most extensions have extensively been using `Joomla\CMS\MVC\View\AbstractView::get()` in all views. From 5.3 onwards, this method is deprecated and is going to be removed in Joomla 7.0.
Joomla and most extensions have extensively been using `Joomla\CMS\MVC\View\AbstractView::get()` in all views. From 5.3 onwards,
this method is deprecated and is going to be removed in Joomla 7.0.

This code in the past was used to retrieve data from the model. It was included in the `HtmlView.php` and often looked like this:
```php
Expand All @@ -35,9 +36,12 @@ public function display($tpl = null)
parent::display($tpl);
}
```
This code in the view called the method `get<FirstArgument>` on the model and returned the result. If the model didn't have such a method, it returned the classes attribute named by the first argument.
This code in the view called the method `get<FirstArgument>` on the model and returned the result. If the model didn't have such a method,
it returned the classes attribute named by the first argument.

The downside of this is an indirection which no IDE and static code analyser can understand and which hides errors. The better
solution is to call the model directly, making it easy for an IDE to understand the code. The new code should look like this:

The downside of this is an indirection which no IDE and static code analyser can understand and which hides errors. The better solution is to call the model directly, making it easy for an IDE to understand the code. The new code should look like this:
```php
public function display($tpl = null)
{
Expand All @@ -49,7 +53,10 @@ public function display($tpl = null)
parent::display($tpl);
}
```
The first line is a docblock comment, which provides a hint for the IDE for the actual model that is used. The second line will retrieve the model set in the view. If you have more than one model in a view, you can provide it with a parameter to select the right model. The last two lines retrieve the actual data from the model. With the first two lines, IDEs can hint at the available methods in the model and now the returned values from those methods, making it possible to find issues further down the line.
The first line is a docblock comment, which provides a hint for the IDE for the actual model that is used.
The second line will retrieve the model set in the view. If you have more than one model in a view, you can provide it with a parameter to select the right model.
The last two lines retrieve the actual data from the model. With the first two lines, IDEs can hint at the available methods in the model
and now the returned values from those methods, making it possible to find issues further down the line.

## Deprecate `HTMLHelper::_('script')`, `HTMLHelper::_('stylesheet')`

Expand All @@ -61,7 +68,20 @@ PR: https://github.com/joomla/joomla-cms/pull/43396
Deprecate the namespace property of the ComponentRecord class. The property were never initialised.
PR: https://github.com/joomla/joomla-cms/pull/44754


## Plugins deprecations

### CMSPlugin: Deprecate use of DispatcherAware and LanguageAware

Plugin should use DispatcherAware on its own, when it needs to dispatch an event, like for example content/finder.
And language cannot be set on plugin while plugin booting, because it is not available until initialisation of the application is completed.

PR: https://github.com/joomla/joomla-cms/pull/43430

## Dependency Deprecations

### TYPO3/phar-stream-wrapper
PHP 7 had a security issue with .phar packages. To circumvent the issue, the TYPO3 project created this wrapper. In PHP 8.0 this has been fixed in PHP and the whole wrapper is not needed anymore. This package will be removed in 6.0.

PHP 7 had a security issue with .phar packages. To circumvent the issue, the TYPO3 project created this wrapper.
In PHP 8.0 this has been fixed in PHP and the whole wrapper is not needed anymore. This package will be removed in 6.0.