The patch for #768294: Views Block still visible without values in OpenLayers view introduced a new issue. When the query is overridden, the results array is filled with a boolean instead of an array. The faulty line is:

$this->view->result = TRUE;

This leads to error messages if the results array is post-rendered or processed in any way after the query has been run. For instance: in the search_api_views module SearchApiViewsQuery:get_result_wrappers() gives an error because TRUE is passed to a foreach loop.
I believe the view result should be set to an empty array instead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

basvredeling’s picture

Status: Active » Needs review

Oh, this needs a review.

FYI, view.inc defines the result property as follows:

/**
* Where the results of a query will go.
*
* The array must use a numeric index starting at 0.
*
* @var array
*/
var $result = array();

so setting it as true is not a good idea.

Pol’s picture

Status: Needs review » Fixed

  • Pol committed c807985 on authored by basvredeling
    Issue #2457303 by basvredeling: Wrong type passed to $view->results on...
basvredeling’s picture

Status: Fixed » Needs review
FileSize
1.02 KB

Sorry Pol, while I was working on an updated patch you committed it.
This just needed some more work.
The code 2 lines down also injects a boolean or string into the result array. All to hide empty blocks.

$this->view->result = $render || !$map->data['hide_empty_map'] ? TRUE : FALSE;

I'm not 100% sure about this solution but it seems to work (also with views_geojson based maps).

Pol’s picture

Status: Needs review » Fixed

Indeed, this patch is better.

Thanks !

  • Pol committed 53dd2ca on 7.x-2.x authored by basvredeling
    Issue #2457303 by basvredeling: Wrong type passed to $view->results on...
basvredeling’s picture

FileSize
819 bytes


This last patch was missing another small piece of code. $this->map was not set on the object.
Final fix here. This patch is made against latest dev. It doesn't include the commit of #4.

basvredeling’s picture

Priority: Normal » Major
Status: Fixed » Needs review

Please review urgently, currently applied patch breaks some maps.

Pol’s picture

Status: Needs review » Fixed

  • Pol committed 0e66d61 on 7.x-2.x authored by basvredeling
    Issue #2457303 by basvredeling: Wrong type passed to $view->results on...

Status: Fixed » Closed (fixed)

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