Skip to content
Browse files

Avoids undefined index errors when building page info.

  • Loading branch information...
1 parent aa45d76 commit e70ef1c28dcbb37261f043cdfd2f213c4fe545aa @jimsafley jimsafley committed Oct 4, 2011
Showing with 15 additions and 15 deletions.
  1. +15 −15 lib/Scripto/Document.php
View
30 lib/Scripto/Document.php
@@ -791,21 +791,21 @@ protected function _getPageInfo($title)
'intoken' => 'edit|move|delete|protect');
$response = $this->_mediawiki->getInfo($title, $params);
$page = current($response['query']['pages']);
- $pageInfo = array('page_id' => $page['pageid'],
- 'namespace_index' => $page['ns'],
- 'mediawiki_title' => $page['title'],
- 'last_revision_id' => $page['lastrevid'],
- 'counter' => $page['counter'],
- 'length' => $page['length'],
- 'start_timestamp' => $page['starttimestamp'],
- 'edit_token' => $page['edittoken'],
- 'move_token' => $page['movetoken'],
- 'delete_token' => $page['deletetoken'],
- 'protect_token' => $page['protecttoken'],
- 'protections' => $page['protection'],
- 'talk_id' => $page['talkid'],
- 'mediawiki_full_url' => $page['fullurl'],
- 'mediawiki_edit_url' => $page['editurl'],
+ $pageInfo = array('page_id' => isset($page['pageid']) ? $page['pageid'] : null,
+ 'namespace_index' => isset($page['ns']) ? $page['ns'] : null,
+ 'mediawiki_title' => isset($page['title']) ? $page['title'] : null,
+ 'last_revision_id' => isset($page['lastrevid']) ? $page['lastrevid'] : null,
+ 'counter' => isset($page['counter']) ? $page['counter'] : null,
+ 'length' => isset($page['length']) ? $page['length'] : null,
+ 'start_timestamp' => isset($page['starttimestamp']) ? $page['starttimestamp'] : null,
+ 'edit_token' => isset($page['edittoken']) ? $page['edittoken'] : null,
+ 'move_token' => isset($page['movetoken']) ? $page['movetoken'] : null,
+ 'delete_token' => isset($page['deletetoken']) ? $page['deletetoken'] : null,
+ 'protect_token' => isset($page['protecttoken']) ? $page['protecttoken'] : null,
+ 'protections' => isset($page['protection']) ? $page['protection'] : null,
+ 'talk_id' => isset($page['talkid']) ? $page['talkid'] : null,
+ 'mediawiki_full_url' => isset($page['fullurl']) ? $page['fullurl'] : null,
+ 'mediawiki_edit_url' => isset($page['editurl']) ? $page['editurl'] : null,
'watched' => isset($page['watched']) ? true: false,
'redirect' => isset($page['redirect']) ? true: false,
'new' => isset($page['new']) ? true: false);

0 comments on commit e70ef1c

Please sign in to comment.
Something went wrong with that request. Please try again.