Don't use wfIsWindows() in CDB writers
authorChad Horohoe <chadh@wikimedia.org>
Thu, 7 Nov 2013 22:26:54 +0000 (14:26 -0800)
committerChad Horohoe <chadh@wikimedia.org>
Sat, 9 Nov 2013 01:20:41 +0000 (17:20 -0800)
Uses the same logic, but without the dependency on MediaWiki.
Planning to use this in the het-deploy code.

Change-Id: I5d6baf6fe63d135c679e4795287daa0a8722dde6

includes/utils/Cdb.php
includes/utils/CdbDBA.php
includes/utils/CdbPHP.php

index 71fa8c8..0995aed 100644 (file)
@@ -145,6 +145,13 @@ abstract class CdbWriter {
                        $this->close();
                }
        }
+
+       /**
+        * Are we running on Windows?
+        */
+       protected function isWindows() {
+               return substr( php_uname(), 0, 7 ) == 'Windows';
+       }
 }
 
 /**
index 5193409..efcaf21 100644 (file)
@@ -64,7 +64,7 @@ class CdbWriterDBA extends CdbWriter {
                if ( isset( $this->handle ) ) {
                        dba_close( $this->handle );
                }
-               if ( wfIsWindows() ) {
+               if ( $this->isWindows() ) {
                        unlink( $this->realFileName );
                }
                if ( !rename( $this->tmpFileName, $this->realFileName ) ) {
index c6edaf5..f05f786 100644 (file)
@@ -334,7 +334,7 @@ class CdbWriterPHP extends CdbWriter {
                if ( isset( $this->handle ) ) {
                        fclose( $this->handle );
                }
-               if ( wfIsWindows() && file_exists( $this->realFileName ) ) {
+               if ( $this->isWindows() && file_exists( $this->realFileName ) ) {
                        unlink( $this->realFileName );
                }
                if ( !rename( $this->tmpFileName, $this->realFileName ) ) {