Jump to content

מדריך:הרחבות/התקנה ושדרוג

From mediawiki.org
This page is a translated version of the page Manual:Extensions/Installation and upgrade and the translation is 54% complete.

לאחר ההתקנה, מדיה-ויקי מוכנה לקבל הרחבות. כדי להוסיף הרחבה, בצע את השלבים הבאים:

לפני שאתם מתחילים

  • הרחבות רבות מספקות הוראות שנועדו להתקנה באמצעות פקודות יוניקס. אתה זקוק לגישת מעטפת (SSH) כדי להזין פקודות אלה המפורטות בדפי העזרה של ההרחבה.
  • דף זה מניח שהגדרות האתר שלך נמצאות בקובץ בשם LocalSettings.php , אך אם אתה משתמש בקובץ אחר, למשל בחוות ויקי, ההוראות אמורות להיות רלוונטיות באותה מידה.

הורדת הרחבה

קבל את חבילת הקבצים

עבור כל הרחבה, קרא את התיעוד שלה כדי לברר את מיקומי ושיטות ההורדה המתאימים. דרכים נפוצות להורדת תוספים כוללות:

  1. מפיץ תוספים עוזר לך לבחור ולהוריד את רוב התוספים הפופולריים, אם כי לא כל מפתחי התוספים בהכרח ממליצים עליו.
  2. רשימת הרחבות המאוחסנות במאגר Git של ויקימדיה נמצאת בכתובת $extensions.
  3. חלק מההרחבות זמינות גם דרך:
    1. חבילות
    2. Composer , מנהל תלויות עבור ספריות PHP. ניתן להתקין הרחבות באמצעות Composer. למידע נוסף, ראה Composer/For extensions .
    3. == מאגרי תמונות ==
  4. חלק מההרחבות אינן משתמשות בבקרת גרסאות ואינן מומלצות.

הוסף את החבילה לתיקייה /extensions

הרחבות מופצות בדרך כלל כחבילות מודולריות. הן בדרך כלל נכנסות לתת-ספרייה משלהן של $IP.

ניתן להוסיף את תיקיית הקבצים באופן ידני או להעביר אותה אוטומטית אם אתם משתמשים במשהו כמו Git או Composer.

התקנת הרחבה

  1. תמיד יש לבדוק את הדרישות וההוראות שמגיעות עם כל הרחבה. הסיכום הבא חל על רוב התוספים, אך תוספים רבים דורשים נקיטת צעדים שונים
  2. ודא שההרשאות הנדרשות מוגדרות עבור ההרחבות!
  3. בסוף קובץ ה-$LocalSettings, הוסף:
    wfLoadExtension( 'ExtensionName' );
    
    שורה זו מאלצת את מפרש ה-PHP לקרוא את קובץ ההרחבה, ובכך להפוך אותו לנגיש למדיה-ויקי.

עבור שיטת התקנה מוקדמת יותר באמצעות require_once וכיצד לבצע את ההעברה, עיין בהוראות שלהלן.

  1. הגדר אם נדרש או רצוי. בדרך כלל יש להוסיף את הגדרות תצורה לאחר כולל הסיומת. שוב, בדוק את הוראות ההרחבה לקבלת פרטים.
  2. ייתכן שתידרש להריץ סקריפט תחזוקה, למשל כדי להוסיף את טבלאות מסד הנתונים הדרושות.
  3. בוצע

שגיאות אפשריות

  • חלק מההרחבות עלולות להתנגש עם סקריפטים של תחזוקה, לדוגמה אם הן ניגשות ישירות ל-$_SERVER (לא מומלץ). במקרה זה, ניתן לעטוף אותם בתנאי כך שהסקריפטים לתחזוקה עדיין יוכלו לפעול.
    if ( !$wgCommandLineMode ) {
    wfLoadExtension ( 'ExtensionName' );
    }
    
  • סקריפט התחזוקה $ImportDump ייכשל עבור כל הרחבה הדורשת מרחבי שמות מותאמים אישית אשר כלולים בתוך התנאי שלמעלה, כגון Extension:Semantic MediaWiki , Extension:Page Forms .

הוסף מספר הרחבות ל-wfLoadExtensions()

Especially if you have a large number of extensions, it may be useful to add them as an array to wfLoadExtensions() (with plural -s) instead of adding them to separate instances of wfLoadExtension() (singular). For instance, to install Cite, ParserFunctions and SpamBlacklist, you could write:

wfLoadExtensions( [ 'Cite', 'ParserFunctions', 'SpamBlacklist' ] );

This method comes with one limitation, which is that you cannot point to custom file locations, as explained in this section.

Upgrade an extension

Some extensions require to be updated whenever you update MediaWiki, while others work with multiple versions.

To upgrade to a new version of an extension:

  1. Download the new version of the extension
  2. Replace all the extension files in the extensions/<ExtensionName> directory with the new files. Do not remove the extension configuration present in LocalSettings.php
  3. If the extension requires changes to the MediaWiki database, you will need to run the update.php maintenance script. Most extensions will mention if this script needs to be run or not. (Perform backup of your data before executing the script). If you don't have command line access, you can also use the web updater.
  4. Documentation for an extension usually tells you what else you need to do.

Uninstall

  1. To uninstall the extension, remove the relevant lines from LocalSettings.php (wfLoadExtension with the extension's name as well as any possible lines for associated configuration settings).
  2. Optionally, delete the file package from the /extensions folder.

Advanced

Use custom locations

This must be done before you load any extensions or skins from non-standard directory locations:

If you keep your extensions in a location different from $IP/extensions, you need to override $wgExtensionDirectory , or use the second parameter of wfLoadExtension(), to specify the directory in which to find the extension.
If one or more of your extensions are stored in additional locations, use the second parameter of wfLoadExtension() to specify the location of the .json file for each of those extensions.
wfLoadExtensions() (plural) always uses $wgExtensionDirectory and cannot be overridden.
$wgExtensionDirectory = '/some/path';
wfLoadExtension( 'FooBar' ); // Looks in $wgExtensionDirectory for /some/path/FooBar/extension.json
wfLoadExtension( 'Hello', '/some/other/path/HelloV2/Hello.json' ); // Looks for /some/other/path/HelloV2/Hello.json
If your skins are not in $IP/skins, you need to override the poorly named $wgStyleDirectory , or use the second parameter of wfLoadSkin(), to specify the directory in which to find the skin.
If one or more of your skins are stored in additional locations, use the second parameter of wfLoadSkin() to specify the location of the .json file for each of those skins.
wfLoadSkins() (plural) always uses $wgStyleDirectory and cannot be overridden.
$wgStyleDirectory = '/my/skins';
wfLoadSkins( [ 'BarBaz', 'BazBar' ] ); // Looks in $wgStyleDirectory for both /my/skins/BarBaz/skin.json and /my/skins/BazBar/skin.json
wfLoadSkin( 'BamBam', '/yet/another/path/BamBam/skin.json' ); // Looks for /yet/another/path/BamBam/skin.json

Migrate from require_once

Before MediaWiki 1.25, configuration for extensions and skins was done in a PHP file using the extension's or skin's name, for example MyExtension.php or MySkin.php. To install an extension with LocalSettings.php, you would use require_once to call this PHP file:

require_once "$IP/extensions/Hello/Hello.php";
require_once "$IP/extensions/FooBar/FooBar.php";
$wgFooBarEnable = true;
require_once "$IP/skins/Baz/Baz.php";
require_once "/tmp/extension/some/where/else/BarFoo/BarFoo.php";

If the extensions are recent enough to support the current registration system, you would convert this to:

wfLoadExtensions( [ 'Hello', 'FooBar' ] );
$wgFooBarEnable = true;
wfLoadSkin( 'Baz' );
wfLoadExtension( 'BarFoo', '/tmp/extension/some/where/else/BarFoo/extension.json' );