$query = wfArrayToCgi( $query );
}
if ( $query != '' ) {
+ // Remove the fragment, if there is one
+ $fragment = false;
+ $hashPos = strpos( $url, '#' );
+ if ( $hashPos !== false ) {
+ $fragment = substr( $url, $hashPos );
+ $url = substr( $url, 0, $hashPos );
+ }
+
+ // Add parameter
if ( false === strpos( $url, '?' ) ) {
$url .= '?';
} else {
$url .= '&';
}
$url .= $query;
+
+ // Put the fragment back
+ if ( $fragment !== false ) {
+ $url .= $fragment;
+ }
}
return $url;
}
return $tmp;
}
}
+
+ /**
+ * PHP on Windows will detect C:\Windows\Temp as not writable even though PHP can write to it
+ * so create a directory within that called 'mwtmp' with a suffix of the user running the
+ * current process.
+ * The user is included as if various scripts are run by different users they will likely
+ * not be able to access each others temporary files.
+ */
+ if ( wfIsWindows() ) {
+ $tmp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mwtmp' . '-' . get_current_user();
+ if ( !file_exists( $tmp ) ) {
+ mkdir( $tmp );
+ }
+ if ( file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
+ return $tmp;
+ }
+ }
+
throw new MWException( 'No writable temporary directory could be found. ' .
'Please set $wgTmpDirectory to a writable directory.' );
}