Deprecated function error message

Created on 4 July 2024, 10 months ago

Deprecated function error:

Deprecated function: Creation of dynamic property Drupal\cmrf_webform\Manager\CMRFDefaultsManager::$stringTranslation is deprecated ve funkci Drupal\cmrf_webform\Manager\CMRFManagerBase->__construct() (Ε™Γ‘dek 14 souboru /var/www/lekari-bez-hranic.cz/dev/web/modules/contrib/cmrf_core/cmrf_webform/src/Manager/CMRFManagerBase.php)

Patch added below.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡ΏCzech Republic begamen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @begamen
  • πŸ‡¨πŸ‡ΏCzech Republic begamen
  • πŸ‡¨πŸ‡ΏCzech Republic begamen

    Patch here

  • πŸ‡¨πŸ‡ΏCzech Republic begamen

    Edited patch

  • Status changed to RTBC 8 months ago
  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    The patch fixes the warning for me.

  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels
  • πŸ‡©πŸ‡ͺGermany gngn

    #4 worked for me too.

  • πŸ‡©πŸ‡ͺGermany gngn

    As mentioned #4 worked for me.

    But taking a deeper look: the abstract constructor from CMRFManagerBase

    abstract class CMRFManagerBase {
    
      protected $core;
    
      public function __construct($core, $translation) {
        $this->core = $core;
        $this->stringTranslation = $translation;
      }
    

    Since $stringTranslation is not declared this is a creation of dynamic property.
    This is changed by #4 by dropping parameter $translation and the assignment ().

    Getting rid of $stringTranslation seems to be no problem since it is never used.

    But ... extending classes could explicitly call the base constructor with $translation - and e.g. CMRFSubmissionsManager does this:

    class CMRFSubmissionsManager extends CMRFManagerBase {
    
      protected $queueFactory;
    
      public function __construct($core, $translation, $queue) {
        parent::__construct($core, $translation);
    
        $this->queueFactory = $queue;
      }
    

    I am not 100% sure but I think this call will fail.

    So I think it would be better to

    • Either also correct the call in CMRFSubmissionsManager to not also use use $translation.
    • Or just declare the property $stringTranslation in CMRFManagerBase

    Any thoughts?

  • πŸ‡©πŸ‡ͺGermany gngn

    Following my thoughts in #8 I created a new patch which does not drop $stringTranslation but instead declares it.

    This way extending classes or other external usages can still explicitly call the constructor with parameter $translation (like CMRFSubmissionsManager does).

    Setting back to Needs Review.

Production build 0.71.5 2024