- if ($this->params['redirect']) {
- //
- // expected redirect-mode parameter:
- // ns|db_key|step|level|ns|db_key|id
- // ns+db_key -- the root title
- // step = 1 or 2 - which step to continue from - 1-titles, 2-redirects
- // level -- how many levels to follow before starting enumerating.
- // if level > 0 -- ns+title to continue from, otherwise skip these
- // id = last page_id to continue from
- //
- if (count($continueList) > 4) {
- $rootNs = intval($continueList[0]);
- if (($rootNs !== 0 || $continueList[0] === '0') && !empty ($continueList[1])) {
- $this->rootTitle = Title :: makeTitleSafe($rootNs, $continueList[1]);
- if ($this->rootTitle) {
-
- $step = intval($continueList[2]);
- if ($step === 1 || $step === 2) {
- $this->contRedirs = ($step === 2);
-
- $level = intval($continueList[3]);
- if ($level !== 0 || $continueList[3] === '0') {
- $this->contLevel = $level;
-
- if ($level === 0) {
- if (count($continueList) === 5) {
- $contID = intval($continueList[4]);
- if ($contID !== 0 || $continueList[4] === '0') {
- $this->contID = $contID;
- return; // done
- }
- }
- } else {
- if (count($continueList) === 7) {
- $contNs = intval($continueList[4]);
- if (($contNs !== 0 || $continueList[4] === '0') && !empty ($continueList[5])) {
- $this->contTitle = Title :: makeTitleSafe($contNs, $continueList[5]);
-
- $contID = intval($continueList[6]);
- if ($contID !== 0 || $continueList[6] === '0') {
- $this->contID = $contID;
- return; // done
- }
- }
- }
- }
- }
- }
- }
- }
- }
- } else {
- //
- // expected non-redirect-mode parameter:
- // ns|db_key|id
- // ns+db_key -- the root title
- // id = last page_id to continue from
- //
- if (count($continueList) === 3) {
- $rootNs = intval($continueList[0]);
- if (($rootNs !== 0 || $continueList[0] === '0') && !empty ($continueList[1])) {
- $this->rootTitle = Title :: makeTitleSafe($rootNs, $continueList[1]);
- if ($this->rootTitle) {
-
- $contID = intval($continueList[2]);
- if ($contID !== 0) {
- $this->contID = $contID;
- return; // done
- }
- }
- }
- }
- }
+ // expected format:
+ // ns | key | id1 [| id2]
+ // ns+key: root title
+ // id1: first-level page ID to continue from
+ // id2: second-level page ID to continue from
+
+ // null stuff out now so we know what's set and what isn't
+ $this->rootTitle = $this->contID = $this->redirID = null;
+ $rootNs = intval($continueList[0]);
+ if($rootNs === 0 && $continueList[0] !== '0')
+ // Illegal continue parameter
+ $this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue");
+ $this->rootTitle = Title::makeTitleSafe($rootNs, $continueList[1]);
+ if(!$this->rootTitle)
+ $this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue");
+ $contID = intval($continueList[2]);
+ if($contID === 0 && $continueList[2] !== '0')
+ $this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "_badcontinue");
+ $this->contID = $contID;
+ $redirID = intval(@$continueList[3]);
+ if($redirID === 0 && @$continueList[3] !== '0')
+ // This one isn't required
+ return;
+ $this->redirID = $redirID;