Wikia code/includes/specials/SpecialUnlockdb.php

--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\specials\SpecialUnlockdb.php	2011-07-18 22:31:17.687500000 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\specials\SpecialUnlockdb.php	2011-08-17 15:28:16.333984400 +0100
@@ -34,10 +34,15 @@
 class DBUnlockForm {
 	function showForm( $err )
 	{
+		/*
+		 * WIKIA-SPECIFIC CHANGES
+		 * use $wgReadOnly instead, to prevent unnecessary stat()s (rt#20875)
+		 */
 		global $wgOut, $wgUser;
 
-		global $wgReadOnlyFile;
-		if( !file_exists( $wgReadOnlyFile ) ) {
+		global $wgReadOnly;
+#		if( !file_exists( $wgReadOnlyFile ) ) {
+		if( empty( $wgReadOnly ) ) {
 			$wgOut->addWikiMsg( 'databasenotlocked' );
 			return;
 		}
@@ -80,17 +85,27 @@
 	}
 
 	function doSubmit() {
-		global $wgOut, $wgRequest, $wgReadOnlyFile;
+		/*
+		 * WIKIA-SPECIFIC CHANGES
+		 * use $wgReadOnly instead, to prevent unnecessary stat()s (rt#20875)
+		 */
+		global $wgOut, $wgRequest, $wgReadOnlyFile, $wgCityId;
 
 		$wpLockConfirm = $wgRequest->getCheck( 'wpLockConfirm' );
 		if ( ! $wpLockConfirm ) {
 			$this->showForm( wfMsg( "locknoconfirm" ) );
 			return;
 		}
-		if ( @! unlink( $wgReadOnlyFile ) ) {
-			$wgOut->showFileDeleteError( $wgReadOnlyFile );
+#		if ( @! unlink( $wgReadOnlyFile ) ) {
+#			$wgOut->showFileDeleteError( $wgReadOnlyFile );
+#			return;
+#		}
+
+		if ( !WikiFactory::setVarByName( 'wgReadOnly', $wgCityId, '' ) || !WikiFactory::clearCache( $wgCityId ) ) {
+			$wgOut->showErrorPage( 'unlockdb', 'unlockdb-wikifactory-error');
 			return;
 		}
+
 		$titleObj = SpecialPage::getTitleFor( "Unlockdb" );
 		$success = $titleObj->getFullURL( "action=success" );
 		$wgOut->redirect( $success );