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

How do I verify what restricted special pages appear on Special:SpecialPages if I don't have access to them?

1
C.Syde65 (talkcontribs)

I'm currently doing a project that involves separating certain special pages that appear on Special:SpecialPages from certain special pages that don't appear on Special:SpecialPages. The problem is that some of the special pages are ones that I don't have access to. If I'm not mistaken, it is possible to verify what special pages appear on Special:SpecialPages by browsing the repositories of their respective extensions on GitHub. But how do I do that?

The special pages that are on my checklist include the following:

  • Special:DeleteBatch (should appear as 'Delete batch of pages' if it appears on Special:SpecialPages)
  • Special:EditAccount (should appear as 'Edit account' if it appears on Special:SpecialPages)

There are a few others that are on my checklist, but the extensions associated with them are not ones that have their own extension pages on this site. Therefore, I need to be able to learn how to read the code in the repositories to avoid having to ask those with access to those pages to check for me.

How should I structure translations for my wiki

1
MarblehorseNet (talkcontribs)

Currently, I have an English wiki containing text and images in English. I want to automate the process of rewriting the content and images into different languages using a Python script. However, I'm concerned about the complexity of creating and managing multiple subdomains. Is there a way to replicate the settings and extensions of my main domain for these subdomains while allowing them to have their own articles and images?

One possible solution I'm considering is manually generating multiple wikis and using a cron job to transfer extensions and settings, as well as import text files and images into each wiki individually. However, I'm hoping to find a simpler approach.

Additionally, I cannot use the generic Translate extension because the images contain English text, and I have schemas and SEO tags associated with each page that would be incorrect during the translation process.

Reply to "How should I structure translations for my wiki"

upgrade Mediawiki from 1.28 to 1.35

2
79.95.87.42 (talkcontribs)

Hello,

I am upgrading Mediawiki from 1.28 to 1.35

I have an issue using the search fonctionality (i cant found page ) and i have message (An error occurred while searching: We were unable to complete your search due to a temporary problem. Please retry later.)


I am using CirrusSearch V1.35 and elastica V 1.35 extensions and i have installed elasticseach V6.5.4


In the upgrading process should i also migrate/upgrade data and index from old elasticserach (2.3.3) and restore it to the new version of elasticsearch or i just install elasticseach 6.5.4 with new settings (new cluster ..) ?


Thanks very much

Ciencia Al Poder (talkcontribs)

Your data is on the old ElasticSearch cluster. You should reindex your wiki from scratch on the new ElasticSearch cluster. The README of Extension:CirrusSearch contains instructions for indexing your wiki.

Reply to "upgrade Mediawiki from 1.28 to 1.35"

Multiple pages into one page

6
Carter.smith1 (talkcontribs)

I'm creating a wiki with information on it. I want to be able to have all of the information to be displayed on one long page but I also want each topic to have their own page. The long page would ideally be each individual pages one after another. Let me know if there is a way of doing this. Thanks

Bawolff (talkcontribs)
Carter.smith1 (talkcontribs)

I don't only want to be able to click a link to get to the other page. Instead I was hoping that the contents of the other pages would be visible on the main page without the need to copy all of the separate pages onto the main page.

Carter.smith1 (talkcontribs)

Templates were not working earlier now they seem to be. Thanks!

Carter.smith1 (talkcontribs)

I do have one more question... These template pages, are the accessabale the same way that a normal page would be? If not is there a way to use templates to embed the contents of one page into another. Thanks

Bawolff (talkcontribs)

If you start the template name with a colon it will embed the normal page named that. E.g. if your page is named Foo then use {{:foo}}

Reply to "Multiple pages into one page"
2003:EE:713:7BF7:E1E4:B6C3:7A09:831 (talkcontribs)
Reply to "Template"

Uncaught TypeError: url.indexOf is not a function

3
Gaon12 (talkcontribs)

When you go to my MediaWiki site (https://www.gaonwiki.com), I get this error in the console.

Uncaught TypeError: url.indexOf is not a function

    at jQuery.fn.load (load.php?lang=ko&modules=ext.EnhanceMarkup.scripts%7Cjquery%2Coojs-ui-core%2Coojs-ui-widgets%7Cjquery.ui%7Coojs-ui.styles.icons-editing-advanced&skin=liberty&version=8mj0p:846:335)

    at <anonymous>:10:577

    at domEval (load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:10:692)

    at runScript (load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:12:439)

    at execute (load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:13:489)

    at doPropagation (load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:6:492)

jQuery.fn.load @ load.php?lang=ko&modules=ext.EnhanceMarkup.scripts%7Cjquery%2Coojs-ui-core%2Coojs-ui-widgets%7Cjquery.ui%7Coojs-ui.styles.icons-editing-advanced&skin=liberty&version=8mj0p:846

(anonymous) @ VM1451:10

domEval @ load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:10

runScript @ load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:12

execute @ load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:13

doPropagation @ load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:6

requestIdleCallback (async)

setAndPropagate @ load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:7

implement @ load.php?lang=ko&modules=startup&only=scripts&raw=1&skin=liberty:18

(anonymous) @ load.php?lang=ko&modules=ext.EnhanceMarkup.scripts%7Cjquery%2Coojs-ui-core%2Coojs-ui-widgets%7Cjquery.ui%7Coojs-ui.styles.icons-editing-advanced&skin=liberty&version=8mj0p:1

I've tried overwriting it with the latest version of the MediaWiki file, I've tried running maintenance/update.php, but it still doesn't go away.

Also, the regex feature of the onParserBeforePreprocess function doesn't work in the extension I'm building, and I don't know why.

public static function onParserBeforePreprocess( &$parser, &$text, &$strip_state ) {
    $text = preg_replace(
        "/\[\*\s+([^ ]+)\s+(.*?)\]/",
        '<ref group="$1">$2</ref>',
        $text
    );

    $text = preg_replace(
        "/\[\*\s+([^ ]+)\s*\]/",
        '<ref group="$1" />',
        $text
    );

    return true;
}

How can I solve these problems? Thank you.

TheDJ (talkcontribs)

https://www.gaonwiki.com/w/%EB%AF%B8%EB%94%94%EC%96%B4%EC%9C%84%ED%82%A4:Common.js#L-503

That should be window.on( 'load', function() { // the code goes here } );. Or just $(function(){ // the code goes here }).


Regarding your hook. It's generally better to explain what you want to achieve, instead of asking why your chosen solution doesn't work. Because quite often it turns out that people are focusing on the incorrect solution to the problem.

Gaon12 (talkcontribs)

@TheDJ Thank you for your reply. I've removed the unnecessary parts from that page and no errors are occurring.

Let me elaborate on the issue with the onParserBeforePreprocess function not working.

extension.json:

{
    "name": "EnhanceMarkup",
    "description": "Provides enhanced markup functionalities",
    "version": "1.0",
    "author": [
        "Jeong Gaon"
    ],
    "url": "https://www.gaon.xyz/mw_extensions",
    "type": "other",
    "license-name": "Apache-2.0",
    "AutoloadClasses": {
        "EnhanceMarkupHooks": "includes/EnhanceMarkupHooks.php"
    },
    "ResourceModules": {
        "ext.EnhanceMarkup.styles": {
            "styles": "resources/ext.EnhanceMarkup.styles.css",
            "localBasePath": "",
            "remoteExtPath": "EnhanceMarkup"
        },
        "ext.EnhanceMarkup.scripts": {
            "scripts": ["resources/ext.EnhanceMarkup.scripts.js", "resources/lib/math.js"],
            "localBasePath": "",
            "remoteExtPath": "EnhanceMarkup"
        }
    },
    "Hooks": {
        "ParserFirstCallInit": "EnhanceMarkupHooks::onParserFirstCallInit",
        "BeforePageDisplay": "EnhanceMarkupHooks::onBeforePageDisplay"
    },
    "manifest_version": 2
}

includes/EnhanceMarkupHooks.php:

<?php
class EnhanceMarkupHooks
{
    public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
    {
        $out->addModules("ext.EnhanceMarkup.styles");
        $out->addModules("ext.EnhanceMarkup.scripts");
        return true;
    }

    public static function onParserFirstCallInit(Parser $parser)
    {
        // Register each of your custom parser functions with the parser
        $parser->setHook("random", [self::class, "randomRender"]);


        return true;
    }

    public static function onInternalParseBeforeLinks(Parser &$parser, &$text)
    {
        // - * 4+ == <hr>
        // Replace sequences of 3-9 '*', '-', or '_' with a horizontal rule
        $text = preg_replace('/^([-]{3,9})$/m', "<hr>", $text);

        // [pagecount] show all count of page
        // Replace [pagecount] with the total number of pages
        $text = preg_replace_callback(
            "/\[pagecount\]/",
            function ($matches) use ($parser) {
                $dbr = wfGetDB(DB_REPLICA);
                $count = $dbr->selectRowCount("page");
                return $count;
            },
            $text
        );

        // Replace [*A text] with <ref group="A">text</ref>
        $text = preg_replace(
            "/\[\*\s+([^ ]+)\s+(.*?)\]/",
            '<ref group="$1">$2</ref>',
            $text
        );

        // Replace [*A] with <ref group="A" />
        $text = preg_replace(
            "/\[\*\s+([^ ]+)\s*\]/",
            '<ref group="$1" />',
            $text
        );

        // Replace [* text] with <ref>text</ref>
        $text = preg_replace("/\[\*\s+(.*?)\]/", '<ref>$1</ref>', $text);

		// Replace [include text] with {{text}}
        $text = preg_replace("/\[\include\s+(.*?)\]/", '{{$1}}', $text);

        // Replace [br] with <br>
        $text = str_replace("[br]", "<br>", $text);

        // Font Size up {{{+1 (content) }}} - Range: 1~5
        $text = preg_replace_callback('/\{\{\{\+([1-5])\s*(.*?)\s*\}\}\}/s', function($matches) {
            return '<span style="font-size:'.(1 + $matches[1]).'em;">'.$matches[2].'</span>';
        }, $text);
        
        // Font Size down {{{-1 (content) }}} - Range: 1~5
        $text = preg_replace_callback('/\{\{\{-([1-5])\s*(.*?)\s*\}\}\}/s', function($matches) {
            return '<span style="font-size:'.(1 - $matches[1]/10).'em;">'.$matches[2].'</span>';
        }, $text);

        return true;
    }

    // Random
    // <random range="50">True|False</random>
    public static function randomRender(
        $input,
        array $args,
        Parser $parser,
        PPFrame $frame
    ) {
        // Disable caching
        $parser->getOutput()->updateCacheExpiry(0);

        // Parse the input
        $parts = explode("|", $input);

        // Get the range from args
        $range = isset($args["range"]) ? $args["range"] : 2; // default to 2

        // Generate a random number within the range
        $randomNumber = mt_rand(1, $range);

        // Choose the output based on the random number
        if ($randomNumber <= $range / 2) {
            // If the random number is in the first half of the range, return the first part
            return $parts[0];
        } else {
            // Otherwise, return the second part if it exists, or the first part if it doesn't
            return isset($parts[1]) ? $parts[1] : $parts[0];
        }
    }
}

Looking at the code, there doesn't seem to be anything particularly wrong with it - if it's supposed to work, typing something like [* texts] within the wiki should generate a footnote called texts, but for some reason it's outputting literally.

Reply to "Uncaught TypeError: url.indexOf is not a function"

Unable to connect to a wiki

1
DarkraiFerrante (talkcontribs)

Hello, I'm unable to connect to my account on this wiki: http://animebathscenewiki.com

My password doesn't work even though it worked on MediaWiki itself, having tested it.

Thank you in advance for your help.

Reply to "Unable to connect to a wiki"

Adding a CSS class to category page links containing a specific string

1
Gaon12 (talkcontribs)

Hello MediaWiki community,

I am trying to add a CSS class to links on category pages that contain a specific string (e.g., '@@blur'). I have created a custom MediaWiki extension and tried using several hooks such as onParserBeforeInternalParse, onCategoryPageView, and onBeforePageDisplay. However, I am still unable to successfully add the desired class to the links on the category page.

Here's the code I have tried so far:

class BlurLinksHooks {
  public static function onParserBeforeInternalParse( &$parser, &$text, &$strip_state ) {
    $text = preg_replace_callback('/\[\[(.+?)@@blur\]\]/', function($matches) {
      $linkTitle = $matches[1];
      return "[[$linkTitle|<span class='blur-link'>$linkTitle</span>]]";
    }, $text);
    return true;
  }

  public static function onCategoryPageView(array &$links, CategoryViewer $categoryViewer) {
    $members = $categoryViewer->getMembers();
    foreach ($members as $member) {
        $title = $member->getTitle();
        $link = $title->getFullURL();
        if (strpos($link, '@@blur') !== false) {
            $current_classes = explode(' ', $link['attribs']['class']);
            if (!in_array('blur-link', $current_classes)) {
                $link['attribs']['class'] .= ' blur-link';
            }
            $link = str_replace('@@blur', '', $link);
        }
    }
    return true;
}

  public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
    $out->addModules( 'ext.blurLinks' );
  }
}

It seems like the @@blur string is being removed before I can check for its existence in the category page links. Any suggestions or guidance on how to properly implement this feature would be greatly appreciated. Are there any other hooks that I should be using for this task?

Thank you in advance for your help!

Include text in drawio.svg files in Mediawiki search?

1
Bedtry (talkcontribs)

Is it possible?

Reply to "Include text in drawio.svg files in Mediawiki search?"

Error: Call to a member function getNamespaces() on null

3
Faulknmd (talkcontribs)

Hello!

I run a Wiki for an amateur songwriting competition at:

http://www.homecomposed.net/wiki/

MediaWiki     1.39.3

PHP     8.1.17 (cgi-fcgi)

MySQL     8.0.28-0ubuntu0.20.04.3

ICU     60.2

It stopped working properly a few weeks ago, so I upgraded from MediaWiki 1.26.3 to 1.35.10 without problems and everything was fine.

I then came back to it on Friday in order to upgrade further to 1.39.3.

Unfortunately, having done that (incl. running the update script in a browser), some pages now load as they should, whereas many others return "Error: Call to a member function getNamespaces() on null".

For example, the full error report for http://www.homecomposed.net/wiki/index.php?title=Home_Composed_Song_Contest_1994 is as follows:


[ZHNoFVjgJfmtun3AUscyrAAATq4] /wiki/index.php?title=Home_Composed_Song_Contest_1994 Error: Call to a member function getNamespaces() on null

Backtrace:

from /home/faulknmd/homecomposed.net/wiki/extensions/Html5mediator/Html5mediator.php(40)

#0 /home/faulknmd/homecomposed.net/wiki/includes/parser/Parser.php(4023): wfHtml5MediatorParse(string, array, Parser, PPFrame_Hash)

#1 /home/faulknmd/homecomposed.net/wiki/includes/parser/PPFrame_Hash.php(354): Parser->extensionSubstitution(array, PPFrame_Hash, boolean)

#2 /home/faulknmd/homecomposed.net/wiki/includes/parser/Parser.php(2955): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)

#3 /home/faulknmd/homecomposed.net/wiki/includes/parser/Parser.php(1610): Parser->replaceVariables(string)

#4 /home/faulknmd/homecomposed.net/wiki/includes/parser/Parser.php(724): Parser->internalParse(string)

#5 /home/faulknmd/homecomposed.net/wiki/includes/content/WikitextContentHandler.php(301): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)

#6 /home/faulknmd/homecomposed.net/wiki/includes/content/ContentHandler.php(1721): WikitextContentHandler->fillParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams, ParserOutput)

#7 /home/faulknmd/homecomposed.net/wiki/includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput(WikitextContent, MediaWiki\Content\Renderer\ContentParseParams)

#8 /home/faulknmd/homecomposed.net/wiki/includes/Revision/RenderedRevision.php(266): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput(WikitextContent, Title, integer, ParserOptions, boolean)

#9 /home/faulknmd/homecomposed.net/wiki/includes/Revision/RenderedRevision.php(237): MediaWiki\Revision\RenderedRevision->getSlotParserOutputUncached(WikitextContent, boolean)

#10 /home/faulknmd/homecomposed.net/wiki/includes/Revision/RevisionRenderer.php(221): MediaWiki\Revision\RenderedRevision->getSlotParserOutput(string, array)

#11 /home/faulknmd/homecomposed.net/wiki/includes/Revision/RevisionRenderer.php(158): MediaWiki\Revision\RevisionRenderer->combineSlotOutput(MediaWiki\Revision\RenderedRevision, array)

#12 [internal function]: MediaWiki\Revision\RevisionRenderer->MediaWiki\Revision\{closure}(MediaWiki\Revision\RenderedRevision, array)

#13 /home/faulknmd/homecomposed.net/wiki/includes/Revision/RenderedRevision.php(199): call_user_func(Closure, MediaWiki\Revision\RenderedRevision, array)

#14 /home/faulknmd/homecomposed.net/wiki/includes/poolcounter/PoolWorkArticleView.php(91): MediaWiki\Revision\RenderedRevision->getRevisionParserOutput()

#15 /home/faulknmd/homecomposed.net/wiki/includes/poolcounter/PoolWorkArticleViewCurrent.php(97): PoolWorkArticleView->renderRevision()

#16 /home/faulknmd/homecomposed.net/wiki/includes/poolcounter/PoolCounterWork.php(162): PoolWorkArticleViewCurrent->doWork()

#17 /home/faulknmd/homecomposed.net/wiki/includes/page/ParserOutputAccess.php(299): PoolCounterWork->execute()

#18 /home/faulknmd/homecomposed.net/wiki/includes/page/Article.php(714): MediaWiki\Page\ParserOutputAccess->getParserOutput(WikiPage, ParserOptions, MediaWiki\Revision\RevisionStoreRecord, integer)

#19 /home/faulknmd/homecomposed.net/wiki/includes/page/Article.php(528): Article->generateContentOutput(User, ParserOptions, integer, OutputPage, array)

#20 /home/faulknmd/homecomposed.net/wiki/includes/actions/ViewAction.php(78): Article->view()

#21 /home/faulknmd/homecomposed.net/wiki/includes/MediaWiki.php(542): ViewAction->show()

#22 /home/faulknmd/homecomposed.net/wiki/includes/MediaWiki.php(322): MediaWiki->performAction(Article, Title)

#23 /home/faulknmd/homecomposed.net/wiki/includes/MediaWiki.php(904): MediaWiki->performRequest()

#24 /home/faulknmd/homecomposed.net/wiki/includes/MediaWiki.php(562): MediaWiki->main()

#25 /home/faulknmd/homecomposed.net/wiki/index.php(50): MediaWiki->run()

#26 /home/faulknmd/homecomposed.net/wiki/index.php(46): wfIndexMain()

#27 {main}

Whereas pages like this are working fine, for example: http://www.homecomposed.net/wiki/index.php?title=Netherlands_in_the_Home_Composed_Song_Contest

Can anyone give me any ideas as to why this might have happened and how it could be fixed? Thanks!

Martin

Bawolff (talkcontribs)

Sounds like a bug in Html5mediator extension. Maybe the extension isn't compatible with 1.39, or maybe it needs to be updated to a new version.

Faulknmd (talkcontribs)

Thank you! Html5mediator is indeed no longer supported, which is a bummer, but there we go.

I've removed it and the problematic pages do at least work again now, albeit with the Html5mediator code showing, so that's certainly a big step forward.

Unfortunately the supported alternatives (e.g. MP3MediaHandler, TimedMediaHandler) don't seem to allow the embedding of externally hosted audio files, which is what I was using Html5mediator for, so I guess I can look forward to a lot of time spent uploading mp3s in my near future...

Nevertheless, the biggest part of the problem is solved, so thanks again for that!

Martin

Reply to "Error: Call to a member function getNamespaces() on null"