Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
view_unpublished.module.patch | 2.09 KB | specky_rum |
Comments
Comment #1
czigor CreditAttribution: czigor commentedThis 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.
Comment #2
DuaelFrThis condition has been rewritten in #1192074-69: Respect View_Unpublished permissions on the Content overview page as a part of the solution.