6 require_once __DIR__ .
'/../includes/Benchmarker.php';
10 parent::__construct();
12 $this->
addOption(
'file',
'A JSON API result from list=recentchanges',
18 __DIR__ .
'/data/CommentFormatter/rc100-2021-07-29.json' );
19 $json = file_get_contents(
$file );
21 $this->
fatalError(
"Unable to read input file \"$file\"" );
23 $result = json_decode( $json,
true );
24 if ( !isset( $result[
'query'][
'recentchanges'] ) ) {
27 $entries = $result[
'query'][
'recentchanges'];
30 foreach ( $entries as $entry ) {
32 'comment' => $entry[
'comment'],
35 $comments[] = $entry[
'comment'];
38 'Linker::formatComment' => [
39 'function' =>
static function () use ( $inputs ) {
41 foreach ( $inputs as $input ) {
50 'CommentFormatter::createBatch' => [
51 'function' =>
static function () use ( $inputs ) {
53 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
55 foreach ( $inputs as $input ) {
56 $comments[] = (
new CommentItem( $input[
'comment'] ) )
57 ->selfLinkTarget( $input[
'title'] );
59 $formatter->createBatch()
60 ->comments( $comments )
65 'CommentFormatter::formatStrings' => [
66 'function' =>
static function () use ( $comments ) {
68 $formatter = MediaWikiServices::getInstance()->getCommentFormatter();
69 $formatter->formatStrings( $comments );
78 require_once RUN_MAINTENANCE_IF_MAIN;
Base class for benchmark scripts.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.