Problem/Motivation

PHP 8.2 deprecated dynamic properties (creating class properties on-the-fly without declaring them). The Drupal\entity_sync\DelayedExecutor\Executor class assigns $this->exportManager and $this->queueManager in the constructor without declaring these properties, causing deprecation warnings:

Deprecated function: Creation of dynamic property Drupal\entity_sync\DelayedExecutor\Executor::$queueManager is deprecated

Steps to reproduce

1. Run PHP 8.2 or higher
2. Enable entity_sync module
3. Trigger any action that instantiates the DelayedExecutor\Executor service
4. Observe deprecation warning in logs

Proposed resolution

Add explicit property declarations to the Executor class:

/**
 * The Entity Synchronization entity export manager.
 *
 * @var \Drupal\entity_sync\Export\EntityManagerInterface
 */
protected $exportManager;

/**
 * The Entity Synchronization queue manager.
 *
 * @var \Drupal\entity_sync\Queue\ManagerInterface
 */
protected $queueManager;

Comments

shabana.navas created an issue. See original summary.

shabana.navas’s picture

Status: Active » Needs review
StatusFileSize
new706 bytes

Patch.

shabana.navas’s picture

StatusFileSize
new2.39 KB

More deprecation warnings.

shabana.navas’s picture

Title: PHP 8.2+ deprecation: Dynamic properties in DelayedExecutor\Executor » PHP 8.2+ deprecation: Creation of dynamic property is deprecated
vinodhini.e’s picture

Hi,

Tested this issue on Drupal 10.6.10 with PHP 8.4 and was able to reproduce the deprecation error described in the issue summary. Applied the patch and retested. The deprecation error are no longer displayed, and its working as expected.

Thanks.

jsacksick’s picture

Just noting that the changes from this issue were also blended in https://git.drupalcode.org/project/entity_sync/-/merge_requests/70 which introduces D11 support and fix similar issues in other places.

  • krystalcode committed 8bf94d7b on 4.x
    Issue #3568454 Fixed deprecation for dynamic property creation
    
    By:...

  • krystalcode committed 8bf94d7b on 5.x
    Issue #3568454 Fixed deprecation for dynamic property creation
    
    By:...
krystalcode’s picture

Title: PHP 8.2+ deprecation: Creation of dynamic property is deprecated » PHP 8.2+ deprecation: Creation of dynamic property is deprecatedhttps://www.drupal.org/docs/develop/issues
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • krystalcode committed 242d4bdc on 4.x
    Issue #3568454 Fixed deprecations for dynamic property creations
    

  • krystalcode committed 242d4bdc on 5.x
    Issue #3568454 Fixed deprecations for dynamic property creations
    
jsacksick’s picture

@krystalcode: The indentation is off in this commit https://git.drupalcode.org/project/entity_sync/-/commit/8bf94d7bdafcc601...

4 spaces instead of 2.

  • krystalcode committed 3c24eeb7 on 5.x
    Issue #3568454 Fixed indentation messed up in earlier commit
    

  • krystalcode committed 949ef288 on 5.x
    Issue #3568454 Corrected unnecessary property value assignment
    
    We're...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.