UESPWiki:Server Upgrade/MW 1.14 to 1.19

Notes for the upgrade of UESP's custom MediaWiki code from 1.14 to 1.19.  


Update PHP
MediaWiki v1.19 requires PHP v5.2 or higher but unfortunately the standard package managers on the UESP servers only have version 5.1.6. The following rather complex procedure is used to get a working version of 5.2:

:* Import alternate repository GPG key: rpm --import  (See for more details).
:* Create a file /etc/yum.repos.d/utterramblings.repo with the following content:
     [utterramblings
     name=Jason's Utter Ramblings Repo
     baseurl=
     enabled=1
     gpgcheck=1
     gpgkey=
:* Upgrade PHP via yum upgrade php. Note that this will upgrade a variety of related packages, including mysql, so ensure no vital services are affected before continuing.
:* yum install php-eaccelerator
:* yum install php-mcrypt
:* yum erase php-pecl-memcache
:* yum install php-memcache
:* Recompile and install the wikidiff2 extension to /usr/lib/php/modules/
:* This version of PHP doesn't have the correct PCRE library. To update this do the following (taken from here):
::* Download the updated PCRE RPM: pcre-6.6-2.7.i386.rpm.
::* Update the package: rpm -Uvh pcre-6.6-2.7.i386.rpm
::* Check the PCRE settings via pcretest -C which should be something like
   PCRE version 6.6 06-Feb-2006
   Compiled with
     UTF-8 support
     Unicode properties support
     Newline character is LF
     Internal link size = 2
     POSIX malloc threshold = 10
     Default match limit = 10000000
     Default recursion depth limit = 10000000
     Match recursion uses stack
:* Stop and start Apache (a graceful restart will not work) and check the server's phpinfo.php page to ensure a successful upgrade.


UespCustomCode
Updates required to the custom UESP extension:

:* Change Namespace:: to MWNamespace:: 
:* Change PreferencesForm to SpecialPreferences in SiteSpecialPreferences.php
:* Line 33 in MetaTemplateCategoryPage.php needs to be changed to (API change needs a proper context object in second argument):
     $viewer = new CategoryTreeCategoryViewer( $this->mTitle, $this->getContext(), $from, $until );
:* Line 29 in MetaTemplateCategoryPage.php needs to be modified likewise:
     $viewer = new MetaTemplateCategoryViewer( $this->mTitle, $this->getContext(), $from, $until );
:* Line 35 likewise:
     $viewer = new CategoryViewer( $this->mTitle, $this->getContext(), $from, $until);

MediaWiki File Changes
:* skins/MonoBook.php
::* Add to line 90 in between the two     on that line
            
::* Add to line 199 before the    
            
::* Add to line 281 before the  
                 if( function_exists('efUespCustomCode') ) {
                        if (substr($val['text'],0,1)=='*') {
                                if (!$isindent) echo "\n \n";
                        }
		} 
::* Add to line 284 before the  
 \n"; 
:* Move custom code in main.css to  (main.css is now the original v1.19)
:* In order for the toolbar links to work on the Main_Page the three "Main_Page" blocks need to be unhidden.
:* Delete  . Previous custom changes are no longer needed (?) and end up with missing spaces.
:* Code for custom namespace search preferences?

Extensions
:* ActiveUsers renamed to UsersEditCount to not interfere with built-in extension of the same name. Modified extension to work properly.
:* CharInsert updated to latest source version
:* CheckUser updated to latest source version
:* CategoryTree updated to latest source version
:* Cite updated to latest source version
:* CustomCategory removed (not used)
:* DeleteBatch updated to latest source version
:* DismissableSiteNotice updated to latest source version
:* DragonFont no update needed?
:* Editcount no update needed (not to be confused with the official extension with the same name)?
:* DynamicFunctions no update needed?
:* ExpandTemplates updated to latest source version
:* Gadgets already updated in the v1.19 source.
::* Need to update  from source at 
:* Icon removed as features are now built into MediaWiki
:* ImageMap updated to latest source version
:* InputBox updated to latest source version
:* LabeledSectionTransclusion updated to latest source version
:* MediaFunctions no update needed?
:* MetaTemplate no update needed (custom extension)?
:* Nuke updated to latest source version
:* Oversight updated to latest source version
:* ParserFunctions already updated in the v1.19 source.
:* Patroller updated to latest source version
:* ProtectSection updated to latest source version
:* ReCaptcha removed (replaced by ConfirmEdit)
:* RegexFunctions updated to latest source version
:* RenameUser already updated in the v1.19 source.
:* SearchLog no update available
::* Need to modify the method onSearchResults() in SearchLog.php to read:
 
::: to prevent a null error from being displayed in searches.
:* SpamBlacklist updated to latest source version
:* StringFunctions updated to latest source version
:* TitleBlacklist updated to latest source version
:* TorBlock updated to latest source version
:* UespCustomCode see above section
:* UespMap no update needed
:* UespPaypal no longer used
:* UespSiteStats no longer used
:* UncategorizedUESPPages no update needed?
:* Vector updated to latest source version
:* WikiEditor updated to latest source version
:* WikiTextLoggedInOut updated to latest source version

Upgrade Procedure

Pre-Upgrade Items
These items can be done at any time prior to the actual upgrade.

:* Upgrade PHP on content1/2/3
:* Copy Wiki v1.19 directory from the development directory on content3 to content1/2/3 temporary directory /w19 (10 min)
:* Edit w19/LocalSettings.php on content1/2/3 to correctly reflect the Wiki location (5 min)
:* Wiki database cloning using an iterative backup:
::* Create a new database: uesp_net_wiki14
::* Copy that last complete Wiki database dump into the new database: mysqldump -u user -p uesp_net_wiki14   900000.
::* Copy the iterative backup into the new database.

Upgrade Preperation
Things to do just before the upgrade is to occur.

:* Set Wiki to read-only, both v1.14 and v1.19 (5 min)
:* Perform iterative database dump of Wiki (5 min)
:* Load database dump into a new temporary database (15 minute)
:* Point the Wikis on content1/2 to the new temporary database (this will never be written to) (5 min)

Upgrade
At this point the public Wiki should be v1.14 set to read-only mode and running from a temporary database. Wiki v1.19 is available from /w19 also in read-only mode and running from the main database (although the db is still v1.14).

:* Perform the v1.19 database update on content1 (1 hour?)
:* Test the v1.19 Wiki for basic functionality (5 min)
:* Edit /w19/LocalSettings.php to prepare it for the move to /w (5 min)
:* Change the live Wiki to use v1.19: Move /w to /w14 and /w19 to /w (5 min)
:* Test the Wiki for basic functionality (5 min)
:* Turn off read-only mode for the v1.19 Wiki (5 min)
::* Estimated lock time: 115 minutes (conservative)
:* Test the Wiki for basic functionality (5 min)

Post Upgrade
:* Update  from source at 
:* Delete  .


Post Upgrade Notes
:* Update all the gadget JavaScript articles.
:* The icons that are in /w/skins/monobook/ were trying to be accessed as /w/ and thus were not being found. Manually copied then into /w/ for now. Copied external-ltr.png to external.png as some pages were still referencing the latter.
:* "Save" button in preferences too high.
:* All user preferences were reset. Too late now but no idea why.
:* "Edit Summary" message no longer accepts HTML. Revert to wiki markup.
:* Added the blocktalk permission to the blockusers'' group in order to prevent the error message about not being able to block a user's talk page from popping up.
:* Modified line 35 in /w/includes/logging/PatrolLog.php to fix this bug not merged into the 1.19 release.


Broken Things
Note that this is not a complete description of the issue which may be discussed in more detail elsewhere. Its intent is a quick "todo" list as well historical reference.

:* Keep an eye on the abuse filters and modify as needed (can't be too strict nor too loose).
:* Edit summary link not working. Partially fixed by reverting to wiki code. A more thorough CSS fix needed.
:* Image thumbnails no longer line up as previously. 
:* Floating images don't work properly.
:* Page search doesn't work the same as previously.
:* Namespace search preferences aren't the same as previously.
:* The showhide template doesn't work.
:* Table formatting not the same as previously.
:* Blockers get incorrect message about not blocking a talk page. Partially fixed by a permissions change. Blocker are always watched even when not checked.
:* Adding "lazy" links doesn't work properly.
:* Galleries do not appear correctly.
:* Cannot view more than 200 pages in a category. Apparently something related to the CategoryTree extension but disabling it had no effect.

Fixed
:* Save button is too tall. Fixed by editing the CSS.
:* Missing bullets (and other images). Fixed by copying new image files from /w/skins/monobook/ into /w/ and/or updating skins.uesp.net to v1.19.
:* Updated the gadget JavaScript pages.
:* Unusually high content1/2 loads due to pages not being properly cached by squid1 ultimately due to missing/incorrect cache control headers. Fixed by turning off file cache on the content servers. This brought both the Squid hit rate and the content server loads back to normal.
:* Gadgets were missing on content1/2. Fixed by removing $wgMainCacheType = CACHE_MEMCACHED;. Unsure of exact cause and proper fix.
:* Patrol log credits wrong user for the patrol. Fixed by applying a custom code patch from the MediaWiki source control (change not properly merged into the v1.19 trunk).
:* Post times are in EDT instead of UTC. Required adding ''"$wgLocaltimezone = 'GMT';".
:* Uploads stopped working: Need a cron script to clear out /tmp/ daily/weekly of all magick* and transform*'' files.