Bücher online kostenlos Kostenlos Online Lesen
Working With MediaWiki

Working With MediaWiki

Titel: Working With MediaWiki Kostenlos Bücher Online Lesen
Autoren: Yaron Koren
Vom Netzwerk:
from a specific extension, it’s a good idea to check that extension’s main page, or its talk page, to see if there’s any mention of it.

The job queue
    There are certain tasks that MediaWiki has to run over an extended period of time, in the background. The most common case comes when a template is modified. Let’s say that someone adds a category tag to a template — that means that every one of the pages that include that template need to be added to that category. This process can’t be done all at once, because it would slow down the server considerably, or even temporarily crash it. Instead, the process is broken down into “jobs”, which are placed in a “job queue” — and then those jobs are run in an orderly way.
    Behind the scenes, the job queue is really just a database table called “job”, which holds one row for each job. These jobs are run in sequential order, and once a job is run its row is deleted.
    Jobs are run every time the wiki gets a page hit. By default, one job is run on every hit, but this number can be modified to make the running of jobs slower or faster, by changing the value of $wgJobRunRate. To make the running of jobs ten times faster, for instance, you would add the following to LocalSettings.php:
$wgJobRunRate = 10;
    Conversely, to make it ten times slower, you would set the value to 0.1. (You can’t actually run a fraction of a job — instead, having a fractional value sets the probability that a job will be run at any given time.)
    You can also cause jobs to be run in a more automated way, instead of just waiting for them to be run (or hitting “reload” in the browser repeatedly to speed up the running). This is done by calling the script runJobs.php, in the MediaWiki
/maintenance
directory. You can even create a cron job to run runJobs.php on a regular basis -- say, once a day.
    There are various parameters that runJobs.php can take, such as setting the maximum number of jobs to be run, or, maybe more importantly, the type of job to be run. To enable the latter, each job type has its own identifier name, which can be found in the database, if nowhere else. You can read about all the parameters for runJobs.php here:
https://www.mediawiki.org/wiki/Manual:RunJobs.php
    In addition to core MediaWiki, extensions can create their own jobs as well. Some extensions that do are Data Transfer, DeleteBatch, Nuke and Replace Text.

Replace Text
    MediaWiki lacks an innate way to do global search-and-replaceof text, a feature that would come in handy when, for instance, the name of a certain template parameter changes, and many pages that call that template have to be modified. On Wikipedia and some other large-scale wikis, bots are used for that purpose, but having a way to do it from within the wiki is a lot more convenient. Thankfully, the Replace Text extension makes it possible to do site-wide text replacements. Replace Text can handle both the contents of pages and their names; if content in a page title is replaced, it means that the page gets "moved". Every change made by Replace Text shows up in page histories, with the user who initiated the replacement appearing as the author of that edit.
    To run a replacement, go to Special:ReplaceText. This action is governed by the ’replacetext’ permission, which by default is given to administrators.
    You can see the top of the Special:ReplaceText page in Figure 15.2.
    Figure 15.2 Top of Special:ReplaceText
    What follows is a list of namespaces that the user can select from; then below that are some additional options for the replacement, which are shown in Figure 15.3.
    Figure 15.3 Bottom of Special:ReplaceText
    Hitting the “Continue” button brings the user to a second page, listing the exact matches for the search string, so that the user can manually select which pages will have their contents and/or titles modified.
    For more complex transformations, you’ll probably have to rely on bots and the MediaWiki API, which we’ll get to next.

Bots and the MediaWiki API
    There are various tools for making automated changes to the wiki’s contents, like the Replace Text extension. But in many cases the set of edits required is too specific to be handled by an automated tool. For all those cases, there are bots, and the MediaWiki API.
    A bot, in MediaWiki terminology, is a script that does one or more specific kind of edits, or retrieves one or more pieces of data. A bot can be written in any programming language:

Weitere Kostenlose Bücher