From b8129e5b08a80a3eed0ce035b01d8371ce59b708 Mon Sep 17 00:00:00 2001 From: daspeter <daspeter@762870.no-reply.drupal.org> Date: Mon, 16 Jul 2012 09:58:03 +0200 Subject: [PATCH] Issue #1368508 by tim.plunkett, das-peter: Added Document and enforce nummeric array keys starting at 0 for ->result. --- lib/Drupal/views/View.php | 11 ++++++++++- plugins/views_plugin_query.inc | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Drupal/views/View.php b/lib/Drupal/views/View.php index 715d730c6aa3..6a00fe99aae3 100644 --- a/lib/Drupal/views/View.php +++ b/lib/Drupal/views/View.php @@ -96,7 +96,13 @@ class View extends ViewsDbObject { var $use_ajax = FALSE; - // Where the results of a query will go. + /** + * Where the results of a query will go. + * + * The array must use a numeric index starting at 0. + * + * @var array + */ var $result = array(); // May be used to override the current pager info. @@ -1140,6 +1146,9 @@ function execute($display_id = NULL) { } else { $this->query->execute($this); + // Enforce the array key rule as documented in + // views_plugin_query::execute(). + $this->result = array_values($this->result); $this->_post_execute(); if ($cache) { $cache->cache_set('results'); diff --git a/plugins/views_plugin_query.inc b/plugins/views_plugin_query.inc index 59982cdcfd08..d39ed989866c 100644 --- a/plugins/views_plugin_query.inc +++ b/plugins/views_plugin_query.inc @@ -65,7 +65,8 @@ function build(&$view) { } * Values to set: $view->result, $view->total_rows, $view->execute_time, * $view->pager['current_page']. * - * $view->result should contain an array of objects. + * $view->result should contain an array of objects. The array must use a + * numeric index starting at 0. * * @param view $view * The view which is executed. -- GitLab