jenkins-bot has submitted this change and it was merged.
Change subject: Improve wfTempDir() fallback sequence
......................................................................
Improve wfTempDir() fallback sequence
Validate the return value of sys_get_temp_dir(), and use upload_tmp_dir
if that is not writable. If nothing is writable, throw an exception.
Bug: T119934
Change-Id: I27d784f55c47277bbab1192853e2e04a9d8bd39a
---
M includes/GlobalFunctions.php
1 file changed, 6 insertions(+), 3 deletions(-)
Approvals:
BryanDavis: Looks good to me, approved
Ananay: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index f797e5b..928066b 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -2162,8 +2162,8 @@
/**
* Tries to get the system directory for temporary files. First
* $wgTmpDirectory is checked, and then the TMPDIR, TMP, and TEMP
- * environment variables are then checked in sequence, and if none are
- * set try sys_get_temp_dir().
+ * environment variables are then checked in sequence, then
+ * sys_get_temp_dir(), then upload_tmp_dir from php.ini.
*
* NOTE: When possible, use instead the tmpfile() function to create
* temporary files to avoid race conditions on file creation, etc.
@@ -2178,13 +2178,16 @@
}
$tmpDir = array_map( "getenv", array( 'TMPDIR', 'TMP', 'TEMP' ) );
+ $tmpDir[] = sys_get_temp_dir();
+ $tmpDir[] = ini_get( 'upload_tmp_dir' );
foreach ( $tmpDir as $tmp ) {
if ( $tmp && file_exists( $tmp ) && is_dir( $tmp ) &&
is_writable( $tmp ) ) {
return $tmp;
}
}
- return sys_get_temp_dir();
+ throw new MWException( 'No writable temporary directory could be found.
' .
+ 'Please set $wgTmpDirectory to a writable directory.' );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/265132
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I27d784f55c47277bbab1192853e2e04a9d8bd39a
Gerrit-PatchSet: 12
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ananay <[email protected]>
Gerrit-Reviewer: Aklapper <[email protected]>
Gerrit-Reviewer: Ananay <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: L10n-bot <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits