*/
function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
global $wgServer, $wgCanonicalServer, $wgInternalServer, $wgRequest;
- $serverUrl = $wgServer;
if ( $defaultProto === PROTO_CANONICAL ) {
$serverUrl = $wgCanonicalServer;
- }
- // Make $wgInternalServer fall back to $wgServer if not set
- if ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) {
+ } elseif ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) {
+ // Make $wgInternalServer fall back to $wgServer if not set
$serverUrl = $wgInternalServer;
- }
- if ( $defaultProto === PROTO_CURRENT ) {
- $defaultProto = $wgRequest->getProtocol() . '://';
+ } else {
+ $serverUrl = $wgServer;
+ if ( $defaultProto === PROTO_CURRENT ) {
+ $defaultProto = $wgRequest->getProtocol() . '://';
+ }
}
// Analyze $serverUrl to obtain its protocol
* @param array $environ optional environment variables which should be
* added to the executed command environment.
* @param array $limits optional array with limits(filesize, memory, time, walltime)
- * this overwrites the global wgShellMax* limits.
+ * this overwrites the global wgMaxShell* limits.
* @param array $options Array of options:
- * - duplicateStderr: Set this to true to duplicate stderr to stdout,
+ * - duplicateStderr: Set this to true to duplicate stderr to stdout,
* including errors from limit.sh
- *
+ *
* @return string collected stdout as a string
*/
function wfShellExec( $cmd, &$retval = null, $environ = array(),
if ( $useLogPipe ) {
$desc[3] = array( 'pipe', 'w' );
}
+
+ # TODO/FIXME: This is a bad hack to workaround an HHVM bug that prevents
+ # proc_open() from opening stdin/stdout, so use /dev/null *for now*
+ # See bug 56597 / https://github.com/facebook/hhvm/issues/1247 for more info
+ if ( wfIsHHVM() ) {
+ $desc[0] = array( 'file', '/dev/null', 'r' );
+ $desc[2] = array( 'file', '/dev/null', 'w' );
+ }
+
$pipes = null;
$proc = proc_open( $cmd, $desc, $pipes );
if ( !$proc ) {
$logMsg = false;
// According to the documentation, it is possible for stream_select()
- // to fail due to EINTR. I haven't managed to induce this in testing
- // despite sending various signals. If it did happen, the error
- // message would take the form:
+ // to fail due to EINTR. I haven't managed to induce this in testing
+ // despite sending various signals. If it did happen, the error
+ // message would take the form:
//
// stream_select(): unable to select [4]: Interrupted system call (max_fd=5)
//
wfRunHooks( 'ResetSessionID', array( $oldSessionId, $newSessionId ) );
}
-
/**
* Initialise php session
*
* @param string|bool $cluster Cluster name accepted by LBFactory. Default: false.
*/
function wfWaitForSlaves( $maxLag = false, $wiki = false, $cluster = false ) {
- if( $cluster !== false ) {
+ if ( $cluster !== false ) {
$lb = wfGetLBFactory()->getExternalLB( $cluster );
} else {
$lb = wfGetLB( $wiki );