delinquent_files/demon.php

changeset 3
24d8f83459b3
parent 2
cd58c0bc21d6
child 6
8b4e205ffc94
equal deleted inserted replaced
2:cd58c0bc21d6 3:24d8f83459b3
1 #!/usr/bin/php 1 #!/usr/bin/php
2 # $Id$
3 #
4
5 <?PHP 2 <?PHP
6 3
7 chdir ( '/data/project/commons-delinquent' ) ; 4 chdir ( '/data/project/commons-delinquent' ) ;
8 5
9 error_reporting(E_ERROR|E_CORE_ERROR|E_COMPILE_ERROR); # E_ALL| 6 error_reporting(E_ERROR|E_CORE_ERROR|E_COMPILE_ERROR); # E_ALL|
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";

mercurial