Project:Support desk

Jump to navigation Jump to search

About this board

Welcome to the MediaWiki Support desk, where you can ask MediaWiki questions!

(Read this message in a different language)

See also

Other places to ask for help:

Before you post

Post a new question

  1. To help us answer your questions, please indicate which versions you are using, as found on your wiki's Special:Version page:
    • MediaWiki version
    • PHP version
    • Database type and version
  2. Please include the web address (URL) to your wiki if possible. It's often easier for us to identify the source of the problem if we can see the error directly.
  3. To start a new thread, click "Start a new topic".
Drew1209 (talkcontribs)

Hi everyone,

Ive been recently tasked with updating an older media wiki ( about 6 years ago) i know the version of ubuntu, mediawiki, php, and MySQL when the version was last running. I have access to the sql dump from the wiki archive. I have never worked with media wiki before and i really confused on how to start. I have basic technology knowledge but i dont understand how to even run the last working version of the wiki let alone update the site. If anyone is able to give me a quick overview of what i will need to do to just start that would be super helpful. I've viewed the page here on manual updating and it looks like there may be steps to complete before even looking into that page.

Reply to "New to mediawiki"

Question about the writeapi right

1
Costas Athan (talkcontribs)

According to the relative documentation the writeapi user permission enables the groups with that permission (*, user, bot) to use the write API.

The write API includes modules like Delete for example for deletion of pages.

The delete permission is set to true for the sysop group, but is not set at all for the * group in the DefaultSettings.php file. Despite the fact that the writeapi permission is enabled for the unregistered users and the fact that the delete permission is not defined for them, deleting a page through the write API is not possible for users that aren't logged in.

My question is which permissions does actually the writeapi permission give to the groups to which is assigned or in other words what does block the execution of a delete request through the API for the unregistered users?

Reply to "Question about the writeapi right"
Costas Athan (talkcontribs)

Which users does actually the * group represent?

Based on the documentation which mentions "all users (including anonymous)", I had the impression that any change made for the * group would be inherited by all the other groups.

In practice though, for example setting $wgGroupPermissions['*']['edit'] = false; does prevent only unregistered users from editing pages and has no effect on logged in users who belong to the "user" group.

So which users are part of the * group?

MarkAHershberger (talkcontribs)

The * covers all users if no other groups have that permission set. If you look at DefaultSettings.php, though, you'll see that logged in users, by default, are explicitly allowed to edit. So $wgGroupPermissions['*']['edit'] = false; takes away anonymous user's right to edit, but not logged in users because $wgGroupPermissions['user']['edit'] = true;

Costas Athan (talkcontribs)

@MarkAHershberger


OK. So in this case all, doesn't mean literally all, but all the ones who haven't a permission set through other groups. Maybe this should be explicitly explained in the documentation.

Reply to "Question about * user group"

Error contacting the Parsoid/RESTBase server (HTTP 415)

8
189.217.121.39 (talkcontribs)

I just installed mediawiki 1.35 every time I edit with the visual editor, when I save changes, I get error 415 and I don't know what happens, what can I do?

MarkAHershberger (talkcontribs)

Check your access log and tell us what lines you see there for rest.php.

189.217.121.39 (talkcontribs)

i can't obtain access of the logs of the visualeditor, my wiki is alojed in host shared

Gota de agua (talkcontribs)

i check yhis mistake of the file rest.php

{"messageTranslations":{"es":"La ruta relativa solicitada () no coincide con ningún controlador conocido","en":"The requested relative path () did not match any known handler"},"httpCode":404,"httpReason":"Not Found"}

MarkAHershberger (talkcontribs)

How was that generated? And, it looks like VE is not set up correctly. How did you install it?

Gota de agua (talkcontribs)

that was installed with the mediawiki installation

MarkAHershberger (talkcontribs)

Can you add the following to your LocalSettings.php:

$logDir = "$IP/cache";
$wgDebugLogGroups['rest'] = "$logDir/rest.php";

(Change $logDir to something the webserver can write to, if needed.) And apply the following diff:

diff --git a/includes/Rest/EntryPoint.php b/includes/Rest/EntryPoint.php
index 84704e67bb..e9031619a7 100644
--- a/includes/Rest/EntryPoint.php
+++ b/includes/Rest/EntryPoint.php
@@ -130,14 +130,23 @@ class EntryPoint {
 
 	public function execute() {
 		ob_start();
+
+		wfDebugLog( "rest", __METHOD__ . " got router: " . get_class( $this->router ) );
 		$response = $this->router->execute( $this->request );
+		$proto = $response->getProtocolVersion();
+		$req = $this->request->getUri();
+		$code = $response->getStatusCode();
+		$reason = $response->getReasonPhrase();
+		wfDebugLog( "rest", "Got $code:$reason in response to $req" );
 
-		$this->webResponse->header(
-			'HTTP/' . $response->getProtocolVersion() . ' ' .
-			$response->getStatusCode() . ' ' .
-			$response->getReasonPhrase() );
+		$this->webResponse->header( "HTTP/$proto $code $reason" );
 
-		foreach ( $response->getRawHeaderLines() as $line ) {
+		wfDebugLog( "rest", "body: " . $this->request->getBody() );
+		foreach ( $this->request->getHeaders() as $headerType => $line ) {
+			wfDebugLog( "rest", "< $headerType: " . implode( "/", $line ) );
+		}
+		foreach ( $response->getRawHeaderLines() as $lineNo => $line ) {
+			wfDebugLog( "rest", "> $lineNo: $line" );
 			$this->webResponse->header( $line );
 		}
 
diff --git a/includes/Rest/Router.php b/includes/Rest/Router.php
index b6e674ea3c..1cb1b4f41f 100644
--- a/includes/Rest/Router.php
+++ b/includes/Rest/Router.php
@@ -362,8 +362,10 @@ class Router {
 		}
 
 		// Run the main part of the handler
+		wfDebugLog( "rest", "About to execute: " . get_class( $handler ) );
 		$response = $handler->execute();
 		if ( !( $response instanceof ResponseInterface ) ) {
+			wfDebugLog( "rest", "Response: $response" );
 			$response = $this->responseFactory->createFromReturnValue( $response );
 		}
 

(If you don't know what I mean by "apply the following diff", let me know and I'll try to guide you through it.)


After that, you should get messages in your rest.log file (the one you will have told MediaWiki to log requests to with your LocalSettings.php modifications) which should begin to give us an idea of what is happening.

Gota de agua (talkcontribs)

ok, i add the lines a localsentigs.php i don't undernstand "aplic the next diference " the file rest.log where to consult?

Reply to "Error contacting the Parsoid/RESTBase server (HTTP 415)"

Requesting help using API action=clientlogin

4
Mrwassen (talkcontribs)

Hi guys,

As a relative noobie to mediawiki I am looking to get a little help regarding a very basic SSO project. I have a php based web site "mysite" which requires user login. I am trying to come up with a php script that does the following:


1) User logs into mysite

2) The user login scripts executes a "wikilogin.php" script

3) The wikilogin.php script logs into mywikisite and creates the required cookies in the browser

4) User can now go to mywikisite and access pages etc. without having to log into mywikisite


I am not trying to build any logic to manage user creation/change/deletion or password change. The assumption for now is simply that credentials are identical across the 2 applications.


I have tried to put together a basic "wikilogin.php" which uses the mediawiki api as follows:

  a) Get a logintoken using "api?action=query&meta=tokens&type=login&format=json

  b) Parse out the returned logintoken to a string variable

  c) Perform the login using "api?action=clientlogin&username=joe&password=secret&logintoken=<token from step 2>"&loginreturnurl=http:mysite,org"


however I am running into the error:

  "code": "badtoken", "info": "Invalid CSRF token."


I have tried to change "type"="csrf" in step 1), however then I get:

  "code": "nologintoken","info": "The \"logintoken\" parameter must be set."


Below is the php - any help would be much appreciated.

Thanks

Dennis


//

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://mywikisite.org/api.php");

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS,

            "action=query&meta=tokens&type=login&format=json");

// Receive server response ...

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);

//echo $server_output;

$logintoken_array = json_decode($server_output);

$logintoken = $logintoken_array->query->tokens->logintoken;

echo $logintoken;

curl_setopt($ch, CURLOPT_URL,"http://mywikisite.org/api.php");

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS,

"action=clientlogin&username=joe&password=secret&logintoken=" . $logintoken . "&loginreturnurl=http://mywikisite.org");

// Receive server response ...

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);

echo $server_output;

curl_close ($ch);

?>

Mrwassen (talkcontribs)

Forgot to mention versions:

mediawiki 1.34.4

php 7.2

Bawolff (talkcontribs)

i think you need to tell curl to save and send cookies for the login to work.


You may also be interested in reading about SessionManager - which i think is the more proper way to do what you are trying to do in MediaWiki.

Mrwassen (talkcontribs)

Hi Bawolff,


Thanks for your help - I was able to make some progress: I rewrote the php script to write a cookie file and then login using action=clientlogin which thankfully returned the following response:

{ "clientlogin": { "status": "PASS", "username": "Admin" }}

However, I think I am still missing something: once this login was successful I was expecting in the same browser to be able to open a mediawiki page without logging in, however the main page is still showing "not logged in".

I also noticed that after the script successfully logged in, there was nothing listed in the browsers "Storage/Cookies" list under the domain.

Is this a case of me not understanding how cookies work?

Any help appreciated.

Dennis

EDIT: or will I need to programmatically open the wiki page from php using something like Headers() after using setcookies() to set the cookies?

EDIT#2:

OK so a little further progress:

I logged in as normal directly through the wiki main page to determine cookie behavior and saw that 3 cookies are created:

1) session cookie containing a token

2) username cookie

3) user ID cookie

I then added code to the php script which replicates these exact cookies after the login is completed using the newly acquired token to create the session cookie.

What I notice is that I can run my php script and see the 3 cookies get created and when the script echos the page, it shows as logged in.

However the moment I click on a link to go to a different wiki page, the user ID and session cookies disappear and only the user ID cookie remains "in the browser" and the page logs out.

So it seems I am close, but the elusive part is how to get those cookies to persist so that the session stays logged in?


php:


<?php

$cookie_jar = tempnam('/volume1/web/cookies','cookie');

//retrieve token

$c = curl_init('http://mywikisite/api.php?action=query&meta=tokens&type=login&format=json');

curl_setopt($c, CURLOPT_POST, 1);

curl_setopt($c, CURLOPT_HEADER, 0);

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);

curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);

$page = curl_exec($c);

$logintoken_array = json_decode($page);

$logintoken = $logintoken_array->query->tokens->logintoken;

echo $logintoken;

curl_close($c);

//log in

$c = curl_init('http://mywikisite/api.php');

$post = [

    'action' => 'clientlogin',

'password' => 'xxxxxxxxx',

    'username' => 'admin',

    'logintoken' => $logintoken,

'loginreturnurl' => 'http://1mywikisite/index.php'

];

$c = curl_init('http://mywikisite/tng/wiki/api.php');

curl_setopt($c, CURLOPT_POST, 1);

curl_setopt($c, CURLOPT_POSTFIELDS, $post);

curl_setopt($c, CURLOPT_HEADER, 0);

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);

curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);

$page = curl_exec($c);

curl_close($c);

//create 3 cookies

$cookie_name = "tng_upgrade_12_3_wiki__session";

$cookie_value = $logintoken;

setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day

$cookie_name = "tng_upgrade_12_3_wiki_UserID";

$cookie_value = "1";

setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day

$cookie_name = "tng_upgrade_12_3_wiki_UserName";

$cookie_value = "Admin";

setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day

//open wiki

$c = curl_init('http://mywikisite/index.php?title=Main_Page');

curl_setopt($c, CURLOPT_HEADER, 0);

curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar);

curl_setopt($c, CURLOPT_COOKIEJAR, $cookie_jar);

$page = curl_exec($c);

echo $page;

curl_close($c);

?>

Reply to "Requesting help using API action=clientlogin"

MediaWiki 1.35 Error contacting the Parsoid/RESTBase server: (curl error: 28) Timeout was reached

4
CharlesCivi (talkcontribs)

I just installed MediaWiki 1.35 on an Amazon Linux EC2 server, with php 7.3 and MariaDB

Everything seems to work fine, except when I try to edit a page using VisualEditor.

I cannot load a page for editing, I get the error:

Error contacting the Parsoid/RESTBase server: (curl error: 28) Timeout was reached

I can edit a new page with VisualEditor, but I when I try to save it, I get the same error.

Error contacting the Parsoid/RESTBase server: (curl error: 28) Timeout was reached

I have no trouble reaching the page via the REST endpoint:

http://MyWayCoolIPAddress/rest.php/v1/page/Main_Page

Which returns:

// 20201019142902

// http://MyWayCoolIPAddress/rest.php/v1/page/Main_Page

{

 "id": 1,
 "key": "Main_Page",
 "title": "Main Page",
 "latest": {
   "id": 1,
   "timestamp": "2020-10-14T17:17:27Z"
 },
 "content_model": "wikitext",
 "license": {
   "url": "",
   "title": ""
 },
 "source": "MediaWiki has been installed.\n\nConsult the User's Guide for information on using the wiki software.\n\n== Getting started ==\n* Configuration settings list\n* MediaWiki FAQ\n* MediaWiki release mailing list\n* Localise MediaWiki for your language\n* Learn how to combat spam on your wiki"

}


If I try to call the API endpoint directly:

http://MyWayCoolIPAddress/api.php?action=visualeditor&paction=parse&page=Main_Page

I get a similar error:

{

   "error": {
       "code": "apierror-visualeditor-docserver-http-error",
       "info": "Error contacting the Parsoid/RESTBase server: (curl error: 28) Timeout was reached",
       "*": "See http://MyWayCoolIPAddress/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."
   }

}

This is MediaWiki 1.35, and as far as I know it includes Parsoid-PHP, so I don't need to do any additional configuration.

I assume VisualEditor is not the problem because I can edit a new page, I just can't save it.

MarkAHershberger (talkcontribs)
CharlesCivi (talkcontribs)

SELinux status: disabled

CharlesCivi (talkcontribs)

Is it trying to reach parsoid from the client, or from the server side and then pass it to the client?

When I try to navigate to http://MyWayCoolIPAddress/api.php?action=visualeditor&paction=parse&page=Main_Page I get the timeout error

But, on the server, I run:

curl http://localhost/api.php?action=visualeditor&paction=parse&page=Main_Page

I get good results. So it must be something is inaccessible from the client, but what?

Reply to "MediaWiki 1.35 Error contacting the Parsoid/RESTBase server: (curl error: 28) Timeout was reached"

Lua error on reference section after importing all the citation module from Wikipedia

5
Goodman Andrew (talkcontribs)

Now all our article references displays:

"Lua error in ...ribunto/includes/engines/LuaCommon/lualib/mwInit.lua at line 23: bad argument #1 to 'old_ipairs' (table expected, got nil)."

This happened in MediaWiki 1.35

MarkAHershberger (talkcontribs)

Did you run update.php?

Goodman Andrew (talkcontribs)
MarkAHershberger (talkcontribs)

Is there a backtrace or is that the entire message?

Goodman Andrew (talkcontribs)
Lua error in ...ribunto/includes/engines/LuaCommon/lualib/mwInit.lua at line 23: bad argument #1 to 'old_ipairs' (table expected, got nil).
Backtrace:
(tail call): ?
[C]: in function "old_ipairs"
...ribunto/includes/engines/LuaCommon/lualib/mwInit.lua:23: in function "ipairs"
Module:Citation/CS1/Utilities:38: in function "in_array"
Module:Citation/CS1:3718: in function "validate"
Module:Citation/CS1:3879: in function "chunk"
mw.lua:518: ?
(tail call): ?
[C]: in function "xpcall"
MWServer.lua:99: in function "handleCall"
MWServer.lua:313: in function "dispatch"
MWServer.lua:52: in function "execute"
mw_main.lua:7: in main chunk
[C]: ?

I know that a lua table is missing in the database but I just don't know how to insert it.

Reply to "Lua error on reference section after importing all the citation module from Wikipedia"
210.245.86.220 (talkcontribs)

Is it possible to set up mediawiki so that user is able to either login through OpenIDConnect or through the normal Mediawiki login?

MarkAHershberger (talkcontribs)
Reply to "Multiple login method"

Preventing to create empty pages

19
Summary by Fokebox

Need to find out one more detail

Fokebox (talkcontribs)

I have a problem at my wiki, most of the users are school pupils and they often create just empty pages adding just a couple words. Are there any tool that can prevent to create empty pages or pages with just couple of words?

Wargo (talkcontribs)
Ciencia Al Poder (talkcontribs)

Extension:AbuseFilter will work for this. You can create a rule like this:

 page_id==0
 &!("#redirec" in lcase(added_lines))
 & (new_size < 20)
Fokebox (talkcontribs)

Guys, can you help me please. How to download Extension:AbuseFilter for older version of my wiki. I have 1.29.1

Bawolff (talkcontribs)

you should use a newer version. Mediawiki 1.29 hasnt been recieving security updates for over a year.


That said, you can get old versions from github https://github.com/wikimedia/mediawiki-extensions-AbuseFilter/archive/REL1_29.zip . I'm not sure if github downloads include vendor dependencies (prob not) so you also have to run composer install --no-dev in the AbuseFilter directory after you have unpacked it

Fokebox (talkcontribs)

It seems to be that I have successfully installed the extension. So we shall I put this code?:

page_id==0
 &!("#redirec" in lcase(added_lines))
 & (new_size < 20)

In localsettings.php file?

Ciencia Al Poder (talkcontribs)
Fokebox (talkcontribs)

Yes, now I try to use it ) Thanks

So, when I try to save the filter in this code:

page_id==0
 &!("#redirec" in lcase(added_lines))
 & (new_size < 20)

I have a system mistake, that there is an error in syntax

Bawolff (talkcontribs)

Syntax seems fine to me, are you sure you tried to add that code exactly?

Fokebox (talkcontribs)
Bawolff (talkcontribs)

Try

article_articleid==0
 &!("#redirec" in lcase(added_lines))
 & (new_size < 20)

instead (older versions of abusefilter might require that instead).

Fokebox (talkcontribs)

Thanks! Now all seems to be fine, all works!

Fokebox (talkcontribs)

Can you also help me how to create a filter that will not allow to non-registered users to insert external links in articles?

Matěj Suchánek (talkcontribs)
action == 'edit'
& user_age == 0
& article_namespace == 0
& added_lines rlike 'https?://'
Fokebox (talkcontribs)

Hi! Can you please help me. I want to make an exception for uploaded files. So it it necessary to provide description and the filter blocks uploading if there isn't such description. So I want users allow to upload files without descriptions

Matěj Suchánek (talkcontribs)

Adding article_namespace !== 6 & or action !== 'upload' & should suffice.

Fokebox (talkcontribs)

Thanks!

The whole code looks now so:

article_articleid==0
 &!("#redirec" in lcase(added_lines))
 & (new_size < 30)
 & action !== 'upload'
Fokebox (talkcontribs)

Hello! I have updated my wiki to 1.35 and enables VisualEditor. So if I upload the image via VisualEditor, it shows me a message that cannot create empty page. Shall I add to the code exception for uploading a file via VisualEditor

Fokebox (talkcontribs)

Thx! Works perfect!

Reply to "Preventing to create empty pages"

RestBase installation on Lambda

2
Krug Walton (talkcontribs)

I understand installing a RESTBase server will help with dirty differences (I keep getting these 'return' symbols when switching from wikieditor to visualeditor and I understand a RESTBase server will help with that).


Is it possible to set up as a Lambda service in Amazon AWS instead of having a fully devoted server? i.e. does anyone have any pointers as to whether that should be possible (I assume API Gateway + Lambda function)?


Thank you!

Krug Walton (talkcontribs)

API Gateway + Lambda function + Amazon Keyspaces (for Apache Cassandra) that is

Reply to "RestBase installation on Lambda"