Jump to content

Manual talk:Sites table

About this board

How can you find out the file_path for a wiki?

2
216.114.117.77 (talkcontribs)

I'm trying to follow the instructions for adding a new site. It's not clear to me how to figure out what the file_path should be. In the examples (including the one provided by addSite.php's help flag), they differ from the page_path. Do I just need to mimic the the URL for a file in the File namespace?

Lucamauri (talkcontribs)

One easy way to build it is to go to Special:Version page of the wiki and look for the "Script path" in paragraph "Entry point URLs".

That path will look something like /wikifolder. Then compose the file_path by concatenating the base url of the wiki (like https://www.somewiki.org), the Script path and /$1 into something like https://www.somewiki.org/wikifolder/$1.

Reply to "How can you find out the file_path for a wiki?"

Where would you use the custom script to add a site to the table?

2
Lwangaman (talkcontribs)

The page talks about using a custom script ("Insert wiki family (using Script)"). I have just used the populateSitesTable.php script running it once for each wiki ID, and it successfully populated the sites table for each language wiki with a list of default wiki sites. Now I think I need to add my own wiki to this list in order to be able to use the "add link" feature for any given page. Where would I use the suggested script? Do I create a php file somewhere? Or add this within another script such as addSite.php?

$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 );

Obviously switching out "mywiki" with my own wiki namespace.

Lwangaman (talkcontribs)

I believe I have succeeded in completing this task. I created a file "addMyWikiFarm.php" in the maintenance folder with these contents:

 1 <?php
 2 class AddMyWikiFarm extends Maintenance {
 3 
 4 	public function __construct() {
 5 		$this->addDescription( 'Add my Custom Wiki Farm definitions into the sites table.' );
 6 
 7 		parent::__construct();
 8 	}
 9 
10 	/**
11 	 * Imports the sites of my Wiki Farm
12 	 * into the sites table of this MediaWiki installation.
13 	 * @return bool
14 	 */
15 	public function execute() {
16 		$siteStore = MediaWikiServices::getInstance()->getSiteStore();
17 		if ( method_exists( $siteStore, 'reset' ) ) {
18 			// @phan-suppress-next-line PhanUndeclaredMethod
19 			$siteStore->reset();
20 		}
21 
22         $sites = [];
23         foreach ( [ 'en', 'it' ] as $langCode ) {
24             $site = new MediaWikiSite();
25         	if ( $siteStore->getSite( $langCode . 'mywikisite' ) !== null ) {
26         		echo "Site with global id {$langCode}mywikisite already exists.\n";
27         		return false;
28         	}
29             $site->setGlobalId( $langCode . 'mywikisite' );
30             $site->setGroup( 'mywikifarm' );
31             $site->setLanguageCode( $langCode );
32             $site->addInterwikiId( $langCode );
33             $site->addNavigationId( $langCode );
34             $site->setPath( MediaWikiSite::PATH_PAGE, "https://pathto.mywikisitepages.com/$langCode/$1" );
35             $site->setPath( MediaWikiSite::PATH_FILE, "https://pathto.mywikisitescripts.com/$langCode/$1" );           
36             $sites[] = $site;
37         }
38                   
39         $siteStore->saveSites( $sites );
40 		if ( method_exists( $siteStore, 'reset' ) ) {
41 			// @phan-suppress-next-line PhanUndeclaredMethod
42 			$siteStore->reset();
43 		}
44 
45 		echo "Done.\n";
46 	}
47 }
48 
49 $maintClass = AddMyWikiFarm::class;
50 require_once RUN_MAINTENANCE_IF_MAIN;

Then I ran php maintenance/addmyWikiFarm.php --wiki WIKIID from the command line for each of my language wikis and the wikifarm language sites do seem to have been added to the sites table of these wikis. Am still trying to figure out how to get the "add link" on the sidebar to work for the interwiki...

Reply to "Where would you use the custom script to add a site to the table?"

site_language conflict?

1
Deletedaccount4567435 (talkcontribs)

Is language code like en/ja/zh already defined in Mediawiki?

I tried to add Sites in following formate with addSite.php. This site do appear in Site table. However, there were nothing under site_language column. What's the correct way to insert type="language"?

<site type="mediawiki">

<globalid>enmoegirl</globalid>

<localid type="interwiki">enmoegirl</localid>

<localid type="language">en</localid>

<group>moegirlpedia</group>

<path type="link">https://en.moegirl.org/</path>

</site>

Reply to "site_language conflict?"
Till Kraemer (talkcontribs)

Hi,

I'd like to know what I have to enter into the site_data field. Currently my table looks like this:

a:1:{s:5:"paths";a:2:{s:9:"file_path";s:5:"/w/$1";s:9:"page_path";s:8:"/wiki/$1";}}

Is there some documentation out there on how to populate the site_data field?

Thanks and cheers,

Till Kraemer (talkcontribs)

P.S.: Looks like the number after "s:" seems to be the amount of characters followed, for example "file_path" has 9 characters.

Reply to "site_data"
There are no older topics