Project

General

Profile

Actions

Bug #87064

closed

Deprecated public properties can't be accessed after removal

Added by Coders.Care Extension Team over 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
Code Cleanup
Target version:
-
Start date:
2018-12-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

While it is a good idea to convert public to protected properties to avoid manipulation from the outside, it will make access to these properties within hooks provided within the same class as these properties impossible.

Example taken from the Gridelements new item wizard hook:

Within the NewContentElementController there are

    /**
     * @var array
     */
    protected $deprecatedPublicProperties = [
        'id' => 'Using $id of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'sys_language' => 'Using $sys_language of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'R_URI' => 'Using $R_URI of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'colPos' => 'Using $colPos of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'uid_pid' => 'Using $uid_pid of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'modTSconfig' => 'Using $modTSconfig of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'doc' => 'Using $doc of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'content' => 'Using $content of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'access' => 'Using $access of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
        'config' => 'Using $config of NewContentElementController from the outside is discouraged as this variable is used for internal storage.',
    ];

Now the whole class is handed over to hook objects via
$hookObject->manipulateWizardItems($wizardItems, $this);
and then processed like this
public function manipulateWizardItems(&$wizardItems, $parentObject)

As soon as these properties are really deprecated with CMS 10, it won't be possible anymore to get $parentObject->id or $parentObject->colPos from within the hook, which is essential information while rendering the wizard items.

Solution: Since the PublicPropertyDeprecationTrait is used quite a lot all over the core, we should make sure that properties which are handed over to hooks always
provide a getter to access their values while keeping them protected.

Actions

Also available in: Atom PDF