0
votes

TL;DR: How can I use getQuerySettings()->setEnableFieldsToBeIgnored() to work on a relation instead of the "base" table? Using array('fe_users.disable') does not work.

I have a DB model called "parks" which has three fields: "leader", "administrator" and "partner". All are optional joins on the fe_user table.

Now I want to create a repository method that fetches a park where a given fe_user is either leader, administrator or partner. This works like:

$query = $this->createQuery();
$where[] = $query->equals('parkusersLeader.uid', $userUid);
$where[] = $query->equals('parkusersAdministrators.uid', $userUid);
$where[] = $query->equals('parkusersPartner.uid', $userUid);
$query->matching($query->logicalOr($where));

This actually creates a SQL query where a JOIN is made for each of the MM-tables to the "fe_users" table, but a WHERE statement is enabled for each of the fe_users table joins, adding a "fe_users.disable=0" to it. So as soon as any park has multiple users assigned and one of the users assigned therein is disabled, the whole query will fail and not return the park.

So how can I use the setEnableFieldsToBeIgnored() method to not make extbase append the "disable" clause for a fe_user join at this place? I tried:

$query->getQuerySettings()->setEnableFieldsToBeIgnored(array('parkusersLeader.disable', 'parkusersLeader.disabled', 'fe_users.disabled', 'fe_users.disable', 'disabled', 'starttime'));

None of those seem to change the SQL query at all.

1

1 Answers

0
votes

You need to enable the option to ignore disable fields explicitely.

Have you tried setting the following for your query

$query->getQuerySettings()->setIgnoreEnableFields(true);
$query->getQuerySettings()->setEnableFieldsToBeIgnored(['disable']);

(This should ignore the disabled attribute in all records. It might be possible to be more specific in the field definition - as per your example. You could also set those globally for the repository.)