Problem/Motivation

The flag_bookmark view is broken, is not installed automatically when the module is enabled and when you install it manually and go to /bookmarks a fatal error appears.

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in flag_bookmark[flag_bookmark]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '1') AND (.uid IS NOT NULL ) ))) subquery' at line 2: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node} node INNER JOIN {users_field_data} users_field_data_node_field_data ON uid = users_field_data_node_field_data.uid WHERE (( (.status = :db_condition_placeholder_0) AND (.uid IS NOT NULL ) ))) subquery; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\views\Plugin\views\query\Sql->execute()

So this is related to #2448881: Adding relationship to user views does not work $this->tableAlias is empty, and there is no join.

Proposed resolution

Update the flag_bookmarks view.

Remaining tasks

Create patch.

User interface changes

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

giancarlosotelo created an issue. See original summary.

socketwench’s picture

Status: Active » Postponed
socketwench’s picture

Stashing some work here to update the view while working on another issue.

edurenye’s picture

Status: Postponed » Needs work

This issue is fixed, so we can work on it again.
And this patch was empty.

edurenye’s picture

I think that the problem here is that in FlagViewsFilter doesn't have set the relationship, so the ensureMyTable set tableAlias to NULL, that's why is doing "(.uid IS NOT NULL)"

Requiring this relationship we don't need the filter anymore, so set to required and deleted the filter from the view.
This is the result:

Also fixed the buildOptionsForm and added the schema for the filter, I'm not sure if I have to fix it or we should drop the filter directly.

I think we can add tests here with check config schema disabled an enable it in this issue #2555365: Add views schema for flag_relationship.

The last submitted patch, 5: flag_bookmark_view_is-2562971-5-test_only.patch, failed testing.

Berdir’s picture

Status: Needs review » Needs work
+++ b/flag_bookmark/src/Tests/FlagBookmarkUITest.php
@@ -0,0 +1,78 @@
+
+    $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
+

Interesting, the bookmark flag has configuration enabled for article and page node types, but we can enable it when those don't exist. We're either missing calculateDependencies() implementations on those plugins or haven't updated the default config there. Not a problem if this issue, but it's going to bite us at some point when we implement that properly, then a) tests like this won't work anymore and b) the module won't be installable on non-standard based install profiles.

+++ b/flag_bookmark/src/Tests/FlagBookmarkUITest.php
@@ -0,0 +1,78 @@
+
+  public static $modules = array(
+    'views',
+    'flag',
+    'flag_bookmark',
+  );
+
+  protected $strictConfigSchema = FALSE;

missing docblocks.

I think we should either leave out the config scheme here completely or we should just include the remaining part of the config schema fix from the other issue in either. The current state of adding a bit of config schema but not actually testing it seems a bit weird.

joachim’s picture

> We're either missing calculateDependencies() implementations on those plugins

Very likely!

edurenye’s picture

Status: Needs work » Needs review
FileSize
14.42 KB

Ok in case, I'll upload the two patches, this is with the schema errors fixed from this issue #2555365: Add views schema for flag_relationship.
Adding the bookmark view has apeared new schema errors that I had to fix.

edurenye’s picture

Here the second patch without schema fix.

martin107’s picture

I am limiting this review to just the new test ( FlagBookmarkUITest )

Yep, looks clean -- it will prevent recurrences of the problem - so +1 from me!

Also phpcs reports no cs snafu's

dswier’s picture

Confirming that flag_bookmark_view_is-2562971-10.patch works for me. I now get the Flag Bookmark List view after enabling flag_bookmark.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

I think this is ready.

It's up to @joachim to decide which patch to commit. #9 includes the schema fixes from that other issue already and we could just close this or #10, which is with config schema checking disabled, then we need to reroll the other issue and just remove the disabled flag in the test.

The last submitted patch, 3: 2562971.3.updateBookmarksView.patch, failed testing.

The last submitted patch, 5: flag_bookmark_view_is-2562971-5-test_only.patch, failed testing.

  • edurenye authored 10e5201 on 8.x-4.x
    Issue #2562971 by edurenye, socketwench: Fixed broken flag bookmark view...
socketwench’s picture

Status: Reviewed & tested by the community » Fixed

Since this has sat for over month, I decided to take the smaller patch. We will need to split off the related fixes into a separate issue.

socketwench’s picture

FileSize
7.12 KB

Remaining fixes for reference.

socketwench’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.