- if ( !empty( $result['query-continue'] ) ) {
- $data['apfrom'] = $result['query-continue']['allpages']['apfrom'];
- $this->output( "Fetching new batch from {$data['apfrom']}\n" );
+
+ if ( $page !== null ) {
+ $this->output( "Fetched list up to {$page['title']}\n" );
+ }
+
+ if ( isset( $result['continue'] ) ) { // >= 1.21
+ $data = array_replace( $data, $result['continue'] );
+ } elseif ( isset( $result['query-continue']['allpages'] ) ) { // <= 1.20
+ $data = array_replace( $data, $result['query-continue']['allpages'] );
+ } else {
+ break;