Bug #87064

Deprecated public properties can't be accessed after removal

Added by Coders.Care Extension Team 10 days ago. Updated 8 days ago.

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

0%

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.


Related issues

Related to Grid Elements - Bug #85441: Notices when opening a CE gridelement (non-cached) Resolved 2018-06-30

History

#1 Updated by Coders.Care Extension Team 10 days ago

  • Description updated (diff)

#2 Updated by Coders.Care Extension Team 10 days ago

  • Description updated (diff)

#3 Updated by Georg Ringer 9 days ago

I wouldn't want getters for every property as those as those could be just internal. I would propose adding a new hook or request getters for specific properties

#4 Updated by Coders.Care Extension Team 8 days ago

Good point.

Actually it does not matter how this will be resolved technically as long as necessary information is still made available.

In this specific case it would be enough to provide an array of the necessary key/value pairs either as additional parameter or maybe as a replacement for $parentObject, since the parent object would be more or less inaccessible anyway.

Should be checked what fits the other cases best. In this case i.e. having just a few properties like id, uid_pid, sys_language and colPos would be enough to determine the context for additional wizard items.

#5 Updated by Coders.Care Extension Team 4 days ago

  • Related to Bug #85441: Notices when opening a CE gridelement (non-cached) added

Also available in: Atom PDF