Problem/Motivation

Relationship id is missing in "file_to_node", "node_to_file", "file_to_user", "user_to_file" and other file related relationships.

Steps to reproduce

-------- From original summary - ---------------
I am trying to add a relationship "file usage" to a view. I click the submit button, but the relationship never gets added and UI never closed. I can add other relationships as expected.


To replicate (with "standard" profile):

  1. Create a new view listing node content (no displays need to be added).
  2. Don't touch the base view config in any way (the default "title" field will be the only field, etc.)
  3. Add a File Usage "File" relationship via the UI

After these steps the relationship config dialog reports "The handler for this item is broken or missing" and no config form is displayed. The relationship can then be saved on the view (without configuration) but cannot be used.

Immediately upon adding the relationship an error similar to the following is printed in the views UI:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'fid' in 'field list': SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, fid AS fid FROM {node_field_data} node_field_data WHERE (( (node_field_data.status = :db_condition_placeholder_0) )) ORDER BY node_field_data_created DESC LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 )

And a barrage of notices are logged, containing and/or repeating:

Notice: Undefined index: id in Drupal\views\Plugin\ViewsHandlerManager->getHandler() (line 109 of /var/www/drupal-8/core/modules/views/src/Plugin/ViewsHandlerManager.php).
Notice: Undefined variable: items in Drupal\views\Plugin\views\relationship\Broken->buildOptionsForm() (line 79 of /var/www/drupal-8/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php).
Notice: Undefined index: original_configuration in Drupal\views\Plugin\views\relationship\Broken->buildOptionsForm() (line 61 of /var/www/drupal-8/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php).

Proposed resolution

- Add standard relationship id

Remaining tasks

Needs review

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

CommentFileSizeAuthor
#117 interdiff.txt825 byteslauriii
#112 interdiff-2628230-110-112.txt594 bytesmohit_aghera
#112 2628230-112.patch41.03 KBmohit_aghera
#110 interdiff-2628230-105-110.txt2.72 KBmohit_aghera
#110 2628230-110.patch41.03 KBmohit_aghera
#105 interdiff-2628230-99-105.txt37.27 KBmohit_aghera
#105 test-only-2628230-105.patch37.26 KBmohit_aghera
#105 2628230-105.patch40.49 KBmohit_aghera
#99 after patch applied.png332.05 KBaziza_a
#99 before patch.png320.33 KBaziza_a
#99 2628230-99.patch3.21 KBaziza_a
#98 2628230-nr-bot.txt88 bytesneeds-review-queue-bot
#95 Screenshot 2022-10-19 at 10.35.31 PM.png80.54 KBsandip27
#95 Screenshot 2022-10-19 at 10.35.13 PM.png148.4 KBsandip27
#65 2628230-65.patch18.92 KBshubhangi1995
#56 after applying the patch.PNG77.86 KBshubhangi1995
#56 before applying patch.PNG79.62 KBshubhangi1995
#53 2628230-53.patch3.22 KBcgoffin
#52 2628230-52.patch3.83 KBcgoffin
#41 2628230-41.patch44.64 KBLendude
#41 interdiff-2628230-31-41.txt11.28 KBLendude
#31 interdiff.txt39.92 KBwadmiraal
#31 views_file_relationships_broken-2628230-31.patch41.36 KBwadmiraal
#28 interdiff.txt9.46 KBwadmiraal
#28 views_file_relationships_broken-2628230-28.patch18.46 KBwadmiraal
#26 views_file_relationships_broken-2628230-26.patch9 KBwadmiraal
#25 views_file_relationships_broken-2628230-25.patch3.22 KBwadmiraal
#12 views_file_relationships_broken-2628230-12.patch2.37 KBLendude

Issue fork drupal-2628230

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

usrsbn created an issue. See original summary.

dawehner’s picture

Can you enable the display of errors on /admin/config/development/logging? This could give some more information to start with.
Are you sure you also don't see any kind of error in the javascript error console? Its often, especially in connection with ajax work, appearing there.

usrsbn’s picture

Sorry, maybe I was a bit unclear saying that there is no error message: I meant logging / watchdog gives me no error message. There is a message in my console telling me that ajax terminated abnormally, but as that was pretty obvious I didn't mention that.

cilefen’s picture

@usrsbn Please turn off JS aggregation on the performance admin screen, get us the exact console error. Also, there may be a web server PHP you could find.

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

There is, if you enable it, some error message involved, quite sure about that.

usrsbn’s picture

@cilefen JS aggregation is off. Chromium console gave a bit more detail than Iceweasel. Heres the exact console error:
POST http://localhost:8080/drupal-8/admin/structure/views/ajax/add-handler/zeitungsdownload/block_1/relationship?_wrapper_format=drupal_ajax net::ERR_EMPTY_RESPONSE

Uncaught AjaxError: 
Eine AJAX-Anfrage ist abnormal beendet worden.
Im Folgenden finden Sie Debugging-Informationen.
Pfad: /drupal-8/admin/structure/views/ajax/add-handler/zeitungsdownload/block_1/relationship
Statustext: error
Antworttext: 
ReadyState: 0
cilefen’s picture

What is the server PHP error when that happens?

usrsbn’s picture

Today I finally made some progress. I'm now using drupal 8.0.2 and finally UI gives me this error:

Relationship: Broken/missing handler
The handler for this item is broken or missing. The following details are available:
Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.

and heres my logging info:
Notice: Undefined index: id in Drupal\views\Plugin\ViewsHandlerManager->getHandler() (line 109 of /var/www/drupal-8/core/modules/views/src/Plugin/ViewsHandlerManager.php).
Notice: Undefined variable: items in Drupal\views\Plugin\views\relationship\Broken->buildOptionsForm() (line 79 of /var/www/drupal-8/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php).
Notice: Undefined index: original_configuration in Drupal\views\Plugin\views\relationship\Broken->buildOptionsForm() (line 61 of /var/www/drupal-8/core/modules/views/src/Plugin/views/BrokenHandlerTrait.php).

rjacobs’s picture

Version: 8.0.1 » 8.0.x-dev
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

I've encountered this issue several times recently as well, with multiple 8.0.x tagged releases and HEAD.

In addition to the errors logged and noted by usrsbn, the following message is printed via the views_ui (though not logged... I'm not sure if there is something distinct to my logging setup that would explain that though):

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'fid' in 'field list': SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, fid AS fid FROM {node_field_data} node_field_data WHERE (( (node_field_data.status = :db_condition_placeholder_0) )) ORDER BY node_field_data_created DESC LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 )

This seems to occur under several different views configurations. Adding a "file usage" relationship simply appears to be impossible without resulting in a broken handler. I'm not aware of any current workaround.

I tweaked the issue summary slightly to capture error specifics.

rjacobs’s picture

Title: Views relationship file can not be added » Adding File Usage "File" relationship results in broken/missing handler
Issue summary: View changes

Additional clarification to title.

usrsbn’s picture

@rjacobs: thanks, that exactly what I get

Lendude’s picture

Component: views.module » file.module
Status: Active » Needs review
Issue tags: +VDC, +Needs tests
FileSize
2.37 KB

Turns out none of the relationships defined in FileViewsData.php have an id set for the handler.

Did some quick manual tests and this seems to help.

But oh boy does this need some tests! (and a more generic way of adding these relationships? Hardcoded adding them only to all the known core entities? Really? Feels very D7).

deensdale’s picture

Thanks Lendude, #12 fixed it for me in 8.0.3 and 8.1.0-beta2. My system is still in dev, so plenty of opportunity to test (and plenty of time to receive an official patch).

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dhendriks’s picture

Any progress on this?

dhendriks’s picture

I tested the patch in #12 on Drupal 8.1.10, and it doesn't solve the problem. I still get the same error dialog, a similar SQL query error, and 21 log entries.

dawehner’s picture

Yeah I'm also not convinced by that at all. We merge the standard relationship in there normally.

jptreen’s picture

Thanks Lendude, #12 also worked for me in 8.2.1

Shadowcub’s picture

#12 worked for me in 8.2.3. Thank you! Why isn't this fixed yet?

As a side note: It seems that the lines are off in 8.2.3; what I did was a manual patch, inserting " 'id' => 'standard' " after lines 129, 145, 164, 180, 200, 215, and 234.

Lendude’s picture

Why isn't this fixed yet?

Needs tests and probably a better (as in, more generic) fix then the thing I did in #12. The fix in #12 is fine for people needing an instant fix, but as a real fix we want to look at something better, like what @dawehner said in #18

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

takim’s picture

I m using drupal core 8.3.2 and this patch did not fix for me the error. Anybody knows or have any more patches for it?

/Takim

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wadmiraal’s picture

Re-rolled patch for 8.4.x.

Will see if I can add some failing tests. Also, should the standard handler be set as the default (in which case, the fix should be in Views)?

wadmiraal’s picture

This contains a failing test for the file_to_user relationship. It can only pass if you apply the patch from #25.

Status: Needs review » Needs work

The last submitted patch, 26: views_file_relationships_broken-2628230-26.patch, failed testing. View results

wadmiraal’s picture

This contains a failing test for the file_to_user and user_to_file relationships. It can only pass if you apply the patch from #25.

Lendude’s picture

Status: Needs work » Needs review

Lets kick the testbot into motion and see if it fails.

wadmiraal’s picture

Status: Needs review » Needs work

Hold on, I'm working on 2 new tests, and refactoring the first 2 :-). I'll upload the patch in a few minutes.

wadmiraal’s picture

Status: Needs work » Needs review
FileSize
41.36 KB
39.92 KB

This refactors the tests, merging the 3 existing User/File relationship tests into a single Kernel test (instead of a Browser test), and adds a new Kernel test for Node/File relationships.

Again: these tests will fail unless the patch from #25 is applied.

Status: Needs review » Needs work

The last submitted patch, 31: views_file_relationships_broken-2628230-31.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

wadmiraal’s picture

Assigned: Unassigned » wadmiraal
wadmiraal’s picture

Assigned: wadmiraal » Unassigned
mErilainen’s picture

Fix looks good to me. Not familiar with tests so can't mark as RTBC.

ConradFlashback’s picture

#12 works in D8.37.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bewilled’s picture

Any plans to port this to D8.5?

mErilainen’s picture

Is this fixed in 8.5.0 somehow? I have one view that I know of (in addition to default files list) which has file_usage relationship and it seems to work now without the patch. Adding a new relationship for file usage doesn't print any errors either.
It was the patch #31 which was failing, #25 still applies. That's why it worked for me.

dhendriks’s picture

Any progress on getting this actually released?

Lendude’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
11.28 KB
44.64 KB

Nice work on the tests. Bit of a clean up. This merges the fix and the tests.

Status: Needs review » Needs work

The last submitted patch, 41: 2628230-41.patch, failed testing. View results

nottaken’s picture

I came across this bug in 8.5. A little confused if this patch will/should work in 8.5?

mErilainen’s picture

@nottaken I'm just testing core update 8.4.6 -> 8.5.1 and the patch applies and works on 8.5.1 too.

UniversalDrupal’s picture

Just tested the patch in 8.5.1. When clicking in "adding fields" after the relationship is added, the field table where you can select the fields to be added has formatting issues, with the file fields all aligned on left and the others aligned on the right.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

cacrody@gmail.com’s picture

This problem keeps happening in the Drupal version 8.6.1
If the user only applies the FileViewsData.php patch , it works

Nathan Tsai’s picture

Still occurring in Drupal 8.6.2, PHP 7.0.33, & MySQL 5.7.24.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'fid' in 'field list': SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, fid AS fid FROM {node_field_data} node_field_data WHERE node_field_data.status = :db_condition_placeholder_0 ORDER BY node_field_data_created DESC LIMIT 25 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 )

Notice: Undefined index: id in Drupal\views\Plugin\ViewsHandlerManager->getHandler() (line 104 of /home/user/public_html/core/modules/views/src/Plugin/ViewsHandlerManager.php)

peterbkk’s picture

I can confirm that I am getting this issue on Drupal 8.6.10 too.

rjdavidson’s picture

Just tried patches 25 and #41 individually on my Drupal 8.6.17 site and it did not fix the issue.

rjg’s picture

On Drupal 8.7.5 I was able to apply #25 but it did not work. #12 and #41 could not be applied.

cgoffin’s picture

Here a patch for 8.7.*.

cgoffin’s picture

There were some changes that didn't belong in the patch I added. I removed them from the patch.

Chris Matthews’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Needs work » Needs review
shubhangi1995’s picture

Assigned: Unassigned » shubhangi1995
shubhangi1995’s picture

Hi all,
The patch (2628230-53.patch) has been tested against drupal core version 8.7.7
file relationship before applying the patch:
view before patch with broken handler
file relationship after applying the patch :
after patch apply

shubhangi1995’s picture

Status: Needs review » Reviewed & tested by the community

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 53: 2628230-53.patch, failed testing. View results

shubhangi1995’s picture

patch applied successfully

shubhangi1995’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 53: 2628230-53.patch, failed testing. View results

StefanieB’s picture

Status: Needs work » Reviewed & tested by the community

#53 applied to Drupal 8.8.1 fixes the problem.

alexpott’s picture

Priority: Normal » Major
Status: Reviewed & tested by the community » Needs work

It looks like #53 removed the test coverage that's in #41 - we need that test coverage in order to commit this fix and ensure we don't break this again.

This is at least a major bug - you can cause your site to error through normal operation.

shubhangi1995’s picture

Hi @alexpott, the test cases from #41 have been added to the patch from #53 and tested against drupal 8.8.1 .
it works fine.
2628230-65.patch

shubhangi1995’s picture

Status: Needs work » Needs review
sense-design’s picture

I can confirm, the patch from #66 works for my view file relationship.
After applying the path, clear the cache and add the relationship.

shubhangi1995’s picture

mmi.cse’s picture

#53 (https://www.drupal.org/project/drupal/issues/2628230#comment-13213379) worked for me on Drupal core 8.8.3. #65 was failing to apply that patch using composer.

fox_01’s picture

#53 works for me too. i have drupal 8.8.2

jamesfk’s picture

Another +1 for #53 on 8.8.1 - thank you :)

shubhangi1995’s picture

Assigned: shubhangi1995 » Unassigned
young74xxxx’s picture

Works on 8.8.6. After applying patch, must clear the cache to make it work.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

junaidpv’s picture

Patch from #65 does not apply to branch 8.8.x, not even to 8.8.1 tag. It looks like it got corrupted. However, I see it is exactly same as #53 except extra test cases and #53 still applies to current 8.9.x.

Devendra Mishra’s picture

#53 worked for me with 8.9.2. Thanks

JAINV18’s picture

#53 worked for me with 8.9.8. Thanks.

This is such a important issue and must be resolved in Core 8.9.x

Lendude’s picture

Status: Needs review » Needs work

Didn't even open the patch file in #65 but since it is 18k and the patch in #41 is 40k, I'm pretty sure it's still missing things......

Oops, should have opened it! The old patch also included a move from simpletest to phpunit, sorry!

Lendude’s picture

Status: Needs work » Needs review

Started from scratch with #41 cause as far as I can tell all sorts of things got lost in other patches. Rerolled and refactored all the simpletest stuff. The file that gets removed is a test case that is moved from a functional test to the new kernel test, so no coverage is lost there, just some testbot run time won.

Opened an MR for this.

Lendude’s picture

Opened up a branch/MR for test-only, not sure yet if that is the best way to handle test-only

ramonma1989’s picture

#53 works for me. i'm using drupal 8.9.13

Mirzero’s picture

I ran into this error in 9.1.10 also.
I couldn't use the patch from #53 directly as the file is now slightly different... but adding the ID to all of the defined relationships appears to have fixed everything (with cursory testing).

It looks like this patch alone isn't enough. It lets me add the file relationship properly, but then the view query starts to throw errors.
Using PostreSQL - looks like it's some kind of conversion issue... but I'm a bit out of my depth here.

aitala’s picture

I'm running into this in Drupal 9.2.3

I'd try the patch in #53, but....

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
apaderno’s picture

Version: 9.3.x-dev » 9.4.x-dev
DamirKhasanov’s picture

the problem is not solved

I m use Drupal 9.3.5, php 7.3 or 8.0
Adding File Usage "File" relationship results in broken/missing

Relationship: Broken/missing handler
The handler for this item is broken or missing. The following details are available:
Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.

Notice: Undefined index: id в Drupal\views\Plugin\ViewsHandlerManager->getHandler() (строка 104 из /var/www/www-root/data/www/otziv.dalem.ru/web/core/modules/views/src/Plugin/ViewsHandlerManager.php)

how do I solve it?

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

cafuego’s picture

Status: Needs review » Needs work

The patch from #53 applies fine to the current Drupal 9; remember to do a container rebuild after applying it.

How about just adding that patch to the next release, instead of keeping a major bug open for seven years because there is no test? How is that worse than actual broken functionality?

petiar’s picture

Patch #53 works on 9.4.5. What can we do to get this merged?

cilefen’s picture

It looks like we need tests someone already wrote and the patch that everyone uses integrated into a single patch or a merge request.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sandip27’s picture

It's been 7 years to this issue and seems its yet not fixed ? Weird.. I am on Drupal 9.4.8 and I am still facing this issue.. Any chance of getting the issue fixed soon ?
Screenshot 1
Screenshot 2

alfattal’s picture

Status: Needs work » Reviewed & tested by the community

Patch in #53 applied successfully on Drupal 9.5.3, PHP 8.0.28

apaderno’s picture

Status: Reviewed & tested by the community » Needs review

There are no patches in comment #53.

It is not clear why this issue has been changed to Needs work, but a comment that says the patch applies to Drupal 9.5 is not sufficient to mark the issue as Reviewed & tested by the community, especially because this is a Drupal 10 issue, now.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
88 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

aziza_a’s picture

Adding the patch again for 10.1.x
The patch of #53 applies properly on 10.1.x
adding before and after patch images, for more clarity

aziza_a’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue under control, following Review a patch or merge request as a guide.

This ticket will need a test case to show the issue.

ilfelice’s picture

Howdy,

For what it's worth, after applying the patch in #99 to a Drupal 10.0.8 installation, the errors are gone and the (file) relationships work as expected in my views.

crutch’s picture

#99 or 53 fixes the issue for 9.5.9 when applied manually

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mohit_aghera’s picture

Summarizing all the progress done so far.

Patch in #99 fixes the issue.

Patches from @Lendude #79 and #81 contains all the test cases.
However those got removed during next re-rolls.
One more attempt was done in comment #41, however #79 looks good enough to me.

Re-roll #65 also seems missing certain things.

I've combined all the progress, and performed necessary tweaks in test cases and patch.

I have included an interdiff, however it mostly contains all the test cases.
Also, included test-only patch for reference. We already have a PR which is failing.

Updated issue summary and hiding all other unnecessary patches.

mohit_aghera’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
mohit_aghera’s picture

Issue tags: +Bug Smash Initiative

The last submitted patch, 105: 2628230-105.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 105: test-only-2628230-105.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review
FileSize
41.03 KB
2.72 KB

I think I put views config files in incorrect folder and that is causing issues.
Fixing in the patch.

Also, missed a couple of module dependencies in code formatting fixes.
Adding those again. All the failing tests are passing on local now.

Status: Needs review » Needs work

The last submitted patch, 110: 2628230-110.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review
FileSize
41.03 KB
594 bytes

Removing depredations.

nubeli’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed and tested the patch in #112, which includes tests. Looks like it's all in order. I've applied the patch with composer locally and then did a drush cache rebuild. The error disappears.

I'm not clear why this was switched to the 11.x-dev version back in #103. According to https://www.drupal.org/about/core/policies/core-release-cycles/schedule it seems that this bug fix could even go into 9.5.x. At the very least 10.0.x.

smustgrave’s picture

11.x is the current development branch. All code is committed there first and case by case backported to previous versions.

  • lauriii committed b8e76446 on 11.x
    Issue #2628230 by Lendude, mohit_aghera, wadmiraal, usrsbn, cilefen,...

  • lauriii committed 01f82e3f on 10.1.x
    Issue #2628230 by Lendude, mohit_aghera, wadmiraal, usrsbn, cilefen,...
lauriii’s picture

Version: 11.x-dev » 10.0.x-dev
FileSize
825 bytes

The fix looks right and was provided by one of the subsystem maintainers of Views 👍

The test coverage looks good 👍 Made a minor adjustments on commit to the modules installed for the test.

Committed b8e7644 and pushed to 11.x. Also cherry-picked to 10.1.x. Thanks!

This may be qualified for a backport to 10.0.x and 9.5.x but checking with other committer.

Spokje’s picture

Status: Reviewed & tested by the community » Needs work

This commit has broken HEAD on 11.x and 10.1.x for pgsql only.

TestBot merrily gives us the middle finger with:

1) Drupal\Tests\file\Kernel\Views\RelationshipNodeFileDataTest::testViewsHandlerRelationshipFileToNode
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in test_file_to_node[test_file_to_node]: SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: character varying = bigint
LINE 5: ...ta" "node_field_data_file_usage" ON file_usage.id = node_fie...
                                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.: SELECT "file_managed"."fid" AS "fid", "node_field_data_file_usage"."nid" AS "node_field_data_file_usage_nid"
FROM
"test20724246file_managed" "file_managed"
LEFT JOIN "test20724246file_usage" "file_usage" ON file_managed.fid = file_usage.fid
INNER JOIN "test20724246node_field_data" "node_field_data_file_usage" ON file_usage.id = node_field_data_file_usage.nid AND file_usage.type = :views_join_condition_0
LIMIT 11 OFFSET 0; Array
(
    [:views_join_condition_0] => node
)

/var/www/html/core/modules/views/src/Plugin/views/query/Sql.php:1563
/var/www/html/core/modules/views/src/ViewExecutable.php:1441
/var/www/html/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php:127
/var/www/html/core/modules/file/tests/src/Kernel/Views/RelationshipNodeFileDataTest.php:115
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

2) Drupal\Tests\file\Kernel\Views\RelationshipNodeFileDataTest::testViewsHandlerRelationshipNodeToFile
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in test_node_to_file[test_node_to_file]: SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: bigint = character varying
LINE 4: ...53file_usage" "file_usage" ON node_field_data.nid = file_usa...
                                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.: SELECT "node_field_data"."nid" AS "nid", "file_managed_file_usage"."fid" AS "file_managed_file_usage_fid"
FROM
"test13514853node_field_data" "node_field_data"
LEFT JOIN "test13514853file_usage" "file_usage" ON node_field_data.nid = file_usage.id AND file_usage.type = :views_join_condition_0
INNER JOIN "test13514853file_managed" "file_managed_file_usage" ON file_usage.fid = file_managed_file_usage.fid
LIMIT 11 OFFSET 0; Array
(
    [:views_join_condition_0] => node
)

/var/www/html/core/modules/views/src/Plugin/views/query/Sql.php:1563
/var/www/html/core/modules/views/src/ViewExecutable.php:1441
/var/www/html/core/modules/views/tests/src/Kernel/ViewsKernelTestBase.php:127
/var/www/html/core/modules/file/tests/src/Kernel/Views/RelationshipNodeFileDataTest.php:177
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

See for example: https://www.drupal.org/pift-ci-job/2682293

Unsure if we need to do the Rollbak-Rumba, or attempt a hotfix in here.

Spokje’s picture

Version: 10.0.x-dev » 11.x-dev
lauriii’s picture

It looks like the id column is a string whereas nid is an integer. Because of this, the patch only works with MySQL which is more relaxed about types. We need to decide whether we skip the tests for other database types than MySQL and fix this for other databases in a follow-up or revert this. The reason I think it might be fine to postpone fixing PostgreSQL to a follow-up is that the experience before and after this change is pretty much the same, it's just a different error that is being triggered now.

lauriii’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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