From db7d95de27fccbe78ad13a08e164ecc900755ef9 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 7 Nov 2013 14:26:54 -0800 Subject: [PATCH] Don't use wfIsWindows() in CDB writers 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 | 7 +++++++ includes/utils/CdbDBA.php | 2 +- includes/utils/CdbPHP.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/utils/Cdb.php b/includes/utils/Cdb.php index 71fa8c80af..0995aed718 100644 --- a/includes/utils/Cdb.php +++ b/includes/utils/Cdb.php @@ -145,6 +145,13 @@ abstract class CdbWriter { $this->close(); } } + + /** + * Are we running on Windows? + */ + protected function isWindows() { + return substr( php_uname(), 0, 7 ) == 'Windows'; + } } /** diff --git a/includes/utils/CdbDBA.php b/includes/utils/CdbDBA.php index 5193409a4a..efcaf21f86 100644 --- a/includes/utils/CdbDBA.php +++ b/includes/utils/CdbDBA.php @@ -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 ) ) { diff --git a/includes/utils/CdbPHP.php b/includes/utils/CdbPHP.php index c6edaf5ca9..f05f786b37 100644 --- a/includes/utils/CdbPHP.php +++ b/includes/utils/CdbPHP.php @@ -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 ) ) { -- 2.20.1