Open main menu

MediaWiki β

Project:Support desk

About this board

vde   Welcome to MediaWiki.org's Support desk, where you can ask MediaWiki questions!

There are also other places where to askCommunication: IRCCommunication#Chat, mailing listsMailing lists, Wikimedia Developer Support, Q&A, mwusers (unofficial forum) etc.

Before you post

Post a new question

  1. To help us answer your questions, please always indicate which versions you are using (reported by your wiki's Special:Version page):
    • MediaWiki
    • PHP
    • Database
  2. Please include the URL of your wiki unless you absolutely can't. It's often a lot easier for us to identify the source of the problem if we can look for ourselves.
  3. To start a new thread, click "Start a new topic".

Brand new installation - can't edit pages

5
Rpsjab (talkcontribs)

I would like to use MediaWiki for a knowledge-base for my class.

I installed vanilla 1.30 (no extensions) and am running PHP 5.6 and MySQL . Everything went smoothly during install. I can see the main page, I can log in and can get into edit mode on the main and talk pages, and I can even successfully upload files. But whenever I try to save a page, the response times out (ERR_TIMED_OUT) after about 10 seconds. I have tried searching for the issue, but without success. I enabled all the debugging from the manual, including the log file. Tail of the log file looks fine. Any suggestions would be appreciated.

website is at: http://raspberry.rochester.k12.mn.us/w

should also mention - have tried multiple browsers on multiple computers, so not a browser or extension issue.

[DBQuery] wikidb COMMIT /* MWCallableUpdate::doUpdate  */

[DBQuery] wikidb SELECT /* JobQueueDB::doGetSiblingQueuesWithJobs  */  DISTINCT job_cmd  FROM `job`    WHERE job_cmd IN ('refreshLinks','deleteLinks','htmlCacheUpdate','sendMail','enotifNotify','fixDoubleRedirect','AssembleUploadChunks','PublishStashedFile','ThumbnailRender','recentChangesUpdate','refreshLinksPrioritized','refreshLinksDynamic','activityUpdateJob','categoryMembershipChange','cdnPurge','enqueue','null')   

Request ended normally

[session] Saving all sessions on shutdown

[DBConnection] Closing connection to database 'localhost'.

[DBConnection] Closing connection to database 'localhost'.

星耀晨曦 (talkcontribs)

Have you checked your web-server error log?

Rpsjab (talkcontribs)

yes, nothing unusual in the apache log.

星耀晨曦 (talkcontribs)

Are you sure you've carefully checked your debug log? The debug log for mediawiki is very complicated, since load page action or save edit action there will be several requests. Debug information about saving edits is probably not placed at tail of the debug log. You should search StashEdit from tail to head and check its context. The context should be similar:

[ContentHandler] Created handler for wikitext: WikitextContentHandler
User: loading options for user 1 from override cache.
EditPage::edit: enter
EditPage::importFormData: Passed token check.
[DBConnection] Connected to database 0 at '0.0.0.0'.
[MessageCache] MessageCache::load: Loading zh... local cache is empty, got from global cache
[TitleBlacklist-cache] Updated DB:title_blacklist_entries with 0 entries.User::getBlockedStatus: checking...
[SpamBlacklist] Spam blacklist validator: [[User:星耀晨曦/沙盒]] not a local blacklist
timestamp: 20180217143541, edittime: 20180217143541
EditPage::internalAttemptSave: getting section ''
ConfirmEdit: user group allows skipping captcha
ConfirmEdit: no need to show captcha.
[StashEdit] Timestamp-based cache hit for key 'DB:prepared-edit:' (age: 2 sec).
[StashEdit] AbuseFilter::filterAction: cache hit for 'User:星耀晨曦/沙盒' (key gakuencityDB:abusefilter:check-stash:default:a3bd6483e34e8924bfca427dc299e6c0:v1).
[cookie] setcookie: "DBPostEditRevision5181", "saved", "59iwks9e5", "/", "", "1", "1"
MediaWiki::preOutputCommit: primary transaction round committed
WikiPage::doEditUpdates: Using prepared edit...
[caches] parser: MemcachedPhpBagOStuff
Rpsjab (talkcontribs)

I will check and report back. Thank you.

Reply to "Brand new installation - can't edit pages"

Define localization translation for namspace via mediawiki namespace

1
星耀晨曦 (talkcontribs)

I define a new customized namespace in my wiki. Can I define a localization translation for namspace via mediawiki namespace?

Reply to "Define localization translation for namspace via mediawiki namespace"
Horus (talkcontribs)

Hello. Regarding Manual:User group CSS and Javascript, can I create CSS for anonymous users? I have tried using "user-show" as in en:w:MediaWiki:Group-user.css but it does not look like IPs are affected by it, as IPs will still see both "anonymous-show" and "user-show", while users see only "user-show." Thanks.

Ciencia Al Poder (talkcontribs)

Use MediaWiki:Common.css for all (anons included) then override it (if needed) in the MediaWiki:Group-user.css.

There's no CSS exclusive for anons.

Reply to "Anon group CSS"
ZakirH (talkcontribs)

I am getting the login token using a POST API calling this URL "http://localhost:81/mediawiki/api.php?action=query&meta=tokens&type=login&format=json" with the below post object

my post object is { lgname: test123, lgpassword: test@123 }.

Once I got the logintoken and session created, I am again doing a POST call to this URL"http://localhost:81/mediawiki/api.php?action=query&meta=tokens&type=csrf&format=json" with the below cookie information

bitnami_mediawiki_session: e6ggc1bi6jt2qck5rubgpddi6bq0jc9s; bitnami_mediawikiUserID:1;bitnami_mediawikiUserName: test123

Even after doing the above steps, I am still receiving anon token (+). Is there anything I am doing wrong or missing? Any assistance would be of great help.

Margarethkearney (talkcontribs)

I am having the same issue. Has anyone been able to figure out how to do this.

2604:6000:84C1:A900:4959:984E:73CD:B115 (talkcontribs)

    function requestCSRFtoken($wiki)

    {

        $parameters = array(

                            'action' => 'query',                     

                            'format'=>'json',

                            'maxlag'=>'10',

                            'smaxage'=>'0',

                            'maxage'=>'0',

                            'assert'=>'user',

                            'assertuser'=>'Admin2',

                            'requestid'=>'1',

                            'servedby'=>'true',

                            'curtimestamp'=>'true',

                            'responselanginfo'=>'1',

                            'origin'=>'*',

                            'uselang'=>'user',

                            'centralauthtoken'=>'123',

                            'meta'=>'tokens',

                            'type'=>'csrf'

                            );  

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $wiki);

        curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);

        curl_setopt($ch, CURLOPT_POST, true);

        curl_setopt($ch, CURLOPT_POSTFIELDS,  http_build_query($parameters));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_COOKIESESSION, true);

        curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie-name');

        curl_setopt($ch, CURLOPT_COOKIEFILE, '/var/www/ip4.x/file/tmp');

        $answer = curl_exec($ch);

        return $answer;

    }   

    $wiki = "https://breakofdaymhg.com/staff/wiki/api.php";

    //ebsh7p6e6q

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) (localhost)

2
Strela9K (talkcontribs)

MediaWiki V1.30.0

PHP version 5.6.33-0+deb8u1 (apache2handler)

MySQL version 5.5.59-0+deb8u1-log

URL: https://wiki.iceh.eu/index.php/Main_Page

Hey, I have a wiki for own purposes running on a raspberry pi. It used to work without a problem, but now I'm having trouble opening my

Ansible - Configuration page https://wiki.iceh.eu/index.php/Configuration All other pages work. I tried to run php update.php just in case.

It seems like my MySQL crashes (restarts) when I try to access Configuration. I get the following error:

MediaWiki internal error.

Original exception: [e8c603824f627c5fc7fbdf09] /index.php/Configuration Wikimedia\Rdbms\DBQueryError from line 1149 of /usr/share/mediawiki-1.30.0/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?

Query: SELECT old_text,old_flags FROM `text` WHERE old_id = '41' LIMIT 1

Function: Revision::fetchText

Error: 2002 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) (localhost)

Backtrace:

#0 /usr/share/mediawiki-1.30.0/includes/libs/rdbms/database/Database.php(979): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)

#1 /usr/share/mediawiki-1.30.0/includes/libs/rdbms/database/Database.php(1343): Wikimedia\Rdbms\Database->query(string, string)

#2 /usr/share/mediawiki-1.30.0/includes/libs/rdbms/database/Database.php(1411): Wikimedia\Rdbms\Database->select(string, array, array, string, array, array)

#3 /usr/share/mediawiki-1.30.0/includes/Revision.php(1672): Wikimedia\Rdbms\Database->selectRow(string, array, array, string, array)

#4 /usr/share/mediawiki-1.30.0/includes/Revision.php(1637): Revision->fetchText()

#5 [internal function]: Revision->{closure}(boolean, integer, array, NULL)

#6 /usr/share/mediawiki-1.30.0/includes/libs/objectcache/WANObjectCache.php(1012): call_user_func_array(Closure, array)

#7 /usr/share/mediawiki-1.30.0/includes/libs/objectcache/WANObjectCache.php(914): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)

#8 /usr/share/mediawiki-1.30.0/includes/Revision.php(1640): WANObjectCache->getWithSetCallback(string, integer, Closure, array)

#9 /usr/share/mediawiki-1.30.0/includes/Revision.php(1084): Revision->loadText()

#10 /usr/share/mediawiki-1.30.0/includes/Revision.php(1101): Revision->getSerializedData()

#11 /usr/share/mediawiki-1.30.0/includes/Revision.php(1071): Revision->getContentInternal()

#12 /usr/share/mediawiki-1.30.0/includes/page/Article.php(362): Revision->getContent(integer, User)

#13 /usr/share/mediawiki-1.30.0/includes/page/Article.php(552): Article->fetchContentObject()

#14 /usr/share/mediawiki-1.30.0/includes/actions/ViewAction.php(68): Article->view()

#15 /usr/share/mediawiki-1.30.0/includes/MediaWiki.php(499): ViewAction->show()

#16 /usr/share/mediawiki-1.30.0/includes/MediaWiki.php(293): MediaWiki->performAction(Article, Title)

#17 /usr/share/mediawiki-1.30.0/includes/MediaWiki.php(851): MediaWiki->performRequest()

#18 /usr/share/mediawiki-1.30.0/includes/MediaWiki.php(523): MediaWiki->main()

#19 /usr/share/mediawiki-1.30.0/index.php(43): MediaWiki->run()

#20 {main}

Exception caught inside exception handler: [e8c603824f627c5fc7fbdf09] /index.php/Configuration Wikimedia\Rdbms\DBConnectionError from line 800 of /usr/share/mediawiki-1.30.0/includes/libs/rdbms/database/Database.php: Cannot access the database: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) (localhost)

Backtrace:

#0 /usr/share/mediawiki-1.30.0/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1028): Wikimedia\Rdbms\Database->reportConnectionError(string)

#1 /usr/share/mediawiki-1.30.0/includes/libs/rdbms/loadbalancer/LoadBalancer.php(670): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()

#2 /usr/share/mediawiki-1.30.0/includes/GlobalFunctions.php(2858): Wikimedia\Rdbms\LoadBalancer->getConnection(integer, array, boolean)

#3 /usr/share/mediawiki-1.30.0/includes/cache/localisation/LCStoreDB.php(45): wfGetDB(integer)

#4 /usr/share/mediawiki-1.30.0/includes/cache/localisation/LocalisationCache.php(392): LCStoreDB->get(string, string)

#5 /usr/share/mediawiki-1.30.0/includes/cache/localisation/LocalisationCache.php(291): LocalisationCache->loadSubitem(string, string, string)

#6 /usr/share/mediawiki-1.30.0/languages/Language.php(2587): LocalisationCache->getSubitem(string, string, string)

#7 /usr/share/mediawiki-1.30.0/includes/cache/MessageCache.php(933): Language->getMessage(string)

#8 /usr/share/mediawiki-1.30.0/includes/cache/MessageCache.php(888): MessageCache->getMessageForLang(LanguageEn, string, boolean, array)

#9 /usr/share/mediawiki-1.30.0/includes/cache/MessageCache.php(829): MessageCache->getMessageFromFallbackChain(LanguageEn, string, boolean)

#10 /usr/share/mediawiki-1.30.0/includes/Message.php(1275): MessageCache->get(string, boolean, LanguageEn)

#11 /usr/share/mediawiki-1.30.0/includes/Message.php(842): Message->fetchMessage()

#12 /usr/share/mediawiki-1.30.0/includes/Message.php(971): Message->toString(string)

#13 /usr/share/mediawiki-1.30.0/includes/exception/MWExceptionRenderer.php(131): Message->escaped()

#14 /usr/share/mediawiki-1.30.0/includes/exception/MWExceptionRenderer.php(54): MWExceptionRenderer::reportHTML(Wikimedia\Rdbms\DBQueryError)

#15 /usr/share/mediawiki-1.30.0/includes/exception/MWExceptionHandler.php(75): MWExceptionRenderer::output(Wikimedia\Rdbms\DBQueryError, integer)

#16 /usr/share/mediawiki-1.30.0/includes/exception/MWExceptionHandler.php(130): MWExceptionHandler::report(Wikimedia\Rdbms\DBQueryError)

#17 /usr/share/mediawiki-1.30.0/includes/MediaWiki.php(550): MWExceptionHandler::handleException(Wikimedia\Rdbms\DBQueryError)

#18 /usr/share/mediawiki-1.30.0/index.php(43): MediaWiki->run()

#19 {main}

Ciencia Al Poder (talkcontribs)

Look at the mysql error logs in case it contains hints about what can be happening and to confirm if mysql is crashing on that page.

Reply to "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) (localhost)"

External link opening in a new tab in the browser

2
Indrik2 (talkcontribs)

How can I have an external link open a new tab in the browser?

AhmadF.Cheema (talkcontribs)

See Manual:$wgExternalLinkTarget.

Reply to "External link opening in a new tab in the browser"

Fatal exception of type Scribunto_LuaInterpreterNotFoundError

9
96.35.210.116 (talkcontribs)

I tried installing the Scribunto but I'm getting the above error, this is on a freebsd box

96.35.210.116 (talkcontribs)

Anybody?

204.193.72.15 (talkcontribs)

Seriously? Nobody has an answer to this? I cannot be the first person on a freebsd box to have this problem

88.130.91.246 (talkcontribs)

Maybe you are the first person with this very issue.

204.193.72.15 (talkcontribs)

I would be totally surprised if I was, but I guess anything is possible. I never would have thought that my phone calls were being tracked either but I guess we know that's a distinct possibility.

Verizons' "Can you hear me now" was really their way of talking to the NSA.

204.193.72.15 (talkcontribs)

Ok I got past the fatal exception error by adding the following lines to the LocalSettings file:

$wgScribuntoEngineConf['luastandalone']['luaPath'] = '/path/to/lua'; $wgScribuntoEngineConf['luastandalone']['errorFile'] = '/path/to/error/file';

the error log just shows TX and RX entries, that's it. I had installed a lua package on the freebsd box and just pointed the Local Settings file to the binary.

I'm now getting a "Script Error" on my pages, but that's all it says.....

Ideas?

50x40px This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (October 2007) Script error

96.35.210.116 (talkcontribs)

Well its still a problem with Scribunto its just not throwing the same error, I tried downloading the source and compiling but that didn't seem to work either, so now I'm just frustrated.

88.130.91.246 (talkcontribs)

I am sorry to hear, but I don't use Scribunto myself; I only googled your error - without results. I don't know either.

Chuck.Kahn (talkcontribs)

I am the second person to have this error but I'm new at this and don't know the solution yet.

Reply to "Fatal exception of type Scribunto_LuaInterpreterNotFoundError"
Chuck.Kahn (talkcontribs)

I'm reading the Extension:JsonConfig/Tabular page and can't figure out what I'm doing wrong.

I added JsonConfig to my Extension folder. My http://worldwideboxoffice.com/wiki/index.php/Special:Version page says that it is installed. But how do install the Tabular function?

I added this code block:

$wgJsonConfigModels['Tabular.JsonConfig'] = 'JsonConfig\JCTabularContent'; $wgJsonConfigs['Tabular.JsonConfig'] = array( 'namespace' => 486, // === NS_DATA, but the constant is not defined yet 'nsName' => 'Data', 'isLocal' => false, 'pattern' => '/.\.tab$/' );

and then this code block:

$wgJsonConfigs['Tabular.JsonConfig']['remote'] = 'https://commons.wikimedia.org/w/api.php';

To the end of my LocalSettings.php file, but the example.tab doesn't display as a table:

http://worldwideboxoffice.com/wiki/index.php/Data_test

Using the example data source:

http://worldwideboxoffice.com/wiki/index.php/Data:Sandbox/Name/Example.tab

Help?

Ciencia Al Poder (talkcontribs)

Placing mw.ext.data.get("Example.tab") on the page won't work. This is Lua code and should be placed in a Module (modules are provided by Extension:Scribunto).

Chuck.Kahn (talkcontribs)

Thanks. Added the Scribunto module and it shows up here:

http://worldwideboxoffice.com/wiki/index.php/Special:Version

But the test page doesn't seem to be working upon reload:

http://worldwideboxoffice.com/wiki/index.php/Data_test

AhmadF.Cheema (talkcontribs)

"Module" here means in the Module namespace, for example:

http://worldwideboxoffice.com/wiki/index.php/Module:Data_test

Chuck.Kahn (talkcontribs)

Thanks. When I save it there I get this error:

[WpL9LMVSr8Am0HcZljq6KQAAABc] 2018-02-25 18:15:09: Fatal exception of type Scribunto_LuaInterpreterNotFoundError

Does it need the full path where the Example.tab exists?

mw.ext.data.get("Sandbox/Name/Example.tab")

Reply to "Installing Extension:JsonConfig/Tabular"

WM Api, Can't create CSRF Token... Returns Blank

2
Pai1976 (talkcontribs)

I am having a difficult time figuring out how to correctly implement this api. Any help would be super appreciated!!

I am using CURL in PHP., Getting this Result(N0 CSRF token)

Array
(
    [batchcomplete] => 
    [query] => Array
        (
            [tokens] => Array
                (
                    [csrftoken] => +\
                    [watchtoken] => +\
                    [patroltoken] => +\
                    [rollbacktoken] => +\
                    [userrightstoken] => +\
                    [logintoken] => c875cf8ce3e1f1786ab1486b1a012c395a922b2a+\
                    [createaccounttoken] => add02aeb90d07e7ec81c6d49f46ec0e85a922b2a+\
                )

        )

)
Array
(
    [error] => Array
        (
            [code] => badtoken
            [info] => Invalid CSRF token.
            [*] => See https://breakofdaymhg.com/staff/wiki/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.
        )

)

Here is my Code:

<?

    //Define Your Endpoint here

    $endPoint = "MYWEBSITE.com/wiki/api.php";

    $botUsername = "MYAdmin";

    $botPassword = "MYBot@f4apm209rhaa1seds56tkt1uroapo123";

    $cookies = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';

    //Force HTTPS when your endpoint also uses HTTPS

    if(substr(strtolower($endPoint),0,5) == "https"){ForceHTTPS();}

    //Helper functions

    function ForceHTTPS()

    {

        if($_SERVER["HTTPS"] != "on")

        {

            $pageURL = "Location: https://";

            if ($_SERVER["SERVER_PORT"] != "80")

            {

                $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];

            }

            else

            {

                $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];

            }

            header($pageURL);

        }       

    }

    function ShowErrors()

    {

        ini_set('display_errors', 1);

        ini_set('display_startup_errors', 1);

        error_reporting(E_ALL);       

    }

    // API Implementation

    function GetLoginToken($username, $password, $endPoint, $cookieName, $cookieFile)

    {

        $endPoint.="?action=query&meta=tokens&type=login&format=json";

        $parameters = [];

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $endPoint);

        curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);

        //curl_setopt($ch, CURLOPT_POST, true);

        //curl_setopt($ch, CURLOPT_POSTFIELDS,  http_build_query($parameters));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_COOKIESESSION, true);

        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieName);

        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

        session_write_close();

        $json = curl_exec($ch);

        curl_close($ch);

        $arr =json_decode($json, true);

        return $arr['query']['tokens']['logintoken'];

    }

    function Login($username, $password, $endPoint, $cookieName, $cookieFile, $loginToken)

    {//Requires POST Request

        $parameters = ['action'=>'login',

                       'format'=>'json',

                       'lgname'=>$username,

                       'lgpassword'=>$password,

                       'lgtoken'=>$loginToken

        ];

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $endPoint);

        curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);

        curl_setopt($ch, CURLOPT_POST, true);

        curl_setopt($ch, CURLOPT_POSTFIELDS,  http_build_query($parameters));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_COOKIESESSION, true);

        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieName);

        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

        session_write_close();

        $json = curl_exec($ch);

        curl_close($ch);

        $arr =json_decode($json, true);

        return $arr['login']['token'];       

    }

    function createUser($token, $endPoint, $cookieName, $cookieFile)

    {

        //action=createaccount&createreturnurl=http://example.com/&createtoken=29590a3037d325be70b93fb8258ed29257448cfb%2B%5C&username=Carl&mailpassword=1&email=carl%40example.com&realname=&reason=Carl%20asked%20me%20to.

        $parameters = ['action'=>'createaccount',

                       'format'=>'json',

                       'createreturnurl'=>'',

                       'username'=>'test',

                       'mailpassword'=>'1',

                       'email'=>urlencode('info@ishaktech.com'),

                       'realname'=>'paul ishak',

                       'reason'=>'autocreate',

                       'createtoken'=>urlencode($token)];

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $endPoint);

        curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);

        curl_setopt($ch, CURLOPT_POST, true);

        curl_setopt($ch, CURLOPT_POSTFIELDS,  http_build_query($parameters));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_COOKIESESSION, true);

        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieName);

        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

        session_write_close();

        $json = curl_exec($ch);

        curl_close($ch);

        $arr =json_decode($json, true);

        ?><pre><? print_r($arr);?></pre><?

        //return $arr['login']['token'];

    }

    function GetCSRFToken($endPoint, $cookieName, $cookieFile)

    {

        //?action=query&format=json&meta=tokens&type=csrf|watch|patrol|rollback|userrights|login|createaccount;

        $parameters = ['action'=>'query',

                       'format'=>'json',

                       'meta'=>'tokens',

                       'type'=>'csrf|watch|patrol|rollback|userrights|login|createaccount'];

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $endPoint);

        curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);

        curl_setopt($ch, CURLOPT_POST, true);

        curl_setopt($ch, CURLOPT_POSTFIELDS,  http_build_query($parameters));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_COOKIESESSION, true);

        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieName);

        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

        session_write_close();

        $json = curl_exec($ch);

        curl_close($ch);

        $arr =json_decode($json, true);

        ?><pre><? print_r($arr);?></pre><?

        return $arr['query']['tokens']['csrftoken'];

    }

    ShowErrors();

    $loginToken = GetLoginToken($botUsername, $botPassword, $endPoint, $cookies, $cookies);           

    $csrfToken = GetCSRFToken($endPoint, $cookies, $cookies);

    createUser($csrfToken, $endPoint, $cookies, $cookies);      

?>

星耀晨曦 (talkcontribs)

Wikimedia Developer Support may be more suitable to ask you this question.

Reply to "WM Api, Can't create CSRF Token... Returns Blank"

Generate LocalSettings.php from an existing MW database (without removing it)

5
Toniher (talkcontribs)

Hello, I'm checking install.php maintenance script, and I'm wondering if there is any parameter/option/additional maintenance script via command-line for generating a LocalSettings.php file from an existing DB installation.

Thanks!

星耀晨曦 (talkcontribs)

In general, the configuration is not stored in the database. So, you can't generate a LocalSettings.php from an existing DB installation. Of course, you can also develop the corresponding extension to meet your needs.

2001:16B8:10F2:3400:8CCF:3FDD:68E3:7673 (talkcontribs)

I am not sure I understand: An existing installation will already have a LocalSettings.php file. So there is no need to recreate one - you can just copy it!

What do you want to achieve?

Toniher (talkcontribs)

In my case I'm working with Docker containers and LocalSettings.php is kept in the image/container and not mounted. If rebuilt a new image / run a new container, I want to generate a new LocalSettings.php mapping a DB that I'm not creating from scratch. I would dare to say what I am asking is actually possible via web interface. I'm wondering whether could be possible via CLI...

2001:16B8:10F2:3400:A150:F8BA:2A8F:73AD (talkcontribs)

I don't know docker enough: What are the differences between all the different images/containers, which you later can create?

Are they all completely separate in a way that they could e.g. always use the same DB name for example?

And apart from the database credentials: Should they be identically configured?

(Reading what you want to achieve, I think this must be kind of a standard usecase for docker...)

Reply to "Generate LocalSettings.php from an existing MW database (without removing it)"