This module appears to not work with large data sets because it forces the return of all records.

I am sure others would have found this a few hours sooner than me, but I did not consider this module overriding the range limit. The following call appears to reset the limit to zero.


class views_php_plugin_pager extends views_php_plugin_wrapper {
  /**
   * Perform any needed actions just prior to the query executing.
   */
  public function pre_execute($query) {

    $this->wrapped->view->query->set_limit(0);  
    $this->wrapped->view->query->set_offset(0); 

Comments

furamag’s picture

I modified file plugins/views/views_php_plugin_pager.inc to fix this issue. To fix this bug replace function "post_execute" with following code:

  public function post_execute(&$result) {
    foreach (array(/*'argument',*/ 'field', 'filter', 'sort', /*'relationship'*/) as $type) {
      foreach ($this->wrapped->view->$type as $id => $handler) {
        if (is_callable(array($handler, 'php_post_execute'))) {
          $handler->php_post_execute();
        }
      }
    }

    $this->wrapped->total_items = count($this->wrapped->view->result);
    $this->wrapped->update_page_info();

    $item_per_page = $this->wrapped->get_items_per_page();
    // Get offset value.
    $offset_value = $this->wrapped->get_offset();
    // Check if item per page or offset > 0.
    if ($item_per_page > 0 || $offset_value > 0) {
      // Check if item per page > 0.
      if ($item_per_page == 0) {
        // Set item per page to 999999 to be sure we display all results.
        $item_per_page = 999999;
      }
      $offset = $this->wrapped->get_current_page() * $item_per_page + $this->wrapped->get_offset();
      $this->wrapped->view->result = array_slice($this->wrapped->view->result, $offset, $item_per_page);
    }
    $this->wrapped->post_execute($result);
  }

I didn't have much time to test this code but it works for me. I'll try to create patch based on this modification by the end of this week. Let me know if you have any issues with this code.

prakin’s picture

I have the same problem... The global php is not setting the LIMIT.

prakin’s picture

I have the same problem... The global php is not setting the LIMIT.

josebc’s picture

same problem here , subscribe

mustanggb’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)