If you add a contextual filter "user has a revision" to a view, you will end with a broken SQL query preventing you to see the view result.
Steps to reproduce :
- Create a new content view of all content types
- Set the table style for formatting
- Create a block for it
- Add a contextual filter to your view called "User has a revision"
- Set the default value to "provided default value" and set the value as "User ID from logged in user".
- Check the preview zone, an SQL error should appear saying something like:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node_field_data.revision_uid' in 'where clause': SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid FROM {node_field_data} node_field_data WHERE ((node_field_data.revision_uid = :node_field_data_uid_revision OR ((SELECT COUNT(DISTINCT vid) FROM {node_revision} nr WHERE nfr.revision_uid = :node_field_data_uid_revision AND nr.nid = node_field_data.nid) > 0))) AND (node_field_data.status = :db_condition_placeholder_0) ORDER BY node_field_data_created DESC LIMIT 5 OFFSET 0; Array ( [:node_field_data_uid_revision] => 1 [:db_condition_placeholder_0] => 1 ).
(I don't know if it should be considered major or not since i don't a workaround appliable here). Feel free to downgrade it if necessary.
Comments
Comment #2
artusamak#2736619: Conditions on Entity Query are broken with field "revision_uid" may be related but not sure.
Comment #3
artusamakThe table name is broken for nfr so it's the first fix. The second fix refers to an unexisting uid_revision in the node_field_data table. The query conditions should be against the node_revision table.
Here is a fix for that.
Comment #4
artusamakHere is the 8.2.x patch.
Comment #5
lendudeThis fix would get this inline with the code in
\Drupal\node\Plugin\views\filter\UidRevisionso that looks good.This still needs a test though.
Comment #6
artusamakHere is the test.
First patch is red to reproduce the issue, second patch is green with the fix.
Comment #8
lendude@Artusamak nice! Looks really good already.
Ideally this would be a kernel test. We are not using the browser at all, so we can save 30 seconds of test time by leaving the browser out of this. Something like
\Drupal\Tests\node\Kernel\Views\NidArgumentTestshould point out how you can set this up, the actual test bit you wrote should just work there too. Just setting up and generating the content is slightly different.Nitpick: can just be {@inheritdoc}
Comment #9
artusamakAlright, just ask for it! Now it's converted. We will have to convert
FilterUidRevisionTestwhich is almost the same test in a follow-up issue.Here are the same tests going red and green with the fix but based on PHPUnit now.
Comment #12
lendude@Artusamak++
Needs to be
namespace Drupal\Tests\node\Kernel\Views;the testbot actually cares about that and running it locally doesn't (unless you run it through run-tests.sh)We don't do error messages anymore, so that error string can be taken out.
Comment #13
artusamakThank you for the precious feedbacks. They are now included in the patch.
Comment #21
artusamakReal green this time?
Comment #22
lendude@Artusamak nice work. We have a fix and we have a test.
Queued tests for Postgres and sqlite to be on the safe side.
Comment #24
lendudeUnrelated fail, see #2825845: DST-related test failures in FilterDateTimeTest
Comment #25
lendudeRetest passed, back to RTBC
Comment #27
lendudeAnd more unrelated fails. And back to RTBC.
Comment #28
alexpottComment #29
alexpottCommitted and pushed fb8335a to 8.4.x and ed83d7e to 8.3.x. Thanks!
Great to see more and more views test coverage.