Problem/Motivation

A lot of PHP 8.2 tests currently fail like this:

Exception: Deprecated function: Creation of dynamic property Drupal\Core\Database\Query\Condition::$sqlQuery is deprecated
Drupal\Core\Entity\Query\Sql\Condition->compile()() (Line: 44)

Steps to reproduce

What's happening is that this is a trick to pass the query object to the compile method of its child condition (entity query condition object, not SQL condition).

Proposed resolution

There is already a better pattern used in the same place. Set a documented, protected property of itself on the child object, which works because it's the same class.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Anonymous’s picture

I have checked with drupal 10.1.x and the patch applies successfully.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

It may need a test but PHP 8.2 already used to catch it via existing coverage

See #3295821-114: Ignore: patch testing issue for PHP 8.2 attributes

  • catch committed b94cecd on 10.0.x
    Issue #3311562 by Berdir, andypost: Set sqlQuery in Entity\Query\Sql...
  • catch committed e9afcbc on 10.1.x
    Issue #3311562 by Berdir, andypost: Set sqlQuery in Entity\Query\Sql...
  • catch committed 075c691 on 9.5.x
    Issue #3311562 by Berdir, andypost: Set sqlQuery in Entity\Query\Sql...
catch’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Given existing test coverage is catching the PHP 8.2 issue and tests are passing, I don't think we need to add explicit new test coverage here.

Committed/pushed to 10.1.x and cherry-picked back through to 9.5.x, thanks!

mfb’s picture

FYI, this cherry-pick broke 9.5.x branch on PHP 7.3 - the property type declaration requires PHP 7.4

  • catch committed b083e40 on 9.5.x
    Revert "Issue #3311562 by Berdir, andypost: Set sqlQuery in Entity\Query...
catch’s picture

Status: Fixed » Needs work

Reverted on 9.5.x, we could probably recommit just with the type hint removed.

ravi.shankar’s picture

Status: Needs work » Needs review
FileSize
3.38 KB
1.01 KB

Removed type hint from $sqlQuery property.

andypost’s picture

Queued for 7.3

andypost’s picture

Status: Needs review » Reviewed & tested by the community

passed!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3098069 and pushed to 9.5.x. Thanks!

  • alexpott committed 3098069 on 9.5.x
    Issue #3311562 by ravi.shankar, Berdir, andypost, catch: Set sqlQuery in...

Status: Fixed » Closed (fixed)

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