Руководство:Таблица sites

From mediawiki.org
This page is a translated version of the page Manual:Sites table and the translation is 52% complete.
Outdated translations are marked like this.
Manual:Содержание MediaWiki database layout sites таблица
Версия MediaWiki:
1.21

sites table, введена в MediaWiki 1.21 в мае 2013, содержит все сайты, известные в вики.

Поля

site_id

Версия MediaWiki:
1.21

Цифровой идентификатор сайта. Это первичный автоинкрементный ключ.

site_global_key

Версия MediaWiki:
1.21

Глобальный идентификатор для сайта, например 'enwiktionary'

site_type

Версия MediaWiki:
1.21

Тип сайта, например 'mediawiki'

site_group

Версия MediaWiki:
1.21

Группа сайта, то например 'wikipedia'

site_source

Версия MediaWiki:
1.21

Источник данных сайта, например 'local', 'wikidata', 'my-magical-repo'

site_language

Версия MediaWiki:
1.21

Код основного языка сайта.

site_protocol

Версия MediaWiki:
1.21

Протокол сайта, например 'http://', 'irc://', '//'.

Это поле является индексом для поиска и строится из специфичных для типа данных в site_data.

site_domain

Версия MediaWiki:
1.21

Домен сайта в обратном порядке, например 'org.mediawiki.www.'.

Это поле является индексом для поиска и строится из специфичных для типа данных в site_data.

site_data

Версия MediaWiki:
1.21

Введите зависимые данные сайта.

site_forward

Версия MediaWiki:
1.21

Если site.tld/path/key:pageTitle должны направлять пользователей на страницу с фактическим местом, где "ключ" является локальным идентификатором.

site_config

Версия MediaWiki:
1.21

Зависит от типа конфигурации сайта. For instance if template transclusion should be allowed if it's a MediaWiki.

Managing the sites table

The sites table is shipped without data for a new MediaWiki installation.

Importing sites table from another wiki

There're two ways of populating the sites table using another wiki as a source. If you have access to the other wiki's server, you can run the exportSites.php maintenance script and import the data using the importSites.php maintenance script of your MediaWiki installation.

If you don't have access to the other wiki's server but the other MediaWiki installation has the SiteMatrix extension installed, you can use a maintenance script from the Wikibase extension (populateSitesTable.php) to import all sites from the other wiki.

Adding a new site

If you want to add a new site into your MediaWiki's site table, you can use the maintenance script addSite.php .

Additionally, the above mentioned importSites.php maintenance script can be used to add an arbitrary group of wikis from custom made XML file in the following format:

<sites version="1.0" xmlns="https://www.mediawiki.org/xml/sitelist-1.0/">
	<site type="mediawiki">
		<globalid>wikisite1</globalid>
		<group>mywikigroup</group>
		<path type="file_path">https://www.wikisite1.org/$1</path>
		<path type="page_path">https://www.wikisite1.org/index.php/$1</path>
	</site>
	<site type="mediawiki">
		<globalid>wikisite2</globalid>
		<group>mywikigroup</group>
		<path type="file_path">https://www.wikisite2.org/w/$1</path>
		<path type="page_path">https://www.wikisite2.org/wiki/$1</path>
	</site>
</sites>

Each ‎<site> element representing a site.

file_path and page_path can be inferred from Special:Version page of the intended wiki.

Вставка семейства вики (используя Script)

Иногда вы должны добавить свои вики в эту таблицу. Вы можете использовать этот код:

$sites = [];
foreach ( [ 'en', 'fr' ] as $langCode ) {
     $site = new MediaWikiSite();
     $site->setGlobalId( $langCode . 'mywiki' );
     $site->setGroup( 'mywiki' );
     $site->setLanguageCode( $langCode );
     $site->addInterwikiId( $langCode );
     $site->addNavigationId( $langCode );
     $site->setPath( MediaWikiSite::PATH_PAGE, "http://$langCode.mywiki.org/wiki/$1" );
     $site->setPath( MediaWikiSite::PATH_FILE, "http://$langCode.mywiki.org/w/$1" );           
     $sites[] = $site;
}
          
$sitesTable = SiteSQLStore::newInstance();
$sitesTable->clear(); // This will remove all previous entries from the table. Remove this call if you want to keep them.
$sitesTable->saveSites( $sites );

Reloading the cached sites table

MediaWiki caches the sites table in the local-server cache (CACHE_ACCEL) if it is available (ACPu or WinCache installed). After making changes to the sites table using any of the above methods, you should reload or restart any long-running MediaWiki PHP processes: your web server, continuous job runners (if any), etc. Otherwise, changes to the sites table will only become effective after the cache expires.

Краткое описание схемы

Версия MediaWiki:
1.35
Gerrit change 597664
Версия MediaWiki:
1.35
Gerrit change 622214

DESCRIBE sites;

+-----------------+------------------+------+-----+---------+----------------+
| Field           | Type             | Null | Key | Default | Extra          |
+-----------------+------------------+------+-----+---------+----------------+
| site_id         | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| site_global_key | varbinary(64)    | NO   | UNI | NULL    |                |
| site_type       | varbinary(32)    | NO   | MUL | NULL    |                |
| site_group      | varbinary(32)    | NO   | MUL | NULL    |                |
| site_source     | varbinary(32)    | NO   | MUL | NULL    |                |
| site_language   | varbinary(35)    | NO   | MUL | NULL    |                |
| site_protocol   | varbinary(32)    | NO   | MUL | NULL    |                |
| site_domain     | varbinary(255)   | NO   | MUL | NULL    |                |
| site_data       | blob             | NO   |     | NULL    |                |
| site_forward    | tinyint(1)       | NO   | MUL | NULL    |                |
| site_config     | blob             | NO   |     | NULL    |                |
+-----------------+------------------+------+-----+---------+----------------+
Версии MediaWiki:
1.21 – 1.34

DESCRIBE sites;

+-----------------+------------------+------+-----+---------+----------------+
| Field           | Type             | Null | Key | Default | Extra          |
+-----------------+------------------+------+-----+---------+----------------+
| site_id         | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| site_global_key | varbinary(32)    | NO   | UNI | NULL    |                |
| site_type       | varbinary(32)    | NO   | MUL | NULL    |                |
| site_group      | varbinary(32)    | NO   | MUL | NULL    |                |
| site_source     | varbinary(32)    | NO   | MUL | NULL    |                |
| site_language   | varbinary(32)    | NO   | MUL | NULL    |                |
| site_protocol   | varbinary(32)    | NO   | MUL | NULL    |                |
| site_domain     | varbinary(255)   | NO   | MUL | NULL    |                |
| site_data       | blob             | NO   |     | NULL    |                |
| site_forward    | tinyint(1)       | NO   | MUL | NULL    |                |
| site_config     | blob             | NO   |     | NULL    |                |
+-----------------+------------------+------+-----+---------+----------------+

Indexes

Версия MediaWiki:
1.42

SHOW INDEX IN sites;

+-------+------------+-----------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name        | Seq_in_index | Column_name     | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| sites |          0 | PRIMARY         |            1 | site_id         | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| sites |          0 | site_global_key |            1 | site_global_key | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+-----------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+