Hi,

I've been getting the following warning while using the module:

Warning: Illegal string offset 'field' in view_unpublished_query_alter() (line 139 of C:\inetpub\wwwroot\code\drupal\sites\all\modules\view_unpublished\view_unpublished.module).

A patch is attached with a simple logic change that fixes the issue. It changes the if block from:

if (isset($condition['field']) && $condition['field'] === 'n.status') {
  // do stuff
}
elseif (is_object($condition['field'])){
  // do stuff
}

to

if (isset($condition['field'])){
  if ($condition['field'] === 'n.status') {
    // do stuff
  }
  elseif (is_object($condition['field'])){
    // do stuff
  }
}

Hope that looks OK. The comments could probably use a rejig too!

Tom

CommentFileSizeAuthor
view_unpublished.module.patch2.09 KBspecky_rum
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

czigor’s picture

Status: Active » Reviewed & tested by the community

This warning appears only from PHP 5.4:
"As of PHP 5.4 string offsets have to either be integers or integer-like strings, otherwise a warning will be thrown. Previously an offset like "foo" was silently cast to 0. "
http://www.php.net/manual/en/language.types.string.php

The patch makes sense and also works for me.

DuaelFr’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Closed (duplicate)

This condition has been rewritten in #1192074-69: Respect View_Unpublished permissions on the Content overview page as a part of the solution.