Skip to content
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
64 changes: 50 additions & 14 deletions migrations/54-60/removed-backward-incompatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,55 @@ sidebar_position: 3
All the deprecated features than have now been removed and any backward incompatibilities.
There should be an explanation of how to mitigate the removals / changes.


### Removal of the CMSObject class usage
The `CMSObject` (`JObject`) contains various functions in one single class which made sense at the time it was introduced in Joomla 1.7. PHP has evolved and many use cases are now built into the core language or are replaced and not anymore up to date. Therefore the class got [deprecated in 4.0](https://github.com/joomla/joomla-cms/pull/4910) and will be removed in an upcoming major release (currently 7.0). Over time, the maintainers removed the usage in core and with the following chapters are the last traces removed, which couldn't be done in a backwards compatible way.

#### getItem returns a stdClass instead of CMSObject

- PR: https://github.com/joomla/joomla-cms/pull/42961
- File: libraries/src/MVC/Model/AdminModel.php
- Description: The `AdminModel` class does return a `stdClass` object in the `getItem` function instead of a `CMSObject`. This means that all the deprecated functions of `CMSObject` are not available anymore. Mainly the set and get function should be replaced accordingly as documented in the `CMSObject` class or the respective traits. For example you can use
```php
// Old:
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
echo $article->get('title');

// New:
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
echo $article->title;
```

#### CMSObject usage in core has been removed

- PR: https://github.com/joomla/joomla-cms/pull/43795
- PR: https://github.com/joomla/joomla-cms/pull/44655
- Description: The `CMSObject` class has been problematic for a long time, because it allows to circumvent the visibility setting of object properties. The `CMSObject` class will be removed in Joomla 7.0, but with Joomla 6.0 it is removed everywhere in the core code. The following code is affected:
- Smart Search (finder) plugins now use `\stdClass` objects to store the state.
- The following models now return `\stdClass` objects instead of `CMSObject`:
- `Joomla\Component\Installer\Administrator\Model\UpdatesiteModel`
- `\Joomla\Component\Installer\Administrator\Model\UpdatesitesModel`
- `\Joomla\Component\Languages\Administrator\Model\LanguageModel`
- `\Joomla\Component\Mails\Administrator\Model\TemplateModel`
- `\Joomla\Component\Menu\Administrator\Model\MenuModel`
- `\Joomla\Component\Menus\Administrator\Model\MenutypesModel`
- `\Joomla\Component\Messages\Administrator\Model\ConfigModel`
- `\Joomla\Component\Modules\Administrator\Model\ModuleModel`
- `\Joomla\Component\Plugins\Administrator\Model\PluginModel`
- `\Joomla\Component\Scheduler\Administrator\Model\TaskModel`
- `\Joomla\Component\Scheduler\Administrator\Model\TasksModel`
- `\Joomla\Component\Templates\Administrator\Model\StyleModel`
- `\Joomla\Component\Users\Administrator\Model\GroupModel`
- `\Joomla\Component\Workflow\Administrator\Model\TransitionModel`
- `\Joomla\CMS\Component\Contact\Model\FormModel`
- `\Joomla\CMS\Component\Content\Model\FormModel`
- `\Joomla\Component\Tags\Site\Model\TagModel`
- The code of the installer component is using `\stdClass` objects now.
- `\Joomla\CMS\Access\Rules::getAllowed()` now returns a `stdClass`
- `\Joomla\CMS\MVC\Controller\ApiController` uses a `Registry` object for the model state.
- `\Joomla\CMS\User\UserHelper::getProfile()` returns a `stdClass` object now.


### CMS Input object switched to Framework Input object

- PR's:
Expand Down Expand Up @@ -50,20 +99,6 @@ if ($this->item->created !== null) {
}
```

### getItem returns a stdClass instead of CMSObject

- PR: https://github.com/joomla/joomla-cms/pull/42961
- File: libraries/src/MVC/Model/AdminModel.php
- Description: The `AdminModel` class does return a `stdClass` object in the `getItem` function instead of a `CMSObject`. This means that all the deprecated functions of `CMSObject` are not available anymore. Mainly the set and get function should be replaced accordingly as documented in the `CMSObject` class or the respective traits. For example you can use
```php
// Old:
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
echo $article->get('title');

// New:
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
echo $article->title;
```

### None namespaced indexer file removed

Expand Down Expand Up @@ -180,3 +215,4 @@ if ($app instanceof \Joomla\CMS\Application\ConsoleApplication) {
- PR: https://github.com/joomla/joomla-cms/pull/44240
- Folder: libraries/src/Filesystem
- Description: The Filesystem package of the CMS (`\Joomla\CMS\Filesystem`) has been deprecated for a long time. For Joomla 6.0 it has been moved to the compat plugin and will finally be completely removed in 7.0. Please use the [framework `Filesystem`](https://github.com/joomla-framework/filesystem) package (`\Joomla\Filesystem`). The packages can be used nearly interchangeably, with the exception of `File::exists()` and `Folder::exists()`. Please use `is_file()` and `is_dir()` directly.