Index: plugins/views/views_php_handler_field.inc =================================================================== --- plugins/views/views_php_handler_field.inc (revision 458) +++ plugins/views/views_php_handler_field.inc (working copy) @@ -198,6 +198,22 @@ * Implements views_handler_field#pre_render(). */ function pre_render(&$values) { +// start insert issue 1140896 + // Execute value PHP code. + if (!empty($this->options['php_value'])) { + $function = create_function('$view, $handler, &$static, $row, $data', $this->options['php_value'] . ';'); + ob_start(); + foreach ($this->view->result as $i => &$row) { + $normalized_row = new stdClass; + foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) { + $normalized_row->$field = isset($row->{$handler->field_alias}) ? $row->{$handler->field_alias} : NULL; + } + $row->{$this->field_alias} = $function($this->view, $this, $this->php_static_variable, $normalized_row, $row); + } + ob_end_clean(); + } +// end insert issue 1140896 + if (!empty($this->options['php_output'])) { $this->php_output_lamda_function = create_function('$view, $handler, &$static, $row, $data, $value', ' ?>' . $this->options['php_output'] . 'view->result as $i => $row) { $normalized_row = new stdClass; foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) { - $normalized_row->$field = isset($row->{$handler->field_alias}) ? $row->{$handler->field_alias} : NULL; +//-1140896 $normalized_row->$field = isset($row->{$handler->field_alias}) ? $row->{$handler->field_alias} : NULL; + $normalized_row->$field = isset($row->{'field_'.$field}) ? $row->{'field_'.$field} : NULL; } if ($function($this->view, $this, $this->php_static_variable, $normalized_row, $row)) { unset($this->view->result[$i]); Index: plugins/views/views_php_plugin_pager.inc =================================================================== --- plugins/views/views_php_plugin_pager.inc (revision 458) +++ plugins/views/views_php_plugin_pager.inc (working copy) @@ -29,6 +29,7 @@ * Perform any needed actions just after the query executing. */ public function post_execute(&$result) { +/* @TODO Issue 1140896: We're now using this in pre_render instead. 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'))) { @@ -36,7 +37,7 @@ } } } - +*/ $this->wrapped->total_items = count($this->wrapped->view->result); $this->wrapped->update_page_info(); Index: views_php.module =================================================================== --- views_php.module (revision 458) +++ views_php.module (working copy) @@ -143,8 +143,36 @@ * Implements hook_views_post_execute(). */ function views_php_views_post_execute($view) { +/* start 1140896 +// Issue http://drupal.org/node/1140896 +// We don't need to unwrap since we're doing it in pre-render now. // Restore original query plugin if it was wrapped. if ($view->query instanceof views_php_plugin_wrapper) { $view->query->php_unwrap(); } +*/ } + +/** + * Implements hook_views_post_execute(). + */ +function views_php_views_pre_render($view) { + foreach (array( + //'argument', + 'field', + 'filter', + 'sort', + //'relationship' + ) as $type) { + foreach ($view->$type as $id => $handler) { + // dpm($handler); + if (is_callable(array($handler, 'php_post_execute'))) { + $handler->php_post_execute(); + } + } + } + + if ($view->query instanceof views_php_plugin_wrapper) { + $view->query->php_unwrap(); + } +}