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 to make Timeless page VIEW-TALK-FAVORITE-EDIT-HISTORY links appear only to a registered user?

7
109.64.104.73 (talkcontribs)

In MediaWiki 1.36.1 with Skin:Timeless I wish to make page VIEW-TALK-FAVORITE-EDIT-HISTORY links appear only to registered users (no anonymous user could read these links).

How to do that from the PHP?


If it matters, the CSS ID mw-page-header-links reflects these links and appears in /skins/Timeless/includes/TimelessTemplate.php.

Jonathan3 (talkcontribs)
Jonathan3 (talkcontribs)

The Foreground skin uses this: <?php if ($wgUser->isLoggedIn() ......

109.64.104.73 (talkcontribs)

Hello dear Jonathan3 !

I want to restrict the feature in skin Timeless only for registered users and only via PHP.

Jonathan3 (talkcontribs)

The second answer is php.

109.64.104.73 (talkcontribs)

@Jonathan3

Yes, though I didn't understand what you meant by that snippet.

109.64.104.73 (talkcontribs)

What is the meaning of:

The Foreground skin uses this: <?php if ($wgUser->isLoggedIn() ......

I don't understand how this should help me because I use Timless and not Foreground.

Reply to "How to make Timeless page VIEW-TALK-FAVORITE-EDIT-HISTORY links appear only to a registered user?"
2.55.15.231 (talkcontribs)

Greetings,

Can it be set that the bot that sends the welcome message will send it only 10 minutes after registration?

Thank you!

Malyacko (talkcontribs)

Who and where is that "the bot"? Please see "Post a new question" in the sidebar.

Neriah (talkcontribs)

@Malyacko There is a bot extension that sends a welcome message to each user created. The question is about him.

Jonathan3 (talkcontribs)
2.53.171.60 (talkcontribs)
Reply to "welcome bot"
Slgrandson (talkcontribs)

On my creative-venture wiki (and its Referata forebears), I've long had trouble with the <noinclude></noinclude> wraparound on a preloaded template of mine. What I call "Template starter" sets up the bare bones for creating a template, adding a doc-page section that is always hidden from view outside a template's page à la Wikimedia.

With my latest attempt today, I followed the instructions provided at Manual:Creating pages with preloaded text#Loading the preload file (<no<includeonly></includeonly>include></noinclude>), but instead of the expected:

<!-- Please replace this with template content --><noinclude>{{doc tag|categories=<includeonly>Templates</includeonly>}}</noinclude>

all I'm getting is just the comment after loading:

<!-- Please replace this with template content -->

I've tried getting this to work time and again, to the point where spaces before the tag name (< noinclude></ noinclude>) must do as a compromise in our current setup. Of course, that's not really what I even wanted to deal with; I simply want to get the proper s on the page without any hassle. How else to go about it?

(MW 1.37.2; code loaded via Extension:Preloader)

--Slgrandson (talk) 14:17, 17 April 2022 (UTC)

Reply to "Transcluding <noinclude>"

"Stable release" template no longer working

2
Hannob (talkcontribs)

I have an internal script that needs to figure out the latest version of mediawiki. I used to access this wiki template which always gave the latest stable version:

Template:MW stable release number

However it currently returns 1.37.1, and 1.37.2 is the latest stable version. Can this be fixed or is this no longer supported?

Malyacko (talkcontribs)

The page needed a purge

Reply to ""Stable release" template no longer working"

How to make a certain skin feature to be available only for logged-in users?

13
79.180.118.152 (talkcontribs)

I tried to wrap the feature this way:

RequestContext::getMain()->getUser()->isLoggedIn(
    CODE_SNIPPED_OF_THE_FEATURE
);

I got:

syntax error, unexpected 'RequestContext' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)

How to make a certain skin feature to be available only for logged-in users?

Dylsss (talkcontribs)

The syntax is wrong because you're putting the code snippet where the function parameters to isLoggedIn() would be. What you want is

if ( RequestContext::getMain()->getUser()->isLoggedIn() ) {
    CODE_SNIPPED_OF_THE_FEATURE;
}

Though you should probably use isRegistered() as isLoggedIn() was deprecated in 1.36 and was removed in 1.38.

79.180.118.152 (talkcontribs)

Thank you, if I wrap the feature with this code I get:

ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST)
79.180.118.152 (talkcontribs)
79.180.118.152 (talkcontribs)

The file I edit is:

skins/Timeless/includes/TimelessTemplate.php

Above line 123 with the feature starting with:

protected function getContentBlock() {
Dylsss (talkcontribs)

Well the PHP parser says that it is expecting a function or const, not an if statement. You're probably putting the code directly inside the class, which is not correct. Classes can only contain properties and functions, you can't put code directly in the class. The code needs to be in one of the class's methods.

109.64.104.73 (talkcontribs)

Hello @Dylsss I search and search and don't find what to wrap in the following code.

I know only Bash and JavaScript syntax, but barely any PHP syntax.

Please help me by guiding me what to wrap with the wrapper we discussed above.

	protected function getContentBlock() {
		$html = Html::rawElement(
			'div',
			[ 'id' => 'content', 'class' => 'mw-body',  'role' => 'main' ],
			$this->getSiteNotices() .
			$this->getIndicators() .
			Html::rawElement(
				'h1',
				[
					'id' => 'firstHeading',
					'class' => 'firstHeading',
					'lang' => $this->get( 'pageLanguage' )
				],
				$this->get( 'title' )
			) .
			Html::rawElement( 'div', [ 'id' => 'bodyContentOuter' ],
				Html::rawElement( 'div', [ 'id' => 'siteSub' ], $this->getMsg( 'tagline' )->parse() ) .
				Html::rawElement( 'div', [ 'id' => 'mw-page-header-links' ],
					// @phan-suppress-next-line SecurityCheck-DoubleEscaped
					$this->getPortlet(
						'namespaces',
						$this->pileOfTools['namespaces'],
						'timeless-namespaces',
						[ 'extra-classes' => 'tools-inline' ]
					) .
					// @phan-suppress-next-line SecurityCheck-DoubleEscaped
					$this->getPortlet(
						'more',
						$this->pileOfTools['more'],
						'timeless-more',
						[ 'extra-classes' => 'tools-inline' ]
					) .
					$this->getVariants() .
					// @phan-suppress-next-line SecurityCheck-DoubleEscaped
					$this->getPortlet(
						'views',
						$this->pileOfTools['page-primary'],
						'timeless-pagetools',
						[ 'extra-classes' => 'tools-inline' ]
					)
				) .
				$this->getClear() .
				Html::rawElement( 'div', [ 'id' => 'bodyContent' ],
					$this->getContentSub() .
					$this->get( 'bodytext' ) .
					$this->getClear()
				)
			)
		);

		return Html::rawElement( 'div', [ 'id' => 'mw-content' ], $html );
	}
Dylsss (talkcontribs)
Dylsss (talkcontribs)
$content = $this->getSkin()->getUser()->isRegistered() ? $this->getContentBlock() : '';
$html .= Html::rawElement( 'div', [ 'id' => 'mw-content-container', 'class' => 'ts-container' ],
	Html::rawElement( 'div', [ 'id' => 'mw-content-block', 'class' => 'ts-inner' ],
		Html::rawElement( 'div', [ 'id' => 'mw-content-wrapper' ],
			$content .
			$this->getAfterContent()
		) .
		Html::rawElement( 'div', [ 'id' => 'mw-site-navigation' ],
			$this->getLogo( 'p-logo', 'image' ) .
			$this->getMainNavigation() .
			$this->getSidebarChunk(
				'site-tools',
				'timeless-sitetools',
				// @phan-suppress-next-line SecurityCheck-DoubleEscaped
				$this->getPortlet(
					'tb',
					$this->pileOfTools['general'],
					'timeless-sitetools'
				)
			)
		) .
		Html::rawElement( 'div', [ 'id' => 'mw-related-navigation' ],
			$this->getPageToolSidebar() .
			$this->getInterwikiLinks() .
			$this->getCategories()
		) .
		$this->getClear()
	)
);

The above should work if that's what you want. If you want to conditionally hide something else, you can do something similar.

109.64.104.73 (talkcontribs)

Sadly the code snippets you have provided didn't work for me.

  • The first code snippet from GitHub brought 500 HTTP status
  • The second code snippet brought:
ParseError: syntax error, unexpected '$content' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST)

Both problems happened when I tried to replace the original code (which I have pasted above) with yours.

Perhaps, instead replacing such large code snippets I can paste some conditional in the end of the PHP file.

Dylsss (talkcontribs)

I didn't mean for you to paste that code snippet anywhere, I meant for you to replace it with the existing code in execute() where this->getContentBlock() is called. I.e. replace the code from line 78 (https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/skins/Timeless/+/refs/heads/master/includes/TimelessTemplate.php#78) to 107 (https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/skins/Timeless/+/refs/heads/master/includes/TimelessTemplate.php#107) with the code snippet. Note the line numbers may be different if you are not using master.

109.64.104.73 (talkcontribs)

@Dylsss sadly replacing 78 up to (and including 107) didn't work for me.

I use MediaWiki 1.36.1, which version of MediaWiki do you use?

109.64.104.73 (talkcontribs)

Also, perhaps there is a way with much less code to do so such as adding a conditional in the end of the PHP file as discussed here?

Topic:Wtsi7ijp7ceiwutg

Reply to "How to make a certain skin feature to be available only for logged-in users?"

Relocate Related Articles extension

3
Summary by I9i2ex

Fully answered in the reply to my question.

I9i2ex (talkcontribs)

I have setup a private wiki in a docker container with persistent volumes to keep and organise what my brain will no longer retain. I have enabled RelatedArticles extension. I have setup some templates and the site generally works. I get a bulleted list of articles on top like so:

Related articles

I am hoping this will be straightforward, but what I was hoping to accomplish is a related articles box in the upper right-hand corner, similar to what can be seen here:

https://wiki.archlinux.org/title/File_systems

I have some experience with the ArchLinux Wiki (as a user editing page contents and formatting) but I have no web coding knowledge whatsoever.

Can someone perhaps help me out moving that bulleted list to the right hand corner as seen on the Arch Wiki?

Thanks!

Jonathan3 (talkcontribs)

Looks like it uses three templates: Template:Related articles start for the header, Template:Related for each item, and Template:Related articles end at the end.

Template:Related articles start just calls Template:META Related articles start which just uses: <div class="archwiki-template-meta-related-articles-start"><p>{{{1}}}</p><ul>

Template:Related just uses: <li>[[{{{1}}}]]</li>

And Template:Related articles end just uses: </ul></div>

The CSS for the div.archwiki-template-message class is in MediaWiki:Common.css

I9i2ex (talkcontribs)

Thanks! That works beatifully. Really appreciate it, now I just need to change the colors but that is easy now.

I have now two accounts in MCA Hogarth's Peltverse.

2
63.155.116.42 (talkcontribs)

I have now two accounts in MCA Hogarth's Peltverse. I am not sure I can access either.

I need to change my password, I have seemingly lost both passwords.

I am ready to try a third accont,

I use two machines, The windows 10 machine has one account running, and I fear if I shut it down it will not let me back one. The Linux Mint latest version is locked out from both.

I am nor locked out of studiomcah.locals.com. But that is a different link.

I guess that I did not give a email addr?

What can I do?

Bawolff (talkcontribs)

You should contact "MCA Hogarth's Peltverse", whatever that is.

Reply to "I have now two accounts in MCA Hogarth's Peltverse."

Revoked the bureaucrat right from the only bureaucrat

4
I.hate.spam.mail.here (talkcontribs)

I was running a wiki locally, and I was the only user. However, I accidentally revoked the bureaucrat right from myself, and now no one is a bureaucrat. How can this be fixed? ~~~~

I.hate.spam.mail.here (talkcontribs)

The wiki is running locally, so I can't provide a link to it. ~~~~

Dylsss (talkcontribs)
I.hate.spam.mail.here (talkcontribs)

Got it, thanks! ~~~~

How to streamline a big upgrade leap

1
Preslethe (talkcontribs)

Hi, everyone.

My private wiki (just stored and accessed on my local PC) has worked fine for me in Windows XP Pro for more than 12 years. I finally have a Windows 10 computer and want to migrate my wiki to it from my XP machine.

The "Special:Version" page in my XP wiki says I'm using MediaWiki 1.18.5, with PHP 5.3.0 (apache2handler), with MySQL 5.1.36-community-log. Under "Installed extensions", "Special pages", it lists "CategoryTree" and "Replace Text (Version 0.9.3)". Under "Installed extensions", "Parser hooks", it lists "CategoryTree", "CharInsert", "Cite", and "ParserFunctions (Version 1.4.1)".

So far, on my Windows 10 computer, I have not installed anything that would be necessary to migrate my wiki.

Being far from expert, I would like to know the best way to go straight from the existing wiki installation on my Windows XP computer to whatever newer versions would let me take best advantage of having Windows 10 to run my wiki. I'm afraid that if I don't get advice then I'll take unnecessary intermediate steps and gum things up.

Thanks for the help! Preslethe (talk) 21:53, 16 April 2022 (UTC)

Reply to "How to streamline a big upgrade leap"

Thumb folder is massive - necessary to back it up?

4
Jonathan3 (talkcontribs)

My images directory is 8.3GB. The thumb directory is 7.3GB of that. I have a lot of PDF files, and the thumb folder seems mostly to be jpg images of all PDF pages, probably from Extension:PdfHandler.

If exclude the thumb directory from my backup, and need in future to restore from that backup, would the thumbnails be recreated automatically when needed? Alternatively, would there be a way of recreating them all at once?

Bawolff (talkcontribs)

It depends if you have 404 thumb handling enabled.

If yes, then they will be regenerated as needed.


If no, they wont be, but you might be able to force regeneration via a maintenance script like refreshLinks.php.

Jonathan3 (talkcontribs)

Thanks. Could you please share a link explaining 404 thumb handling?

Bawolff (talkcontribs)
Reply to "Thumb folder is massive - necessary to back it up?"