Skip to content

Commit eca3807

Browse files
authored
Reorganize CMSObject removals (#387)
1 parent 882917b commit eca3807

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

migrations/54-60/removed-backward-incompatibility.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,55 @@ sidebar_position: 3
1111
All the deprecated features than have now been removed and any backward incompatibilities.
1212
There should be an explanation of how to mitigate the removals / changes.
1313

14+
15+
### Removal of the CMSObject class usage
16+
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.
17+
18+
#### getItem returns a stdClass instead of CMSObject
19+
20+
- PR: https://github.com/joomla/joomla-cms/pull/42961
21+
- File: libraries/src/MVC/Model/AdminModel.php
22+
- 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
23+
```php
24+
// Old:
25+
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
26+
echo $article->get('title');
27+
28+
// New:
29+
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
30+
echo $article->title;
31+
```
32+
33+
#### CMSObject usage in core has been removed
34+
35+
- PR: https://github.com/joomla/joomla-cms/pull/43795
36+
- PR: https://github.com/joomla/joomla-cms/pull/44655
37+
- 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:
38+
- Smart Search (finder) plugins now use `\stdClass` objects to store the state.
39+
- The following models now return `\stdClass` objects instead of `CMSObject`:
40+
- `Joomla\Component\Installer\Administrator\Model\UpdatesiteModel`
41+
- `\Joomla\Component\Installer\Administrator\Model\UpdatesitesModel`
42+
- `\Joomla\Component\Languages\Administrator\Model\LanguageModel`
43+
- `\Joomla\Component\Mails\Administrator\Model\TemplateModel`
44+
- `\Joomla\Component\Menu\Administrator\Model\MenuModel`
45+
- `\Joomla\Component\Menus\Administrator\Model\MenutypesModel`
46+
- `\Joomla\Component\Messages\Administrator\Model\ConfigModel`
47+
- `\Joomla\Component\Modules\Administrator\Model\ModuleModel`
48+
- `\Joomla\Component\Plugins\Administrator\Model\PluginModel`
49+
- `\Joomla\Component\Scheduler\Administrator\Model\TaskModel`
50+
- `\Joomla\Component\Scheduler\Administrator\Model\TasksModel`
51+
- `\Joomla\Component\Templates\Administrator\Model\StyleModel`
52+
- `\Joomla\Component\Users\Administrator\Model\GroupModel`
53+
- `\Joomla\Component\Workflow\Administrator\Model\TransitionModel`
54+
- `\Joomla\CMS\Component\Contact\Model\FormModel`
55+
- `\Joomla\CMS\Component\Content\Model\FormModel`
56+
- `\Joomla\Component\Tags\Site\Model\TagModel`
57+
- The code of the installer component is using `\stdClass` objects now.
58+
- `\Joomla\CMS\Access\Rules::getAllowed()` now returns a `stdClass`
59+
- `\Joomla\CMS\MVC\Controller\ApiController` uses a `Registry` object for the model state.
60+
- `\Joomla\CMS\User\UserHelper::getProfile()` returns a `stdClass` object now.
61+
62+
1463
### CMS Input object switched to Framework Input object
1564

1665
- PR's:
@@ -50,20 +99,6 @@ if ($this->item->created !== null) {
5099
}
51100
```
52101

53-
### getItem returns a stdClass instead of CMSObject
54-
55-
- PR: https://github.com/joomla/joomla-cms/pull/42961
56-
- File: libraries/src/MVC/Model/AdminModel.php
57-
- 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
58-
```php
59-
// Old:
60-
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
61-
echo $article->get('title');
62-
63-
// New:
64-
$article = $app->bootComponent('content')->getMVCFactory()->createModel('Article', 'Administrator')->getItem(1);
65-
echo $article->title;
66-
```
67102

68103
### None namespaced indexer file removed
69104

@@ -180,3 +215,4 @@ if ($app instanceof \Joomla\CMS\Application\ConsoleApplication) {
180215
- PR: https://github.com/joomla/joomla-cms/pull/44240
181216
- Folder: libraries/src/Filesystem
182217
- 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.
218+

0 commit comments

Comments
 (0)