Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Steps to reproduce:
- Enable the "REST" and "Serialization" module
- Create a view without block and page, but add a "REST export". Give the view a path and save it.
- Now, a lot of forms will not submit. For instance edit the body field of the article content type ( admin/structure/types/manage/article/fields/node.article.body/field ). Change the "Allowed number of values" to limited and try to save. It will result in the "Method Not Allowed" error. If you disable the view and try to edit the same field setting it will work.
I'm not sure if the problem is from views, rest, or even another component.
Comment | File | Size | Author |
---|---|---|---|
#14 | rest-export-2065949.fail_.patch | 4.86 KB | larowlan |
#14 | rest-export-2065949.pass_.patch | 6.13 KB | larowlan |
#12 | rest-export-2065949.do-not-test.patch | 5.63 KB | larowlan |
#12 | rest-export-2065949.interdiff.txt | 5.6 KB | larowlan |
#11 | rest-export-2065949.do-not-test.patch | 5.6 KB | larowlan |
Comments
Comment #1
idflood CreditAttribution: idflood commentedAfter looking at some code I'm still not sure where the problem is but it may be more related to the rest module than views.
edit: It seems to be related to the requirements defined in rest/lib/Drupal/rest/Plugin/views/display/RestExport.php->collectRoutes.
Comment #2
idflood CreditAttribution: idflood commentedHere is a first patch. Not sure if this really works but at least it doesn't give the error on forms.
Comment #3
idflood CreditAttribution: idflood commentedComment #4
klausiInteresting, this totally makes sense, thanks for catching this. Of course we should not modify all routes, but only our own.
Patch looks good, but this needs a test case. I think we can just unit-test collectRoutes() and check that it only modifies its own routes that are passed in a collection.
Comment #5
idflood CreditAttribution: idflood commentedI've started to work on a test. But it is not really executed, any idea why ? (0 pass, 0 fail, ... no test result to display)
edit: there was a little syntax error but even with it corrected it doesn't execute the test. (I was using [] instead of array() )
Comment #7
idflood CreditAttribution: idflood commentedSame patch as #5 but with the typo corrected. The patch is still not really executed (no test result to display).
Comment #8
klausiShould be "... for the collectRoutes() method."
Scope modifier missing, I think it is protected.
All class properties should be defined explicitly.
And shouldn't you test the requirements of one valid route that belongs to the plugin and should be modified?
Comment #9
idflood CreditAttribution: idflood commentedThanks for the review, I've updated the test.
I haven't fixed this since I have no idea of how it can be done.
I changed the test location and took example on the views module for the test on the advice of berdir. The test still doesn't work, but when executed from the command line it gives an interesting error.
The command: cd core; ./vendor/bin/phpunit --filter=CollectRoutesTest
Comment #11
larowlankicked this along some more, but stuck on
Comment #12
larowlanSorry, that was the interdiff.
Full test and interdiff
Comment #13
larowlanthis is at least major, if not critical
Comment #14
larowlanview != views - fixed
So we should have red/green here.
Comment #15
larowlanGiven that once any view of this type is added, any non GET request returns a Method Not Allowed
Comment #16
tim.plunkettThis makes a lot more sense when you view the patch without whitespace changes:
Running the test without the fix, it has 1 error:
Looks good to me, nice work.
Comment #17
catchLooks good to me. Committed/pushed to 8.x, thanks!