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.
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 ofstr_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, usingentity_typeandentity_idas join conditions. Therefore, if you examine theSelectQueryobject generated by EFQ (for example, by dumping it inEntityFieldQuery::finishQuery()) you'll see that the first element in thetablesproperty 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 aconditionskey. 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.