155 } |
152 } |
156 |
153 |
157 |
154 |
158 function getTextFromWiki ( $wiki , $pagename ) { |
155 function getTextFromWiki ( $wiki , $pagename ) { |
159 $ret = false ; |
156 $ret = false ; |
|
157 $this->d->debug( "Getting api of " . $wiki) ; |
160 $api = $this->getAPI ( $wiki ) ; |
158 $api = $this->getAPI ( $wiki ) ; |
161 if ( $api ) { |
159 if ( $api ) { |
162 $services = new \Mediawiki\Api\MediawikiFactory( $api ); |
160 $services = new \Mediawiki\Api\MediawikiFactory( $api ); |
163 $page = $services->newPageGetter()->getFromTitle( $pagename ); |
161 $page = $services->newPageGetter()->getFromTitle( $pagename ); |
164 $revision = $page->getRevisions()->getLatest(); |
162 $revision = $page->getRevisions()->getLatest(); |
504 } |
502 } |
505 $db->close() ; |
503 $db->close() ; |
506 |
504 |
507 $last_wiki = '' ; |
505 $last_wiki = '' ; |
508 foreach ( $edits AS $o ) { |
506 foreach ( $edits AS $o ) { |
509 if ( $last_wiki == $o->wiki ) sleep ( 5 ) ; // Edit rate limiter |
507 if ( $last_wiki == $o->wiki ) sleep ( 2 ) ; // Edit rate limiter |
510 $this->d->debug("Perform an edit in $o->wiki"); |
508 $this->d->debug("Perform an edit in $o->wiki"); |
511 try { |
509 try { |
512 $this->performEdit ( $o ) ; |
510 $this->performEdit ( $o ) ; |
513 } catch (Exception $e) { |
511 } catch (Exception $e) { |
514 echo 'Caught exception: ', $e->getMessage(), "\n"; |
512 echo 'Caught exception: ', $e->getMessage(), "\n"; |