From 44c8781dc669f6a51333542e63edcd6051e06178 Mon Sep 17 00:00:00 2001 From: "hh.lohmann" Date: Wed, 21 May 2014 10:02:24 +0200 Subject: [PATCH 1/5] Illegal string offset '_elem' in action.php on line 205 solution: put the following line at the begin of the foreach loop starting in line 204: `if ( !isset ( $ref ['_elem'] ) ) { break ; }` See also https://www.dokuwiki.org/plugin:publish#error_when_using_the_old_revisions_view --- action.php | 1 + 1 file changed, 1 insertion(+) diff --git a/action.php b/action.php index 86fd7d5..ef54af8 100644 --- a/action.php +++ b/action.php @@ -202,6 +202,7 @@ function handle_revisions(&$event, $param) { $member = null; foreach($event->data->_content as $key => $ref) { + if ( !isset ( $ref ['_elem'] ) ) { break ; } if($ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') { $member = $key; } From 615f6658e6e3d39186c29fffc6f1417d007abe04 Mon Sep 17 00:00:00 2001 From: "hh.lohmann" Date: Wed, 21 May 2014 10:11:51 +0200 Subject: [PATCH 2/5] Illegal string offset '_elem' in action.php on line 231 (or 232) solution: put the following line at the begin of the foreach loop starting in line 230 or 231 (inside "handle_recent"): `if ( !isset ( $ref ['_elem'] ) ) { break ; }` --- action.php | 1 + 1 file changed, 1 insertion(+) diff --git a/action.php b/action.php index ef54af8..991a1c3 100644 --- a/action.php +++ b/action.php @@ -229,6 +229,7 @@ function handle_recent(&$event, $param) { $member = null; foreach($event->data->_content as $key => $ref) { + if ( !isset ( $ref ['_elem'] ) ) { break ; } if($ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') { $member = $key; } From 531c2c8582ebf6aff5b9482a55e8d7cac49cdd7d Mon Sep 17 00:00:00 2001 From: "hh.lohmann" Date: Wed, 21 May 2014 10:51:44 +0200 Subject: [PATCH 3/5] Illegal string offset '_elem' in action.php on line 205 - CORRECTION sorry, simple PHP break dos not do the full job, we need to check all `$ref` items in the `if` clause that sets `$member` BUT ONLY FOR THIS, not for the whole foreach body See also https://www.dokuwiki.org/plugin:publish#error_when_using_the_old_revisions_view --- action.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/action.php b/action.php index 991a1c3..d7c5009 100644 --- a/action.php +++ b/action.php @@ -202,9 +202,10 @@ function handle_revisions(&$event, $param) { $member = null; foreach($event->data->_content as $key => $ref) { - if ( !isset ( $ref ['_elem'] ) ) { break ; } - if($ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') { - $member = $key; + if(isset($ref['_elem']) && isset($ref['_tag']) && isset($ref['class'])) { + if($ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') { + $member = $key; + } } if($member && $ref['_elem'] == 'tag' && From d1150603a61a64f2b475a076b49fbdb23dfc9f5c Mon Sep 17 00:00:00 2001 From: "hh.lohmann" Date: Wed, 21 May 2014 10:55:03 +0200 Subject: [PATCH 4/5] Illegal string offset '_elem' in action.php on line 231 (or 232) - CORRECTION sorry, simple PHP break does not do the full job, we need to check all `$ref`, and that for the whole foreach body --- action.php | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/action.php b/action.php index d7c5009..e93bc83 100644 --- a/action.php +++ b/action.php @@ -230,36 +230,37 @@ function handle_recent(&$event, $param) { $member = null; foreach($event->data->_content as $key => $ref) { - if ( !isset ( $ref ['_elem'] ) ) { break ; } - if($ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') { - $member = $key; - } + if(isset($ref['_elem']) && isset($ref['_tag']) && isset($ref['class'])) { + if($ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') { + $member = $key; + } - if($member && $ref['_elem'] == 'opentag' && - $ref['_tag'] == 'a' && $ref['class'] == 'diff_link'){ - $name = $ref['href']; - $name = explode('?', $name); - $name = explode('&', $name[1]); - $usename = null; - foreach($name as $n) { - $fields = explode('=', $n); - if($fields[0] == 'id') { - $usename = $fields[1]; - break; + if($member && $ref['_elem'] == 'opentag' && + $ref['_tag'] == 'a' && $ref['class'] == 'diff_link'){ + $name = $ref['href']; + $name = explode('?', $name); + $name = explode('&', $name[1]); + $usename = null; + foreach($name as $n) { + $fields = explode('=', $n); + if($fields[0] == 'id') { + $usename = $fields[1]; + break; + } } - } - if($usename) { - if($this->hlp->in_namespace($this->getConf('apr_namespaces'), $usename)) { - $meta = p_get_metadata($usename); - - if($meta['approval'][$meta['last_change']['date']]) { - $event->data->_content[$member]['class'] = 'li approved_revision'; - }else{ - $event->data->_content[$member]['class'] = 'li unapproved_revision'; + if($usename) { + if($this->hlp->in_namespace($this->getConf('apr_namespaces'), $usename)) { + $meta = p_get_metadata($usename); + + if($meta['approval'][$meta['last_change']['date']]) { + $event->data->_content[$member]['class'] = 'li approved_revision'; + }else{ + $event->data->_content[$member]['class'] = 'li unapproved_revision'; + } } - } + } + $member = null; } - $member = null; } } return true; From d52c4d066624bff64400fbe65638136add466271 Mon Sep 17 00:00:00 2001 From: Erik Can Date: Mon, 26 May 2014 16:28:11 +0200 Subject: [PATCH 5/5] action.php: isset check for $meta['last_change']['date'] @ handle_recent --- action.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/action.php b/action.php index e93bc83..a0ad89d 100644 --- a/action.php +++ b/action.php @@ -252,10 +252,12 @@ function handle_recent(&$event, $param) { if($this->hlp->in_namespace($this->getConf('apr_namespaces'), $usename)) { $meta = p_get_metadata($usename); - if($meta['approval'][$meta['last_change']['date']]) { - $event->data->_content[$member]['class'] = 'li approved_revision'; - }else{ - $event->data->_content[$member]['class'] = 'li unapproved_revision'; + if ( isset ( $meta['last_change']['date'] ) ) { + if($meta['approval'][$meta['last_change']['date']]) { + $event->data->_content[$member]['class'] = 'li approved_revision'; + }else{ + $event->data->_content[$member]['class'] = 'li unapproved_revision'; + } } } }