Wikimedia

Write a MediaWiki maintenance script to import content from text files

Your task is to write a PHP maintenance script importTextFiles.php which reads in each of the text files passed as command line parameters, and imports their content to a page on the wiki. For example, if I ran php maintenance/importTextFiles.php Weather.txt Galaxy.txt, the content of Weather.txt would be imported to a page called Weather on the wiki, and Galaxy.txt to Galaxy.

The script should accept the following options (more options may be added as part of future GCI tasks):

  • --user to set the username to which the edits should be attributed (default: Maintenance script).
  • --summary to specify the edit summary for the edits (default: Imported from text file).
  • --use-timestamp to use the modification date of the text file as the timestamp for the edit. (By default, the current time is used as the timestamp for the edit.)

You may like to borrow logic from, or call into code in, maintenance/edit.php and/or includes/import/WikiRevision.php.

There is no Phabricator task.

Task tags

  • mediawiki
  • php

Students who completed this task

unicornisaurous

Task type

  • code Code
close

2015