Dynamic property issue in ConfigEntityQuery with PHP 8.2

Created on 2 August 2023, over 1 year ago
Updated 15 September 2024, 2 months ago

Problem/Motivation

Dynamic Properties are deprecated in PHP 8.2 (see: https://php.watch/versions/8.2/dynamic-properties-deprecated)

Steps to reproduce

Install module and replace some views, then visit a replaced view. You should see a warning message.

Proposed resolution

I have created a patch to fix this issue for the ConfigEntityQuery class.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇸🇪Sweden ordermind

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

Comments & Activities

  • Issue created by @ordermind
  • 🇮🇳India mukhtarm

    Not able to reproduce this issue in D10.1.1, php 8.2. I enabled the Text formats and editors and it is working fine.

  • 🇮🇳India dineshkumarbollu

    @ordermind

    Installed in Drupal 10.2 with 8.2 unable reproduce the issue, can you steps to reproduce the issue(if i am missing anything).

  • 🇺🇸United States mortona2k Seattle

    I have this message appearing. Config Views 2.1.1, PHP 8.2.

    The patch is simple, it just adds the property that it's complaining about. I can't test at the moment, but it looks like it will fix it.

    Deprecated function: Creation of dynamic property Drupal\config_views\Plugin\views\query\ConfigEntityQuery::$group_operator is deprecated in Drupal\config_views\Plugin\views\query\ConfigEntityQuery->execute() (line 106 of modules/contrib/config_views/src/Plugin/views/query/ConfigEntityQuery.php).
    
    Drupal\config_views\Plugin\views\query\ConfigEntityQuery->execute(Object) (Line: 1441)
    Drupal\views\ViewExecutable->execute(NULL) (Line: 1469)
    Drupal\views\ViewExecutable->render() (Line: 199)
    Drupal\views\Plugin\views\display\Page->execute() (Line: 1645)
    Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 81)
    Drupal\views\Element\View::preRenderViewElement(Array)
    call_user_func_array(Array, Array) (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 859)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
    Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
    call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
  • 🇺🇸United States swirt Florida

    Confirmed: I am seeing the same error as mortona2k on Drupal 10.1 and php8.2

  • Status changed to RTBC 8 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    1 pass
  • 🇺🇸United States nadavoid

    I applied the from comment number two, and it resolved the issue for me. Marking this RTBC, but feel free to change if there's more work to be done.

  • 🇦🇹Austria maxilein

    I am seeing the same error on D10.2.7 and php 8.3.
    And this patch fixed it.

  • Status changed to Needs review 2 months ago
  • 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin

    There is an attempt to solve this deprecation warning in the other issue queue of the project duplicate of config views (do not let me start with it, I have already posted over there to clarify the status of the project but this is not the scope of this issue here) which I think should be linked here to discuss why it has been solved almost similar but a bit different over there: patch | issue 🐛 Dynamic property issue in ConfigEntityQuery with PHP 8.2 RTBC

    Also we need to check/test if this fix in here will raise other issues later, since NULL can spit type Errors on other calls.

  • 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin

    Finally, if we agree about the fix here, we should consider to merge it into an upcoming release with the Drupal 11 compatibility fix together since both refer to newer PHP and Drupal versions. Druapl 11 requires php 8.3 minimum so this issue here becomes related to 📌 Automated Drupal 11 compatibility fixes for config_views Active

  • 🇺🇸United States RoloDMonkey

    I had this error. I reviewed and tested the patch, and it all looks good to me.

Production build 0.71.5 2024