Creation of dynamic properties is deprecated

Created on 25 October 2023, about 1 year ago
Updated 26 April 2024, 7 months ago

Problem/Motivation

Deprecated function: Creation of dynamic property Drupal\calendar\CalendarEvent::$date_id is deprecated in Drupal\calendar\Plugin\views\row\Calendar->render() (line 517 of modules/contrib/calendar/src/Plugin/views/row/Calendar.php).
Drupal\calendar\Plugin\views\row\Calendar->render(Object) (Line: 649)
Drupal\calendar\Plugin\views\style\Calendar->render(Array) (Line: 2181)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1551)
Drupal\views\ViewExecutable->render() (Line: 131)
Drupal\views\Plugin\views\display\Block->execute() (Line: 1648)
Drupal\views\ViewExecutable->executeDisplay('manage', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array) (Line: 59)
Drupal\views\Plugin\Block\ViewsBlock->build() (Line: 106)
Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object, 'section_component.build.render_array', Object)

Deprecated function: Creation of dynamic property Drupal\calendar\CalendarEvent::$calendar_start_date is deprecated in Drupal\calendar\Plugin\views\row\Calendar->explodeValues() (line 621 of modules/contrib/calendar/src/Plugin/views/row/Calendar.php).

Deprecated function: Creation of dynamic property Drupal\calendar\CalendarEvent::$calendar_end_date is deprecated in Drupal\calendar\Plugin\views\row\Calendar->explodeValues() (line 622 of modules/contrib/calendar/src/Plugin/views/row/Calendar.php).

Steps to reproduce

I was already on PHP 8.2, but I see the warnings after updating to Drupal 10.1.

The code also has the following in .../views/style/Calendar.php:

$item->continuation = $item->getStartDate() < $this->currentDay;
$item->continues = $days > $bucket_cnt;
$item->is_multi_day = TRUE;

None of these properties exist.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Comments & Activities

  • Issue created by @solideogloria
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    Waiting for branch to pass
  • @solideogloria opened merge request.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    Build Successful
  • Status changed to Needs review about 1 year ago
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    Waiting for branch to pass
  • I can't get any of the changes I made to work with 🐛 Multiple multiday events the second event is not showing on the next row. It is showing in the column after first event colspan ends. Needs work , even after changing the code from that issue as well in the same way I did here.

    So for now I'm just going to use #[\AllowDynamicProperties] so that I can continue making progress toward Drupal 10.

    I haven't been able to figure out why the code with the changes I make doesn't have the same result.

  • 🇮🇹Italy trickfun

    Patch works!
    Thank you

  • 🇬🇧United Kingdom chriscant

    Hello. Could this be released to as a new beta please? We're seeing on our production site and cannot easily install patches. Thanks, Chris

  • Status changed to RTBC 10 months ago
  • I'm getting these same "Deprecated function: ..." messages on my Drupal 10.2.5 site.
    I'm unclear. Is there something I can do temporarily until the next version is released?

    Thanks!

  • Yes, you can add the following to your composer.patches.json

        "drupal/calendar": {
          "#3396700: Creation of dynamic properties is deprecated": "https://www.drupal.org/files/issues/2023-10-26/calendar-dynamic-properties-3396700-5.patch"
        },
    

    And in composer.json, you would need

        "require": {
            "cweagans/composer-patches": "^1.7"
        },
        "extra": {
            "patches-file": "composer.patches.json",
            ...
        }
    

    Then run drush composer install

    • joelpittet committed beafabdb on 8.x-1.x
      Issue #3396700 by solideogloria, trickfun: Creation of dynamic...
  • Status changed to Fixed 8 months ago
  • 🇨🇦Canada joelpittet Vancouver

    I've patched dev with a new release shortly. Thanks for looking into it @solideogloria

  • When I did the steps in #10, I got this output:

    Gathering patches from patch file.

    In Patches.php line 516:

    [TypeError]
    cweagans\Composer\Patches::arrayMergeRecursiveDistinct(): Argument #1 ($arr
    ay1) must be of type array, null given, called in /home/landremanadmin/publ
    ic_html/landreman/vendor/cweagans/composer-patches/src/Patches.php on line
    123

    Exception trace:
    at /home/landremanadmin/public_html/landreman/vendor/cweagans/composer-patches/src/Patches.php:516
    cweagans\Composer\Patches->arrayMergeRecursiveDistinct() at /home/landremanadmin/public_html/landreman/vendor/cweagans/composer-patches/src/Patches.php:123
    cweagans\Composer\Patches->checkPatches() at phar:///opt/cpanel/composer/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:206
    Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///opt/cpanel/composer/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php:129
    Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///opt/cpanel/composer/bin/composer/src/Composer/Installer.php:280
    Composer\Installer->run() at phar:///opt/cpanel/composer/bin/composer/src/Composer/Command/InstallCommand.php:147
    Composer\Command\InstallCommand->execute() at phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Command/Command.php:298
    Symfony\Component\Console\Command\Command->run() at phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Application.php:1040
    Symfony\Component\Console\Application->doRunCommand() at phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Application.php:301
    Symfony\Component\Console\Application->doRun() at phar:///opt/cpanel/composer/bin/composer/src/Composer/Console/Application.php:382
    Composer\Console\Application->doRun() at phar:///opt/cpanel/composer/bin/composer/vendor/symfony/console/Application.php:171
    Symfony\Component\Console\Application->run() at phar:///opt/cpanel/composer/bin/composer/src/Composer/Console/Application.php:145
    Composer\Console\Application->run() at phar:///opt/cpanel/composer/bin/composer/bin/composer:93
    require() at /opt/cpanel/composer/bin/composer:29

    install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [
    ...]

    Is there something else I need to do?

  • I didn't post a complete composer.patches.json. Make sure your file is valid JSON.

    {
      "patches": {
        "drupal/calendar": {
          "#3396700: Creation of dynamic properties is deprecated": "https://www.drupal.org/files/issues/2023-10-26/calendar-dynamic-properties-3396700-5.patch"
        }
      }
    }
    
  • Thanks for that clarification.
    The modules works much better now.

    Thanks again.

  • Note that when the module has a new version released, you will need to remove the patch when updating your site.

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

Production build 0.71.5 2024