2012-07-27 22:16:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once ( getenv( 'MW_INSTALL_PATH' ) !== false
|
|
|
|
? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
|
|
|
|
: dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' );
|
|
|
|
|
|
|
|
class TestDiscussionParser extends Maintenance {
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->mDescription = "Takes enwiki revision IDs and attempts to identify interested users";
|
|
|
|
|
|
|
|
$this->addArg( 'revisions', 'Revision IDs, separated by commas', true /*required*/ );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
$apiURL = 'http://en.wikipedia.org/w/api.php';
|
|
|
|
|
2012-08-31 21:50:46 +00:00
|
|
|
$revisions = explode( ',', $this->getArg( 0 ) );
|
2012-07-27 22:16:19 +00:00
|
|
|
|
|
|
|
// Retrieve original revisions and their predecessors
|
|
|
|
$requestData = array(
|
|
|
|
'format' => 'php',
|
|
|
|
'action' => 'query',
|
|
|
|
'prop' => 'revisions',
|
|
|
|
'revids' => implode( '|', $revisions ),
|
|
|
|
);
|
|
|
|
|
|
|
|
$originalData = Http::post(
|
|
|
|
$apiURL,
|
|
|
|
array(
|
|
|
|
'postData' => $requestData,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$data = unserialize( $originalData );
|
|
|
|
|
|
|
|
$pages = $data['query']['pages'];
|
|
|
|
|
2012-08-31 21:50:46 +00:00
|
|
|
foreach ( $pages as $page ) {
|
2012-08-30 16:04:39 +00:00
|
|
|
if ( count( $page['revisions'] ) != 1 ) {
|
2012-07-27 22:16:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revid = $page['revisions'][0]['revid'];
|
|
|
|
|
|
|
|
$newRequest = array(
|
|
|
|
'format' => 'php',
|
|
|
|
'action' => 'query',
|
|
|
|
'prop' => 'revisions',
|
|
|
|
'titles' => $page['title'],
|
|
|
|
'rvstartid' => $revid,
|
|
|
|
'rvlimit' => 2,
|
|
|
|
'rvprop' => 'ids|content|user',
|
|
|
|
);
|
|
|
|
|
|
|
|
$newData = Http::post(
|
|
|
|
$apiURL,
|
|
|
|
array(
|
|
|
|
'postData' => $newRequest,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$newData = unserialize( $newData );
|
|
|
|
|
|
|
|
$allData = $newData['query']['pages'];
|
|
|
|
$pageData = array_shift( $allData );
|
|
|
|
if ( count( $pageData['revisions'] ) == 2 ) {
|
|
|
|
$revision1 = $pageData['revisions'][0];
|
|
|
|
$revision2 = $pageData['revisions'][1];
|
2012-08-30 16:04:39 +00:00
|
|
|
$oldText = trim( $revision2['*'] ) . "\n";
|
|
|
|
$newText = trim( $revision1['*'] ) . "\n";
|
2012-07-27 22:16:19 +00:00
|
|
|
} elseif ( count( $pageData['revisions'] ) == 1 ) {
|
|
|
|
$revision1 = $pageData['revisions'][0];
|
2012-08-30 16:04:39 +00:00
|
|
|
$newText = trim( $revision1['*'] ) . "\n";
|
2012-07-27 22:16:19 +00:00
|
|
|
$oldText = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = $pageData['revisions'][0]['user'];
|
|
|
|
|
|
|
|
print "http://en.wikipedia.org/w/index.php?diff=prev&oldid=$revid\n";
|
2012-08-30 16:04:39 +00:00
|
|
|
EchoDiscussionParser::getInterestedUsers( $oldText, $newText, $user );
|
2012-07-27 22:16:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = "TestDiscussionParser";
|
2012-08-30 16:04:39 +00:00
|
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|