2012-07-27 22:16:19 +00:00
|
|
|
<?php
|
|
|
|
|
2013-03-08 01:50:54 +00:00
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
if ( $IP === false ) {
|
2015-10-29 11:22:22 +00:00
|
|
|
$IP = __DIR__ . '/../../..';
|
2013-03-08 01:50:54 +00:00
|
|
|
}
|
2017-06-20 02:41:30 +00:00
|
|
|
require_once "$IP/maintenance/Maintenance.php";
|
2012-07-27 22:16:19 +00:00
|
|
|
|
|
|
|
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*/ );
|
2016-12-01 21:34:43 +00:00
|
|
|
|
|
|
|
$this->requireExtension( 'Echo' );
|
2012-07-27 22:16:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2016-12-05 18:51:07 +00:00
|
|
|
$requestData = [
|
2012-07-27 22:16:19 +00:00
|
|
|
'format' => 'php',
|
|
|
|
'action' => 'query',
|
|
|
|
'prop' => 'revisions',
|
|
|
|
'revids' => implode( '|', $revisions ),
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2012-07-27 22:16:19 +00:00
|
|
|
|
|
|
|
$originalData = Http::post(
|
|
|
|
$apiURL,
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
2012-07-27 22:16:19 +00:00
|
|
|
'postData' => $requestData,
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
2012-07-27 22:16:19 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$data = unserialize( $originalData );
|
|
|
|
|
|
|
|
$pages = $data['query']['pages'];
|
|
|
|
|
2012-08-31 21:50:46 +00:00
|
|
|
foreach ( $pages as $page ) {
|
2018-10-19 08:04:24 +00:00
|
|
|
if ( count( $page['revisions'] ) !== 1 ) {
|
2012-07-27 22:16:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revid = $page['revisions'][0]['revid'];
|
|
|
|
|
2016-12-05 18:51:07 +00:00
|
|
|
$newRequest = [
|
2012-07-27 22:16:19 +00:00
|
|
|
'format' => 'php',
|
|
|
|
'action' => 'query',
|
|
|
|
'prop' => 'revisions',
|
|
|
|
'titles' => $page['title'],
|
|
|
|
'rvstartid' => $revid,
|
|
|
|
'rvlimit' => 2,
|
|
|
|
'rvprop' => 'ids|content|user',
|
2016-12-05 18:51:07 +00:00
|
|
|
];
|
2012-07-27 22:16:19 +00:00
|
|
|
|
|
|
|
$newData = Http::post(
|
|
|
|
$apiURL,
|
2016-12-05 18:51:07 +00:00
|
|
|
[
|
2012-07-27 22:16:19 +00:00
|
|
|
'postData' => $newRequest,
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
2012-07-27 22:16:19 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$newData = unserialize( $newData );
|
|
|
|
|
2018-12-17 10:46:02 +00:00
|
|
|
$pageData = reset( $newData['query']['pages'] );
|
2018-10-19 08:08:55 +00:00
|
|
|
$oldText = isset( $pageData['revisions'][1] )
|
|
|
|
? trim( $pageData['revisions'][1]['*'] ) . "\n"
|
|
|
|
: '';
|
|
|
|
$newText = trim( $pageData['revisions'][0]['*'] ) . "\n";
|
2012-07-27 22:16:19 +00:00
|
|
|
$user = $pageData['revisions'][0]['user'];
|
|
|
|
|
|
|
|
print "http://en.wikipedia.org/w/index.php?diff=prev&oldid=$revid\n";
|
2013-03-08 01:50:54 +00:00
|
|
|
EchoDiscussionParser::getInterestedUsers( $oldText, $newText, $user ); // FIXME: getInterestedUsers() is undefined
|
2012-07-27 22:16:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = "TestDiscussionParser";
|
2017-06-20 02:41:30 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|