Project:Support desk

About this board

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

(Read this message in a different language)

See also

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".

JS title-replacement code doesn't work as it should

Slgrandson (talkcontribs)

On my creative-venture wiki, I have just reworked a JS segment from my days on Referata that replaces a namespace word with a page type-turned-pseudo-namespace. In my case, the target is the Morpheme NS, which should identify pages in its list as roots ("Root") or affixes ("Affix"). What I came up with, without breaking the rest of my Common.js:

$(function() {
  var s = document.querySelector('.ns-3036 #firstHeadingTitle').innerHTML;
  s = s.replace("Morpheme", function() {
  if(s.match(/(^-|-$)/)) {
    } else {
  document.querySelector('.ns-3036 #firstHeadingTitle').innerHTML = s;

Tried it out a while ago, but no change occurs; I was 80% sure I'd do it right. (Trust me, JS is not really one of my strengths, and I tend to learn by example.)

To @Bawolff How do I go about repairing the embedded function() here?

(MW 1.38.2; filed via Monobook)

--Slgrandson (talk) 15:07, 15 August 2022 (UTC)

Bawolff (talkcontribs)

Pretty sure it should be #firstHeading not #firstHeadingTitle.

Also i would generally reccomend using innerText over innerHTML when possible. This particular example looks safe, but its very easy to accidentally create a XSS issue when using innerHTML.

Bawolff (talkcontribs)

Oh, i guess also the inner s.match wont get prefixes because its testing whether the whole title including namespace starts ir ends with -, not just the part after the colon.

Slgrandson (talkcontribs)

Retooled the middle portion minutes ago as:

$(function() {
  var s = document.querySelector('.ns-3036 #firstHeadingTitle').innerText;
  s = s.replace("Morpheme", function(pseudo) {
  if(s.match(/(:-|-$)/)) {
    } else {
  document.querySelector('.ns-3036 #firstHeadingTitle').innerText = s;

...only now "undefined:Title" appears instead of "Root:Title". --Slgrandson (talk) 22:39, 15 August 2022 (UTC)

Bawolff (talkcontribs)

Oh, you are also missing return. E.g. return "Affix"; and return "Root";

Slgrandson (talkcontribs)

On the other hand, I came up with this solution myself (which actually works):

if (s.match(/(:-|-$)/)) {
  s = s.replace("Morpheme","Affix")
    } else {
  s = s.replace("Morpheme","Root")

--Slgrandson (talk) 23:16, 15 August 2022 (UTC)

Reply to "JS title-replacement code doesn't work as it should"
Aeonjupiter (talkcontribs)

i installed 1.35 and uploaded localsettings.php but it gives me an error when visiting it

Bawolff (talkcontribs)

Can you tell us what the error is? (Preferably set $wgShowExceptionDetails=true; at bottom of LocalSettings.php to include detailed error messages)

Reply to "error"
2A02:6D40:2C07:2001:726D:148D:2347:36B1 (talkcontribs)

I took over maintenance of an internal wiki at my employer. I tried to update from 1.27 to 1.25 in one step, but get errors like this:

ailed to populate content table archive row batch starting at 91 due to exception: Wikimedia\Rdbms\DBQueryError: Error 1062: Duplicate entry '91-1' for key 'PRIMARY' (localhost)

Function: PopulateContentTables::populateContentTablesForRowBatch

Query: INSERT INTO `slots` (slot_revision_id,slot_role_id,slot_content_id,slot_origin) VALUES ('91',1,'205503','91'),('91',1,'205503','91'),('92',1,'205504','92'),('92',1,'205504','92'),('93',1,'205505','93'),('219',1,'205506','219'),('220',1,'205507','220'),('230',1,'205508','230'),('231',1,'205509','231'),('232',1,'205510','232'),('232',1,'205510','232'),('233',1,'205511','233'),('240',1,'205512','240'),('240',1,'205512','240'),('257',1,'205513','257'),('257',1,'205513','257'),('264',1,'205514','264'),('277',1,'205515','277'),('277',1,'205515','277'),('282',1,'205516','282'),('283',1,'205517','283')

in /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/Database.php:1700

Stack trace:

#0 /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/Database.php(1684): Wikimedia\Rdbms\Database->getQueryException()

#1 /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/Database.php(1659): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()

#2 /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/Database.php(1228): Wikimedia\Rdbms\Database->reportQueryError()

#3 /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/Database.php(2344): Wikimedia\Rdbms\Database->query()

#4 /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/Database.php(2324): Wikimedia\Rdbms\Database->doInsert()

#5 /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->insert()

#6 /www/common/mediawiki-1.35.7/includes/libs/rdbms/database/DBConnRef.php(369): Wikimedia\Rdbms\DBConnRef->__call()

#7 /www/common/mediawiki-1.35.7/maintenance/populateContentTables.php(328): Wikimedia\Rdbms\DBConnRef->insert()

#8 /www/common/mediawiki-1.35.7/maintenance/populateContentTables.php(232): PopulateContentTables->populateContentTablesForRowBatch()

#9 /www/common/mediawiki-1.35.7/maintenance/populateContentTables.php(99): PopulateContentTables->populateTable()

#10 /www/common/mediawiki-1.35.7/includes/installer/DatabaseUpdater.php(1460): PopulateContentTables->execute()

#11 /www/common/mediawiki-1.35.7/includes/installer/DatabaseUpdater.php(554): DatabaseUpdater->populateContentTables()

#12 /www/common/mediawiki-1.35.7/includes/installer/DatabaseUpdater.php(517): DatabaseUpdater->runUpdates()

#13 /www/common/mediawiki-1.35.7/maintenance/update.php(181): DatabaseUpdater->doUpdates()

#14 /www/common/mediawiki-1.35.7/maintenance/doMaintenance.php(107): UpdateMediaWiki->execute()

#15 /www/common/mediawiki-1.35.7/maintenance/update.php(253): require_once('/www/common/med...')

#16 {main}

  1. Am I correct in assuming the step 1.27 -> 1.35 is too big? Can you advise me whicversion h steps I should take?
  2. Before trying again, I restore my DB backup, righjt?

Thanks for your advise

Bawolff (talkcontribs)

Normally that would not be too big a step (you would get explicit error if its too big)

Reply to "Update from 1.27 to 1.35"

Wiki login causes BadMethodCallException

Bernie kra (talkcontribs)

I have a new installation of Mediawiki 1.38 with MariaDB 10.8 and php 7.4.30. If i run the install and set it to a private wiki, when you attempt to log in (after entering name and password), you get an error [ca59474baf38d711fbded9e1] 2022-08-15 12:34:53: Fatal exception of type "BadMethodCallException". I'm sorry but i have no idea how to troubleshoot this.

If i set the wiki so it doesn't require login, it works as expected, with no issues.

Any help would be greatly appreciated.

Bawolff (talkcontribs)

Can you add $wgShowExceptionDetails=true; to LocalSettings.php to give a more detailed error message?

Bernie kra (talkcontribs)

@Bawolff, Thank you so much. Adding the details pointed me right to the cause. It's working now. I'm extremely grateful.

Reply to "Wiki login causes BadMethodCallException"
PrometheusAla (talkcontribs)

I have an error with permanent redirect - 301 redirect from main page. Where to see to find problem? 1.38 version

Bawolff (talkcontribs)

What is the error message?

PrometheusAla (talkcontribs)

Nothing ( also in php logs. Or I should turn on display errors somewhere?

Bawolff (talkcontribs)

If there is no error, what is the problem you are encountering.

PrometheusAla (talkcontribs)

permanent redirect - 301 redirect

PrometheusAla (talkcontribs)

301 Moved Permanently and cycled page reload

Bawolff (talkcontribs)

Probably an issue with rewrite rules.

PrometheusAla (talkcontribs)

How to check it? Or how to solve?

Malyacko (talkcontribs)

Web server logs and web server documentation.

Reply to "Permanent redirect"

How to add a "Contact us" button to Minerva_Neue mobile menu?

3 (talkcontribs)

How to add a "Contact us" button to Minerva_Neue mobile menu?

By default, this menu only has the following links:

  • Homepage
  • RandomPage
  • Login
  • About WEBSITE
  • Disclaimers (talkcontribs)


Malyacko (talkcontribs)
Reply to "How to add a "Contact us" button to Minerva_Neue mobile menu?"

What size should a skin:Vector logo get?

4 (talkcontribs)

Say I have a raster image (png/jpg) or a vector image (svg/eps) which I use as a logo on a website with Skin:Vector, what size should I give it and where should I give it? When resizing the image file itself or in mediawiki:Common.css?

Bawolff (talkcontribs) (talkcontribs)

@Bawolff this manual page is very unclear to me.

Is there something I should follow there in particular?

Jonathan3 (talkcontribs)

"where should I give it?"

I think ideally you would resize the image(s) before uploading.

Though I think some skins resize images to fit.

Reply to "What size should a skin:Vector logo get?"

Organizing categories with RegEx / JWB

2601:282:117F:5960:ACE2:2E0A:3489:8A4A (talkcontribs)

Hello, I'm currently working on a mid-sized wiki on Fandom and their categories are not in a consistent order. With regex I am planning to organize in a custom manner working with sub/super categories on the wiki. I am thinking with using patterns and groups but I can't seem to work it out.

If you could help out in making a sample to organize categories it would be much appreciated.

Reply to "Organizing categories with RegEx / JWB"

I have clean installation of 1.38 Wikimedia and 1.24 DB dump and files

PrometheusAla (talkcontribs)

How to correctly import old data to new installation? Old installation was rewritten by mistake.

PrometheusAla (talkcontribs)

Also old LocalSettings.php file. What updates should implement to update it.

Bawolff (talkcontribs)

You don't. You have to take the sql dump, import it into a db, and then run update.php.

PrometheusAla (talkcontribs)

I did it... but it still doesn't work (

Malyacko (talkcontribs)

Please provide clear steps, and explain what "doesn't work", without any paraphrasing.

Reply to "I have clean installation of 1.38 Wikimedia and 1.24 DB dump and files"

How to make skin:Vector responsive?

14 (talkcontribs)

MediaWiki 1.38.2 website without any non-core extensions or skins installed.

Skin:Vector not responsive by default but I understand from its webpage that there is an experimental way to make responsive.

1) Should I just add wgVectorResponsive = true; to LocalSettings.php?

2) Is this experimental option SEO friendly from your experience? Would you recommend not using it and preferring another approach to get screen-responsivness? (talkcontribs)

Adding $wgVectorResponsive = true; to LocalSettings.php didn't make the website responsive.

Jonathan3 (talkcontribs)

Maybe you need to upgrade Vector? Just a guess. (talkcontribs)


What do you mean? My MediaWiki is already 1.38.2 which is latest.

Jonathan3 (talkcontribs)

I don't use Vector and have to upgrade my skin when I upgrade mediawiki. It sounds from what you said that this isn't relevant to you. (talkcontribs)

@Jonathan3 What do you mean by upgrade your skin?

As far as I know, skins are upgraded (or not, it depends if there is anything in the skin to upgrade) whenever you upgrade MediaWiki.

Jonathan3 (talkcontribs) (talkcontribs)

@Jonathan3 Of course, I meant only to core skins.

Anyway I misunderstand the point you were trying to make even after visiting that link. (talkcontribs)

@Bawolff in great plea, your kind help. (talkcontribs)

I don't want to install MobileFrontend so I desperately seek a solution without it.

Bawolff (talkcontribs)

I dont know why $wgVectorResponsive isnt working. It works on wikipedia. Maybe you need the user preference.

You could also try a different skin like Timeless or Minerva.

2A03:C5C0:107C:AF99:0:0:6392:922E (talkcontribs)

Awolff, what user preferenace? I want it for all users whatsoever.

Malyacko (talkcontribs)
Reply to "How to make skin:Vector responsive?"