I'm not able to create a view with a working "REST export" display.

Steps

1. Create view with indexed source (Search API)
2. Add REST ("REST export") display to created view
3. Define path for "REST export", e.g. "/rest_bug.json"
4. Save view
5. Open path "/rest_bug.json"
6. Result: Error 500 with message "The website encountered an unexpected error. Please try again later."

Trace

AH01071: Got error 'PHP message: Error: Call to a member function id() on boolean in …/core/modules/rest/src/Plugin/views/row/DataEntityRow.php on line 86

#0 …/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php(52): Drupal\\rest\\Plugin\\views\\row\\DataEntityRow->getEntityTypeId()\n
#1 …/core/modules/rest/src/Plugin/views/row/DataEntityRow.php(115): Drupal\\rest\\Plugin\\views\\row\\DataEntityRow->getEntityTranslationRenderer()\n
#2 …/core/modules/views/src/Plugin/views/style/StylePluginBase.php(833): Drupal\\rest\\Plugin\\views\\row\\DataEntityRow->query()
#3 …/core/modules/views/src/ViewExecutable.php(1291): Drupal\\views\\Plugin\\views\\style\\StylePluginBase->query(false)
#4 …/core/modules/views/src/Plugin/views/display/PathPluginBase.php(351): Drupal\\views\\ViewExecutable->build()

Setup

Ubuntu 16.04 LTS, PHP 7.0, MySQL 5.6, Drupal 8.2

Comments

Kartoffelsalat created an issue. See original summary.

Kartoffelsalat’s picture

I have found a workaround (or the solution?):

  1. Open view for editing
  2. Select "REST export" display
  3. Change "Anzeige" (DE locale, could be named "view" or "display" in english) from "Entity" to "Fields"
  4. Save view
wim leers’s picture

Version: 8.2.5 » 8.3.x-dev
Priority: Major » Normal
Issue tags: +VDC
wim leers’s picture

Title: Call to a member function id() on boolean crashes view with REST export » REST views: Call to a member function id() on boolean causes fatal error
badrange’s picture

Thank you for this workaround Kartoffelsalat - and thank you Google for giving as one of the top search results when searching for the error message :)

wim leers’s picture

Title: REST views: Call to a member function id() on boolean causes fatal error » REST views for Search API: Call to a member function id() on boolean causes fatal error
Project: Drupal core » Search API
Version: 8.3.x-dev » 8.x-1.x-dev
Component: rest.module » General code

From the Steps To Reproduce (STR):

1. Create view with indexed source (Search API)

Moving to their issue queue.

wim leers’s picture

drunken monkey’s picture

Project: Search API » Drupal core
Version: 8.x-1.x-dev » 8.4.x-dev
Component: General code » rest.module

This does look like an issue in the REST module, yes. It might be the same as #2666226: REST views: DataEntityRow allows itself to be added to non-entity views, or just in the same direction – i.e., assuming all views use the default query plugin and display entities (of a single type).

dawehner’s picture

StatusFileSize
new836 bytes

I see the problem, this row plugins should not be available for searchapi tables.

abarrio’s picture

Status: Active » Needs work

Hi! @dawehner when you upload a patch you have to put issue with status needs review. Doing this jenkins will queue your patch to test and validate it.

abarrio’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 9: 2858814-9.patch, failed testing.

wim leers’s picture

Title: REST views for Search API: Call to a member function id() on boolean causes fatal error » REST views: fatal error when using row plugin and Views is aware of non-Entity-based tables
Status: Needs work » Needs review
StatusFileSize
new858 bytes
new948 bytes

Attempting to improve issue title.

wim leers’s picture

wim leers’s picture

Assigned: Unassigned » dawehner

D'oh, I've already said that in #7 apparently.

@dawehner?

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.

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

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

司南’s picture

How to fix this? is there anyone fixed it?

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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.

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.

needs-review-queue-bot’s picture

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

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. 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.

larowlan’s picture

larowlan’s picture

Issue tags: +Bug Smash Initiative