Problem/Motivation

When adding a Rest export to ie http://drupal.d8/index.php/admin/structure/views/view/frontpage/edit/res... the "Auto preview" should display something.

Currently the POST to http://drupal.d8/index.php/admin/structure/views/view/frontpage/preview/... gives error 500

[Thu Sep 18 08:11:02 2014] [error] [client 127.0.0.1] Uncaught PHP Exception Symfony\\Component\\Serializer\\Exception\\UnexpectedValueException: "Serialization for the format drupal_ajax is not supported" at /Users/clemens/Sites/drupal/d8/www/core/vendor/symfony/serializer/Symfony/Component/Serializer/Serializer.php line 77, referer: http://drupal.d8/index.php/admin/structure/views/view/frontpage/edit/rest_export_1

Proposed resolution

Pick the first available "Accepted request formats".

Remaining tasks

User interface changes

API changes

Comments

dawehner’s picture

Status: Active » Needs review
Issue tags: +VDC
StatusFileSize
new764 bytes

Interesting

Status: Needs review » Needs work

The last submitted patch, 1: rest-2340471-1.patch, failed testing.

clemens.tolboom’s picture

Status: Needs work » Needs review
StatusFileSize
new1.43 KB

The test misses preparing the stub with $view->live_preview = TRUE;

clemens.tolboom’s picture

Test fails on local

    $this->assertIdentical($actual_json, $expected, 'The expected HAL output was found.');

while the test verbose output looks like hal+json ... not sure why :-(

Status: Needs review » Needs work

The last submitted patch, 3: rest_export_views-2340471-3.patch, failed testing.

clemens.tolboom’s picture

Status: Needs work » Needs review
StatusFileSize
new759 bytes

Wrong thought ... use boolean if ($this->view->preview) {

New patch should lead to 1 fail mentioned in #4

clemens.tolboom’s picture

On local I have

strlen($expected) . ":" . strlen($actual_json)
7363:7033

Doing a pretty print $ diff --side-by-side expected-pp.json actual-pp.json | grep \| gives

                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/10"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/9"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/8"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/7"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/6"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/5"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/4"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/3"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/2"
                     "href" : "http://drupal.d8/index.php/use |	                     "href" : "http://drupal.d8/user/2"
               "href" : "http://drupal.d8/index.php/user/2"   |	               "href" : "http://drupal.d8/user/2"
            "href" : "http://drupal.d8/index.php/entity_test/ |	            "href" : "http://drupal.d8/entity_test/1"

Why is index.php added?

clemens.tolboom’s picture

A normal curl --user admin:admin --header "Accept: application/hal+json" --request GET http://drupal.d8/node/1 does not insert "index.php/"

dawehner’s picture

StatusFileSize
new3.63 KB
new3.23 KB
new3.98 KB

@clemens.tolboom

Not sure about all your work here is, but afaik the problem is basically that the existing test has a wrong setup.

Status: Needs review » Needs work

The last submitted patch, 9: views-2340471-9.patch, failed testing.

clemens.tolboom’s picture

@dawehner np as your change explains my stumbling ;-)

  1. +++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
    @@ -60,7 +61,7 @@ protected function setUp() {
    -  public function testSerializerResponses() {
    +  public function ptestSerializerResponses() {
    

    Huh? Why are most test* functions renamed to ptest* ?

  2. +++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
    @@ -259,9 +260,17 @@ public function testFieldRawOutput() {
    +      /** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */
    

    To many whitespace

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new2.3 KB
new2.54 KB

Huh? Why are most test* functions renamed to ptest* ?

This is poormanstestaccelerator.

Fixed the issues.

clemens.tolboom’s picture

Parent issue: » #2335229: [meta] REST et al
clemens.tolboom’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • webchick committed 688f773 on 8.0.x
    Issue #2340471 by clemens.tolboom, dawehner: Fixed Rest export views...

Status: Fixed » Closed (fixed)

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