Jump to content

User:Rogerhc/upgrade 1.35.1 LTS to 1.39.1 LTS (2023)

From mediawiki.org

Upgrade "production".com MW 1.35.1 to MW 1.39.1.

Manual:Upgrading << READ

https://shorturls.redwerks.org << DO

slowly ☐ 🐛 ☑


Backup

[edit]

Use cpanel to backup the ☑ Home Dir and ☑ Database on home computer.

☑ ^

Wget MW1.39.1

[edit]

See Manual:Upgrading#Command_line

$ cd /path/to/your/new/installation/  
$ wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.1.tar.gz
$ tar -xvzf mediawiki-1.39.1.tar.gz
$ rm mediawiki-1.39.1.tar.gz

☑ ^

robots.txt

[edit]
$ cp -anv ~/www/wiki/robots.txt* ~/www/wikiNew/

☑ ^

The * is to fetch my various versions of this file also.

favicon.ico

[edit]
$ cp -anv ~/www/wiki/favicon* ~/www/wikiNew/

☑ ^

The * is to fetch my various versions of this file also.

FAQ

[edit]

Text file "FAQ" needs to be removed or it will supersede wiki page "FAQ". We don't need that wiki page but we have it. Because.

rm ~/wikiNew/FAQ

☑ ^

Short URL

[edit]

Root level short URL as in exp.com/Page_Name

.htaccess docs

Redwerks.org

[edit]

https://shorturls.redwerks.org/

☑ Generated this from my production https://exp.com MW 1.35.1 3 Feb 2023:

[X] Include 404 thumbnail handler config

/LocalSettings.php

This configuration is meant to go into your LocalSettings.php. There should be a small block already in there that is similar to this, replace that with these settings to setup the MediaWiki side of the Short URL config.

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";
$wgArticlePath = "/$1";
$wgUsePathInfo = true;

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgGenerateThumbnailOnParse = false;

/.htaccess

These rules go inside the .htaccess file at "/.htaccess". If a .htaccess file already exists there you should merge these rules in with it. However if you have any existing rewrite rules for your article path or thumbnail handler you should probably erase those to avoid conflicting with these.

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

/LocalSettings.php

[edit]

Copy from production wiki. And see MW1.35.1 upgrade note, below.

# $wgGenerateThumbnailOnParse = false; #  Redwerks asked for this. But I'm not sure I can use it. Maybe try uncommenting this later and see. And read on MediaWiki.org.
$ cp -anv ~/www/wiki/LocalSettings.php ~/www/wikiNew/

☑ ^

.htaccess

[edit]

Using the one from production wiki instead because it has worked on MW 1.35.1:

$ cp -anv ~/www/wiki/.htaccess ~/www/wikiNew/

☑ ^

See notes below. Maybe try whittling it down later for MW 1.39.1.

MW 1.35.1 upgrade notes

[edit]

First attempt using .htaccess and LocalSettings.php from production.com failed.

Fixed with .htaccess generated at https://shorturls.redwerks.org/

But that failed Visual Editor test, got error:

Error contacting the Parsoid/RESTBase server (HTTP 404)

Fixed by adding this to .htaccess:

RewriteCond %{HTTP_USER_AGENT} !^(VisualEditor)

See https://www.mediawiki.org/w/index.php?title=Topic:Vv35plp6g16qno0s&topic_showPostId=vv4jia2ip0swopod#flow-post-vv4jia2ip0swopod

Here's what the https://shorturls.redwerks.org config I'm using + that^ looks like, and it's working! :)

RewriteEngine On
RewriteCond %{REQUEST_URI} !^(static)
RewriteCond %{HTTP_USER_AGENT} !^(VisualEditor)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]

RewriteCond %{REQUEST_URI} !^(static)
RewriteCond %{HTTP_USER_AGENT} !^(VisualEditor)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{REQUEST_URI} !^(static)
RewriteCond %{HTTP_USER_AGENT} !^(VisualEditor)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

I also added per LapisLazuli33 "flying carpet" but can't see what it does (allow static plain text pages like CREDITS and SECURITY to skip the URL rewrite? Aren't those already skipped by !-f?):

RewriteCond %{REQUEST_URI} !^(static)

My note on MW User:Dantman's talk page: https://www.mediawiki.org/wiki/Topic:W2ahzg3yi27mvp9y

Related links

SSL

[edit]

I purchase SSL certification through our Webhost. That works for production. But I tried free SSL certification for my test wiki to save money and that failed.

MW 1.35.1 upgrade notes

[edit]

Dang, above works for http:// but not for https://. When I switch to https:// I get this error when I click the VisualEditor "edit" link on a page:

Error contacting the Parsoid/RESTBase server: (curl error: 60) SSL peer certificate or SSH remote key was not OK

I am using a self-signed SSL certificate on dev.com. Don't know if that is an issue.

YES! Visual Editor works on my production wiki, which has a properly authorized SSL certificate. Visual Editor throws above error on my test wiki which only has self authorized SSL certificate. So I guess Visual Editor is not currently compatible with self authorized SSL certificate.

Related links

Extensions

[edit]
IMPORTANT

The extension CategoryTree[1] provides functionality we use on the site Contents page which is linked under Main Page in the sidebar. It is bundled in MW and called in LocalSettings.php.

☑ ^

Stop editing

[edit]

Set no-edit at bottom of LocalSettings.php.

☑ ^

PHP version

[edit]
Compatibility -- PHP and Database requirements charts

MW 1.35.1 ("mostly -- may have report minor issues") and MW 1.39.1 are both compatible with PHP 8. So set server to PHP 8.1 now. (Or try PHP 7.4.3 which both are okay with.)

cPanel >> Software >> Select PHP Version (change from PHP 7.3 to 8.1).

☑ ^

Clear jobs que

[edit]

see Manual:runJobs.php

$ php maintenance/runJobs.php

☑ ^

Backup Database again

[edit]

Use cpanel to backup the Database on home computer.

☑ ^

dump

[edit]

dump the database to exp.MW1.35.1-2023.sql

See

$ mysqldump --user=wikidb_user --password=wikidb_userpassword wikidb > file.sql

or, I use something like:

$ cd ~/bu
$ mysqldump -p roger_wikidb > roger_wikidb.`date +%Y-%m-%d`.sql

☑ ^

/images

[edit]

/images is still just 1020MB (1GB) but yes, getting big. One copy of it on the server at a time please, or maybe only two.

$ du -h ~/www/wiki/images

☑ ^

mv ~/www/wikiNew/images/ ~/www/wikiNew/images.MW1.39.1
cp -anv ~/www/wiki/images/ ~/www/wikiNew/images

☑ ^

or if space limited, maybe:

mv ~/www/wikiNew/images ~/www/wikiNew/images.MW1.39.1
mv ~/www/wiki/images ~/www/wikiNew/images

Check /images permissions

$ ls -la ~/www/wikiNew/images
total 100
drwxrwxr-x .
drwxr-x--- ..
drwxr-xr-x f
-rw-rw-r-- .htaccess
drwxr-xr-x lockdir
-rw-rw-r-- README
drwxr-xr-x temp
drwxr-xr-x thumb

☐ ^

Switch live MW1.35.1 with live MW1.39.1

[edit]
$ mv ~/www/wiki/ ~/www/wikiOld/; mv ~/www/wikiNew/ ~/www/wiki/

☑ ^

Update database

[edit]
$ maintenance/update.php

☑ ^

Output:

bilbo@cpanel84:~$ mv ~/www/teflpedia/ ~/www/teflpediaOld; mv ~/www/mrtp/ ~/www/teflpedia/
 
bilbo@cpanel84:~$ ~/www/teflpedia/maintenance/update.php 
Fatal error: Uncaught Exception: Unable to open file /home/bilbo/public_html/teflpedia/extensions/LocalisationUpdate/extension.json: filemtime(): stat failed for /home/bilbo/public_html/teflpedia/extensions/LocalisationUpdate/extension.json in /home/bilbo/public_html/teflpedia/includes/registration/ExtensionRegistry.php:199
Stack trace:
#0 /home/bilbo/public_html/teflpedia/includes/GlobalFunctions.php(53): ExtensionRegistry->queue()
#1 /home/bilbo/public_html/teflpedia/LocalSettings.php(205): wfLoadExtension()
#2 /home/bilbo/public_html/teflpedia/includes/Setup.php(218): require_once('/home/bilbo/pub...')
#3 /home/bilbo/public_html/teflpedia/maintenance/doMaintenance.php(83): require_once('/home/bilbo/pub...')
#4 /home/bilbo/public_html/teflpedia/maintenance/update.php(312): require_once('/home/bilbo/pub...')
#5 {main}
  thrown in /home/bilbo/public_html/teflpedia/includes/registration/ExtensionRegistry.php on line 199
bilbo@cpanel84:~$ 

Oh, MW1.39.1 does not have extension/LocalizationUpdater. So commented it's call out in LocalSettings.php and now maintenance/update.php runs. Looks good. Wiki is still serving same error message. Will check again in 20 minutes. eZoic mirror of site may have cached it.

☑ ^

Database may have been left in a corrupted state by failed update.php attempt. So reverting to database backup.

cd ~/bu
mysql -p roger_orange < file.sql
cd ~/www/wiki/maintenance
php update.php

☑ ^

Update.php runs, looks good "Done in 45 s." but wiki still serves same error message re extension/LocalizationUdate. Maybe eZoic mirror has cached it, but only on Main_Page. Will wait 30 minutes and check again. Other wiki pages are serving correctly. This serving of cached error messages by eZoic's mirrors of my site is annoying but has happened before and may as well be expected by me now.

Start editing

[edit]

Comment out no-edit lock at bottom of LocalSettings.php. No need for this step because the new wiki never had this set. Will be necessary if we revert to old wiki though.

☑ ^

PHP version

[edit]
Compatibility -- PHP and Database requirements charts.

Set to PHP 7.4.33 right now. Try PHP 8.0 or 8.1 later.

Test

[edit]

Once the upgrade has been completed, browse to the wiki and check that the following operations work as expected:

  • ☐ Viewing pages
  • ☐ Editing pages
  • ☐ Uploading a file
  • ☐ Visit Special:Version and check that the version shown is correct and that the extensions are present.

User:Oh dear some should test this

☐ ^

If it fails,
did you put .htaccess in? (I forget this too often! My short URSs require it! Otherwise I get 404.)
If it still fails,
revert to backup of old version (and reset PHP version in cpanel if needed).