In
#2986334: Add a way to enforce an empty result set for a database condition query →
we discovered that there was a query doing ->condition('1 <> 1')
. This only works by accident.
For example:
$query = db_select('node');
$query->condition('1 <> 1');
Compiles to
SELECT
FROM
{node} node
WHERE 11 = :db_condition_placeholder_0"]
If only $field is passed to condition()
and it is a string then throw an error because we cannot in this instance build a condition. This allows NULL to be passed in as $value but not to default to NULL in this case. That allows queries like
$query
->fields('base_table', ['workspace'])
->condition('target_entity_type_id', $entity->getEntityTypeId())
->condition('target_entity_id', $entity->id());
to continue to work as there are instances where $entity->id()
is null.
This should prevent literal SQL expressions like 1 <> 1
for working by accident.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.