Manual:Shared database/cs

Tato stránka poskytuje stručný přehled používání sdílených databází v MediaWiki. Většina informací zde by měla fungovat s jednoduchou instalací MediaWiki (bez rozšíření). Jakékoli požadavky na rozšíření jsou uvedeny. Všimněte si, že toto je navrženo kolem databází MySQL. Podpora pro SQLite byla přidána do MediaWiki 1.17. Podpora pro PostgreSQL byla přidána do MediaWiki 1.19. Jiné databázové stroje nemusí podporovat sdílené databáze tímto způsobem.

Základy
Sdílené databáze jsou nakonfigurovány se 3 hlavními globálními ve vašem :



V závislosti na vašich potřebách a prostředí možná nebudete muset používat všechny tyto možnosti.



Nejjednodušší nastavení: Sdílená uživatelská tabulka
Sdílenou tabulku uživatelů lze použít pro více wikin, které mají sdílené registrace uživatelů, takže uživatelé se musí zaregistrovat pouze do jedné wiki.

Ve výchozím nastavení obsahuje $wgSharedTables tabulky user a user_properties. Přidání 'hráče' je plánováno.



Oprávnění k databázi
Uživatel MySQL sdílené wiki musí mít alespoň oprávnění SELECT a UPDATE pro hlavní tabulky uživatelů wiki. Pokud pro každou wiki používáte různé uživatele MySQL, budete muset uživateli sdílené wiki udělit další oprávnění, jak je uvedeno v nastavení dané wiki. Pro ty, kteří používají sdílený hosting, mějte na paměti, že to je možné u některých, ale ne u všech poskytovatelů. Granting permissions can be performed using MySQL commands similar to the following:

This will allow your wiki to read users from the main table, and also update the tables, which happens whenever a user logs in.

Sharing sessions
To share login sessions between your wikis, set to include all subdomains under your root domain. For example, if you have the sites en.example.comfr.example.compool.example.com, set:

Upgrading
As of MediaWiki 1.21, when upgrading MediaWiki from the web installer, $wgSharedTables must be temporarily removed from LocalSettings.php during upgrade. Otherwise, the shared tables are not touched at all (neither tables with $wgSharedPrefix, nor those with $wgDBprefix), which may lead to a failed upgrade.

When upgrading from the command line, running the script, you need to use the   parameter for the script to upgrade the shared tables.

In MediaWiki 1.24 the default password type for MediaWiki has been changed from MD5 to PBKDF2, and passwords hashes will automatically be updated as users log in. To prevent this from happening until all wikis are upgraded, set to   on all wikis, and remove it on all wikis when they have been upgraded to ensure a stronger encryption is used.

Sharing more tables
You can share tables other than the user table, but be careful when doing so. If a table contains any data specific to one wiki, sharing may cause problems. Note that each of the subsections here assume that you are also sharing the user table. Whenever adding other tables, be sure to either append to the array or include the user table in the new array definition.

The ipblocks table
By sharing the table, you can have "global blocks" so that a block on one wiki will block the user or IP on all other wikis using the shared database.

Caveats
There can be some minor issues when sharing the ipblocks table:


 * The  field is set as the "reason" on Special:Block when blocking a user. When a blocked user sees the "You are blocked" message, this is parsed as wikitext, and links are parsed on Special:BlockList, you will need to make sure when blocking a user that the message makes sense on all wikis.
 * Block logs will not be shared (sharing the table is not recommended).

The user_groups table
Sharing the table will allow you to have global user groups.

Caveats

 * As with the block log, the user rights log is not shared.
 * All user groups will be global. You can work around this somewhat by customizing your user groups. For example, to have admins on one wiki be separate from admins on another, you could do something like the following:
 * In the config for wiki 1:


 * In the config for wiki 2:


 * To prevent bureaucrats on one wiki from assigning themselves rights on other wikis that they shouldn't have, you can do a similar configuration to the above, but remove the 'userrights' right that allows them to set any group, and use / instead.

Other tables
This section covers other tables, with less common reasons to share, as well as which tables not to share.


 * The interwiki table contains mostly static data; it may be useful to share if you have many custom interwikis.
 * The site_stats table could possibly be shared, to aggregate data over all your wikis.
 * By default, the table is included in the list of shared tables. If your wikis were started using MediaWiki 1.15 or older, you should probably keep this for backward compatibility, as user preferences will be silently automatically migrated from the user table to the user_properties table. Otherwise, you can remove this from the array to allow users to have different preferences on each wiki (if desired)

Most other tables should not be shared, as they include wiki-specific data, typically connections to pages via a pageid or a namespace/title combination. This includes (but is not limited to):


 * Any of the links tables (pagelinkstemplatelinks, etc.)
 * The page table
 * The revision table
 * The image table (to have a shared media repository, see )

For more details, see