Extension:QuickInstantCommons

From mediawiki.org
This page is a translated version of the page Extension:QuickInstantCommons and the translation is 100% complete.
Other languages:
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced-invert.svg
QuickInstantCommons
リリースの状態: 安定
実装 ファイル リポジトリ
説明 Provides a performance optimized version of InstantCommons
作者 Brian Wolff (Bawolffトーク)
最新バージョン 1.5
MediaWiki >= 1.35
PHP >= 7.2.11
Composer mediawiki/quickinstantcommons
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
README
  • $wgUseQuickInstantCommons
  • $wgQuickInstantCommonsPrefetchMaxLimit
  • $wgQuickInstantCommonsPrefetch
translatewiki.net で翻訳を利用できる場合は、QuickInstantCommons 拡張機能の翻訳にご協力ください

使用状況とバージョン マトリクスを確認してください。

問題点 未解決のタスク · バグを報告

The QuickInstantCommons extension is a performance optimized version of $wgUseInstantCommons . また、ローカルのWikiでMediaHandlerの拡張子がないファイルの基本的なサムネイルを作成することができます。 For example, the first page of a PDF will still thumbnail even without Extension:PDFHandler installed, but advanced features like multipage requires the extension to be installed locally.

パフォーマンス

Initial testing was done using the page en.wikipedia.org: List of governors general of Canada (revision 1054426240) which has 85 images. テストはキャッシュを無効にして行われ、すでに設定された接続でのAPIの推定TTFBは〜250msであった。

MediaWikiコアのインスタントコモンズでは1038.18秒、この拡張機能でプリフェッチを無効にすると18.50秒、この拡張機能だがプリフェッチを有効にすると1.10秒かかりました。

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のQuickInstantCommonsという名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    wfLoadExtension( 'QuickInstantCommons' );
    
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
If using this extension, please disable $wgUseInstantCommons as this extension replaces it.

設定

If you were previously using $wgUseInstantCommons, no configuration is needed beyond wfLoadExtension-ing this extension; Configuration is only required for advanced usage.

$wgUseQuickInstantCommons
Automatically setup $wgForeignFileRepos to use this extension (defaults true). Set to false if you need to customize something.
$wgQuickInstantCommonsPrefetch
Enable prefetching images based on what's in DB (Default true). Most of the time this is a major performance boost, but its possible that occasionally this might cause work to be done that isn't necessary.
$wgQuickInstantCommonsPrefetchMaxLimit
Max number of images to prefetch if prefetching is enabled (Default: 1000). Could hit OOM issues if too high.

高度な設定

You can directly configure $wgForeignFileRepos if you want. For example, if you want to use this extension with a wiki that is not commons. Example:

  wfLoadExtension( 'QuickInstantCommons' );
  $wgUseQuickInstantCommons = false;
  $wgForeignFileRepos[] = [ 
       'class' => '\MediaWiki\Extension\QuickInstantCommons\Repo',
       'name' => 'commonswiki', // Must be a distinct name
       'directory' => $wgUploadDirectory, // FileBackend needs some value here.
       'apibase' => 'https://commons.wikimedia.org/w/api.php',
       'hashLevels' => 2, // Important this matches foreign repo if 404 transform enabled.
       'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb', // Set to false to auto-detect
       'fetchDescription' => true, // Optional
       'descriptionCacheExpiry' => 43200, // 12 hours, optional (values are seconds). This cache is not adaptive.
       'transformVia404' => true, // Whether foreign repo supports 404 transform. Much faster if supported
       'abbrvThreshold' => 160, // must match what foreign repo uses if 404 transform enabled. Default is 255. Wikimedia uses 160.
       'apiMetadataExpiry' => 60*60*24, // Max time metadata is cached for. Recently changed items are cached for less
       'disabledMediaHandlers' => [TiffHandler::class] // media handler extensions to not use. For 404 handling its important that the local media handler extensions match the foreign ones.
  ];

apiMetadataExpiry is probably the most important value from a performance perspective (other then $wgQuickInstantCommonsPrefetch). If you feel things are slow, try increasing it. If a new version of a file is uploaded, it might not show up properly until after metadata expires. However you can force an expiry by purging the file description page on the local wiki. If you want to maxamize performance, an appropriate value might be 60*60*24*30 (1 month)

Unlike MediaWiki core's ForeignAPIRepo, $wgResponsiveImages should not impact performance when transformVia404 is enabled, so it is recommended that you keep it turned on.
If the foreign repo also has a foreign repo (For example: en.wikipedia.org), then there won't be a single valid thumbUrl. Instead set it to false for the extension to try and auto-detect

Differences between this and ForeignApiFileRepo

  • Caches curl handle
  • Uses HTTP/2 multiplexing (Major performance boost)
  • ?action=purge of File pages purges image metadata
  • Does not support local thumbnail caching
  • Automatically generate thumbnail URLs locally if foreign repository supports 404 handling (Major performance boost. Especially when responsive images are enabled)
  • Prefetch expected images based on imagelinks table (Major performance boost)
  • Allows limited thumbnailing of files that are missing handler extension (e.g. Still show thumbnail of first page of a PDF even if you don't have Extension:PDFHandler installed).
  • Adaptive TTL support that actually works (If the foreign image was recently edited, cache for shorter time, so that if its vandalism the revert will show up faster).
  • Configurable metadata caching time, with better defaults than core.
  • When using a foreign repo that itself has foreign repos (For example, how en.wikipedia.org includes commons.wikimedia.org), image page descriptions will now work correctly.
  • file redirects for files that are foreign files on the foreign repo work.
  • allows disabling media handlers that are incompatible and use fallback behaviour instead.
  • for images that can't use 404 rendering (missing local media handler extension or if transformVia404 false), predictively prefetches the responsive high-dpi thumbnails
  • reuse http/2 connection for fetching description page text
  • do not show text of 404 if the description page is missing on foreign wiki. Instead just show it as blank.

Other ideas that haven't been implemented: better adaptive cache for image description pages.

既知の問題点

関連項目