Topic on Project:Support desk

Changing namespace numbers while preserving namespace's contents

7
Slgrandson (talkcontribs)

Hello. It's not often that I pop in here, but here goes.

Today, on a new ByetHost wiki I opened last week (I was formerly a Referata admin), I was in the process of adding extra namespaces to what I started out with. As I report, the kinks have been smoothed out--except for one issue.

My first custom namespace was "Documentation", inspired by the likes of Wikimedia's feature. In LocalSettings.php, I assigned "050" as its number, believing it was the same as 50--only to realise days later that it renders in the API et al. as "40". (Sort of how virtual broadcast channels work in the States.) Tried "070" with one of the new NSs today; turned into 56.

I tried to remedy the quirk by dropping the first "0" and make it the desired "50"--but this led to the panic-inducing side effect of rendering several dozen doc pages temporarily inaccessible. On a "What links here" list, anything with "Documentation:" as the declared namespace turned into "Special:BadTitle/NS40:[TITLE]", complete with error notice.

After reverting it back to "050", I left a maintenance note below the affected definition:

define("NS_DOCUMENTATION", 050);
define("NS_DOCUMENTATION_TALK", 051);
// To move to:
// define("NS_DOCUMENTATION", 50);
// define("NS_DOCUMENTATION_TALK", 51);

If anyone else here experienced this issue before, feel free to give me a solution. Your help and experience are greatly appreciated!

(MW 1.35)

--Slgrandson (talk) 17:35, 20 October 2020 (UTC)

Bawolff (talkcontribs)

so numbers starting with 0 means octal (base 8) notation. As an example, 0123 is short for 1*82+2*81+3*80=83. So 050=5*8=40.

Anyways, its generally not recomended to change namespace numbers after you have used one. You could try using a script like Manual:cleanupTitles.php after changing the namespace number.

As a general rule, it is reccomended that custom namespaces start at 100.

Slgrandson (talkcontribs)

Thanks, but...how (and where) do I run that script?

Slgrandson (talkcontribs)

...O.K. So I've discovered Cron jobs can do just that, but I'm having a bit of jitters. Where I am, it reads:

Run the script http://sitename.bth7.com/ __________

but I don't want to risk losing my new wiki. To Bawolff: What will happen if I fill in the blank with exactly what MW's manual gives? --Slgrandson (talk) 07:35, 22 October 2020 (UTC)

Bawolff (talkcontribs)

it will either not work, in which case nothing happens or it will move them to a new title starting with 'xbroken/ from which you can rename them after.


If your very concerned it might be best to take a db backup first, even though this should be a fairly safe operation. you could also try using the --dry-run option first which wont make any changes.

Normally in cron they ask you for a file path and not a url.

Slgrandson (talkcontribs)

Backed things up just in case; entered the script path just this moment; the site's still up.

However, cron jobs can only last five seconds for free accounts like mine. Guess I'll have to move all my doc pages to the project namespace as I get things sorted out.

P.S. I'm aware of one MultiPages by name, and it looked like a sure bet yesterday. Sadly, it's a tad behind the times and won't work on the current MW. --Slgrandson (talk) 07:44, 23 October 2020 (UTC)

Bawolff (talkcontribs)

Some other options: You can manually move pages using the API with the fromid parameter, if you know the pages id. This should still work even if the page is normally inaccessible. - https://www.mediawiki.org/wiki/API:Move

Higher risk: You could use SQL (Often the types of hosts like yours give access via phpmyadmin) to change all the page_namespace fields in the database that use the old namespace number to some other number.

Reply to "Changing namespace numbers while preserving namespace's contents"