Посібник:MediaWiki.php

From mediawiki.org
This page is a translated version of the page Manual:MediaWiki.php and the translation is 32% complete.

Опис

Серед іншого, цей файл містить:

  • Функцію run, що викликається з index.php. Запускає поточний екземпляр MediaWiki, викликаючи checkMaxLag, main, triggerJobs і restInPeace.
  • Функцію checkMaxLag: перевіряє, чи максимальне відставання ведених баз даних перевищує параметр maxlag , і якщо це так, виводить повідомлення про помилку. В основному вона використовується в запитах до api.php , які явно викликаються у версіях ApiMain.php до 1.19, і з 1.19 вона також працює для запитів index.php.
  • Функцію main, яка створює об'єкт Title залежно від параметра title , переданого до index.php. Якщо передано параметр curid, то він перекриє title. Якщо не передано параметр curid і передано параметр oldid, то він перекриє title, якщо це не спеціальна сторінка.
  • Function performRequest (before version 1.18 it was called performRequestForTitle, and before version 1.16 it was called initialize) which does the most of the work. It:
    • Checks for invalid titles, or read permission errors
    • Performs interwiki redirects and canonical redirects
    • Calls initializeArticle, and
    • Calls performAction if initializeArticle returned an article, or
    • Calls redirect if initializeArticle returned a string.
  • Function initializeArticle, which creates an Article object from the Title given.

Then it checks if it is a redirect and if it's the case, recreate another Article from the target of the redirect and changes $wgTitle . It can return either:

    • An article object, which will be passed performAction to execute the requested action
    • A string if it's an interwiki redirect or a redirect to a special page
  • Function performAction (called by performRequest) which performs most actions, including creating the HTML.

For example, in the case of viewing a page, function "view" in Article.php is called.

  • Function restInPeace (called by run) which does the following:
    • Perform deferred updates
    • Commit any database transactions
  • Function triggerJobs (doJobs before 1.23), which runs zero, one or more jobs from the Job queue, depending on $wgJobRunRate .

Called from run (it was called from restInPeace before 1.23).

Hooks

Див. також