After the Sierra to High Sierra update my local Mediawiki pages stopped working.
Looking in /etc/apache2
I could see that the httpd.conf
file had changed:
$ ls /etc/apache2/
extra/ httpd.conf.pre-update httpd.conf~previous mime.types other/
httpd.conf httpd.conf~ magic original/ users/
I inspected both httpd.conf
and httpd.conf.pre-update
, and swapped out the updated version for my old config file:
$ cd /etc/apache2/
$ sudo cp httpd.conf httpd.conf.post-update.default
$ sudo cp httpd.conf.pre-update httpd.conf
$ sudo apachectl restart
This was not sufficient to get Mediawiki working again. The default landing page also fails with a 'refused to connect' error.
The error log was not helpful:
[Thu Dec 07 17:31:09.945786 2017] [core:notice] [pid 98] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat Dec 09 14:35:27.996072 2017] [mpm_prefork:notice] [pid 98] AH00169: caught SIGTERM, shutting down
So I swapped the updated config file back:
$ sudo cp httpd.conf.post-update.default httpd.conf
$ sudo apachectl restart
And this restored the landing page.
On the basis that the Mediawiki files should still be present on the machine, I looked at the MediaWiki installation page:
This page recommends to install MAMP but I chose to persist with this route.
The (old, v 1.21) Mediawiki files were still in place in the DocumentRoot
:
$ pwd
/Library/WebServer/Documents
$ ls
PoweredByMacOSX.gif data/ index.html.en~orig test.php
PoweredByMacOSXLarge.gif index.html.en lpmacwiki/ w/
I ran the PHP test page in the browser - this did not work:
Output:
<?php phpinfo(); ?>
PHP is not enabled in the new httpd.conf
, so I stepped through the two config files, making changes so that the new config file matched as closely as possible the old config. I found I had to make a single change - enabling PHP:å
$ diff httpd.conf httpd.conf.pre-update
176,177c169
< LoadModule php7_module libexec/apache2/libphp7.so
< #LoadModule perl_module libexec/apache2/mod_perl.so
---
> LoadModule php5_module libexec/apache2/libphp5.so
I restarted Apache:
$ sudo apachectl restart
and this restored PHP activity. This was not enough to restore MediaWiki function however:
- view-source:http://localhost/lpmacwiki/index.php/Main_Page
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>877</b><br />
<br />
<b>Warning</b>: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>881</b><br />
<br />
<b>Warning</b>: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>877</b><br />
<br />
<b>Warning</b>: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>881</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/lpmacwiki/includes/MagicWord.php</b> on line <b>902</b><br />
and [a61ac297] 2017-12-09 15:01:48: Fatal exception of type MWException
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>877</b><br />
<br />
<b>Warning</b>: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>881</b><br />
<br />
<b>Warning</b>: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>876</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>877</b><br />
<br />
<b>Warning</b>: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>881</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>902</b><br />
<br />
<b>Warning</b>: preg_match(): Compilation failed: group name must start with a non-digit at offset 8 in <b>/Library/WebServer/Documents/w/includes/MagicWord.php</b> on line <b>902</b><br />
and: [104c78d7] 2017-12-09 14:59:46: Fatal exception of type MWException
I Googled for the first HTML error, and hit upon the page https://www.mediawiki.org/wiki/Topic:T50jdu97wu6ogbe1. This suggests that upgrading the MW version should help.
I backed up the existing data (belt-and-braces - I backed up the entire tree for each wiki, and also an explicit database dump):
$ tar -zcf totorowiki.tar.gz /Library/WebServer/Documents/w/
tar: Removing leading '/' from member names
$ tar -zcf lpmacwiki.tar.gz /Library/WebServer/Documents/lpmacwiki/
tar: Removing leading '/' from member names
$ sudo php /Library/WebServer/Documents/w/maintenance/sqlite.php --backup-to totorowiki.sqlite.bak
Password:
Backing up database:
Locking... Copying database file /Library/WebServer/Documents/data/totoro_wiki.sqlite to totorowiki.sqlite.bak... Releasing lock...
$ sudo php /Library/WebServer/Documents/lpmacwiki/maintenance/sqlite.php --backup-to lpmacwiki.sqlite.bak
Backing up database:
Locking... Copying database file /Library/WebServer/Documents/data/lpmacwiki.sqlite to lpmacwiki.sqlite.bak... Releasing lock...
Then followed the guide to upgrade MediaWiki:
On the Desktop
I downloaded and extracted the latest version of MediaWiki:
$ wget https://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.2.tar.gz
$ tar -xvzf mediawiki-1.29.2.tar.gz
$ rm mediawiki-1.29.2.tar.gz
As I have two wikis, and I want to customise both, I copied the extracted folder to two new folders:
$ cp -R mediawiki-1.29.2/ ./totorowiki
$ cp -R mediawiki-1.29.2/ ./lpmacwiki
I then followed the procedure to move customised files from the old installation to the new ones. I started with totorowiki
.
I first moved the customised files from the old installation to the new installation
$ cp /Library/WebServer/Documents/w/LocalSettings.php totorowiki/
$ cp -R /Library/WebServer/Documents/w/images totorowiki/
$ cp -R /Library/WebServer/Documents/w/extensions totorowiki/
$ cp -R /Library/WebServer/Documents/w/TotoroWiki.png totorowiki/
Then moved the old directory, and replaced it with the new one
$ sudo mv ~/Desktop/totorowiki ./w
$ sudo mv ~/Desktop/totorowiki ./w
$ sudo chown -R _www w
$ sudo chgrp -R wheel w
I then modified the LocalSettings.php
file as advised. I restored the old extensions in forms compatible with MediaWiki 1.26.
Cite
This extension comes with MediaWiki and only required re-enabling in LocalSettings.php
:
PdfHandler
This extension comes with MediaWiki and should only require re-enabling in LocalSettings.php
:
ToggleDisplay
This extension is no longer available, so I removed it from LocalSettings.php
SyntaxHighlight_GeSHi
This extension comes with MediaWiki and should only require re-enabling in LocalSettings.php
:
128,130c128,134
< require_once( "$IP/extensions/Cite/Cite.php" );
< require_once( "$IP/extensions/PdfHandler/PdfHandler.php" );
< require_once( "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php" );
---
> #require_once( "$IP/extensions/Cite/Cite.php" );
> #require_once( "$IP/extensions/PdfHandler/PdfHandler.php" );
> #require_once( "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php" );
> # Changes to the extension registration system post-1.26 require the following changes
> wfLoadExtension( 'Cite' );
> wfLoadExtension( 'PdfHandler' );
> wfLoadExtension( 'SyntaxHighlight_GeSHi' );
138c142,144
< require_once( "extensions/ToggleDisplay/ToggleDisplay2.php" );
---
> #require_once( "extensions/ToggleDisplay/ToggleDisplay2.php" );
> # Post 1.26 extension registration change
> wfLoadExtension( 'ToggleDisplay' );
I then ran the update script as advised:
$ pwd
/Library/WebServer/Documents/w/maintenance
$ sudo php update.php
This appeared to complete without error.
Once I had done this, the wiki's content loaded, but the skin loading syntax has changed, so another modification was needed:
# Skin loading has changed in 1.26
wfLoadSkin( 'Vector' );
Having gone through the process with totorowiki
, it was easier to set up the upgraded lpmacwiki
. First, I modified the new file tree:
$ pwd
/Users/<USER>/Desktop/lpmacwiki
$ cp /Library/WebServer/Documents/lpmacwiki/LocalSettings.php ./
$ cp -R /Library/WebServer/Documents/lpmacwiki/images/ ./images
$ cp -R /Library/WebServer/Documents/lpmacwiki/logo.png ./
Then moved the old one and copied the new tree to its place:
$ pwd
/Library/WebServer/Documents
$ sudo mv lpmacwiki/ lpmacwiki.old
$ sudo mv ~/Desktop/lpmacwiki ./lpmacwiki
$ sudo chown -R _www:wheel lpmacwiki
Next I modified the LocalSettings.php
file:
129,131c129,135
< require_once( "$IP/extensions/Cite/Cite.php" );
< require_once( "$IP/extensions/PdfHandler/PdfHandler.php" );
< require_once( "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php" );
---
> #require_once( "$IP/extensions/Cite/Cite.php" );
> #require_once( "$IP/extensions/PdfHandler/PdfHandler.php" );
> #require_once( "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php" );
> # Extension loading is changed for v1.26 upgrade
> wfLoadExtension( 'Cite' );
> wfLoadExtension( 'PdfHandler' );
> wfLoadExtension( 'SyntaxHighlight_GeSHi' );
136,138d139
<
< # ToggleDisplay for backwards compatibility
< require_once( "extensions/ToggleDisplay/ToggleDisplay2.php" );
and ran the update.php
script:
$ pwd
/Library/WebServer/Documents/lpmacwiki/maintenance
$ sudo php update.php
MediaWiki 1.29.2 Updater
Your composer.lock file is up to date with current dependencies!
Going to run database updates for lpmacwiki
Using SQLite file: '/Library/WebServer/Documents/data/lpmacwiki.sqlite'
Depending on the size of your database this may take a while!
[...]
Adding empty categories with description pages...
Removing empty categories without description pages...
--mode=remove --begin=Virtualization_software
Category cleanup complete.
Purging caches...done.
Done in 2.2 s.
I then enabled the Vector
skin, using the new syntax:
# Skin loading changed for v1.26
wfLoadSkin( 'Vector' );
Reloading the wiki worked as expected.