From 7928024c27f388df1ca5e56d332e0305552bffe6 Mon Sep 17 00:00:00 2001 From: git <git@1822662.no-reply.drupal.org> Date: Wed, 30 May 2012 08:42:21 +0200 Subject: [PATCH] Issue #1306196 by DuaelFr, dkinzer, DanzI, tim.plunkett: Fixed ->total_rows() is null. --- plugins/views_plugin_query_default.inc | 2 +- tests/views_pager.test | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/views_plugin_query_default.inc b/plugins/views_plugin_query_default.inc index dc8e3d53cbbe..44252fd189d1 100644 --- a/plugins/views_plugin_query_default.inc +++ b/plugins/views_plugin_query_default.inc @@ -1482,7 +1482,7 @@ function execute(&$view) { $this->pager->post_execute($view->result); - if ($this->pager->use_pager()) { + if ($this->pager->use_count_query() || !empty($view->get_total_rows)) { $view->total_rows = $this->pager->get_total_items(); } } diff --git a/tests/views_pager.test b/tests/views_pager.test index 5954e2be1db3..fef491537361 100644 --- a/tests/views_pager.test +++ b/tests/views_pager.test @@ -175,6 +175,25 @@ class ViewsPagerTest extends ViewsSqlTest { return $view; } + public function testViewTotalRowsWithoutPager() { + $this->createNodes(23); + + $view = $this->viewsPagerNoLimit(); + $view->get_total_rows = TRUE; + $view->set_display('default'); + $this->executeView($view); + + $this->assertEqual($view->total_rows, 23, "'total_rows' is calculated when pager type is 'none' and 'get_total_rows' is TRUE."); + } + + public function createNodes($count) { + if ($count >= 0) { + for ($i = 0; $i < $count; $i++) { + $this->drupalCreateNode(); + } + } + } + /** * Tests the some pager plugin. */ -- GitLab