You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FieldEntityQuery in some situations produces deprecation notices for str_replace #160
OG uses a query alter hook to accommodate EntityFieldQuery that intend to query nodes that belong to specific groups and contains specific values in their fields. This is done in og_query_og_membership_alter().
At some point in D7, a bug was fixed were the order of fieldCondition() in the EFQ query would produce wrong results. See this issue there. This patch was done in PHP 7.4, where passing an empty argument as the 3rd arg of str_replace() (currently in this line) was not a problem. But with PHP 8.1+ this produces a deprecation notice (and eventually an error). This is making some tests fail now that tests are running in PHP 8.2. (e.g. OgEntityFieldQueryFieldConditionTestCase).
The issue here is that, when you run EFQ on any entity and use method fieldCondition() to query more than one field, the first field becomes the "base table" for the query, and any subsequent field tables are joined to the first, using entity_type and entity_id as join conditions. Therefore, if you examine the SelectQuery object generated by EFQ (for example, by dumping it in EntityFieldQuery::finishQuery()) you'll see that the first element in the tables property doesn't contain conditions, while the second does:
The D7 patch I linked above, doesn't really take this fact into account, and indiscriminately uses str_replace() without checking if the array actually contains a conditions key. This leads to the deprecation notice.
The solution is simple: just check to see if (!empty($values['condition'])) {} before applying the str_replace. This fixes the test failure, and produces the expected results.
Activity
Issue backdrop-contrib#160. Check if the conditions key exists.
argiepiano commentedon Feb 12, 2026
@laryn PR #161 submitted ready for review.
argiepiano commentedon Feb 12, 2026
All tests passing now, with the modified test classes that avoid dynamic properties, AND with this patch.
Merge pull request #161 from argiepiano/1.x-2.x-issue-160