When calling $view->init_pager() in hook_view_pre_view() or hook_view_pre_build() PHP throws following strict warning error:

Strict warning: Creating default object from empty value in view->init_pager() on row 688 in views/includes/view.inc

Comments

rossb89’s picture

I just encountered this issue myself, as a warning (PHP 5.4x)

Here is a simple patch, simply checking if $this->query is null, then create a new stdClass before $this->query->pager = $this->display_handler->get_plugin('pager'); is called.

rossb89’s picture

Version: 7.x-3.7 » 7.x-3.x-dev
Status: Active » Needs review
ann b’s picture

Patch #1 worked for me. Thanks ross.

killes@www.drop.org’s picture

Status: Needs review » Needs work

Spoke to some maintainers:

08:07 < dawehner> killes: and its wrong, it should call $this->init_query() first

nbourdial’s picture

Status: Needs work » Needs review
StatusFileSize
new410 bytes

Hi !
Facing the same issue, here is the simple updated patch with:

$this->init_query();

Correct patch attached.
Thanks

nbourdial’s picture

Hum, this way is better...

if (!isset($this->query)) {
  $this->init_query();
}
harivenuv’s picture

hi,

Try this.

rreiss’s picture

Status: Needs review » Reviewed & tested by the community

#7 Works for me.

Changed status to RTBC.
I think this should be committed to the latest dev. branch.

Thanks.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs review
Parent issue: » #2855120: Plan for Views 7.x-3.16 release
StatusFileSize
new501 bytes
new509 bytes

There's no need for both !isset() and empty().

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks.

Status: Fixed » Closed (fixed)

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