* like "subdir/foo.html", etc.
*
* @param string $url Either fully-qualified or a local path + query
- * @param string $defaultProto One of the PROTO_* constants. Determines the
+ * @param string|int|null $defaultProto One of the PROTO_* constants. Determines the
* protocol to use if $url or $wgServer is protocol-relative
* @return string|false Fully-qualified URL, current-path-relative URL or false if
* no valid URL can be constructed
if ( $wasRelative ) {
$url = "http:$url";
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$bits = parse_url( $url );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
// parse_url() returns an array without scheme for some invalid URLs, e.g.
// parse_url("%0Ahttp://example.com") == [ 'host' => '%0Ahttp', 'path' => 'example.com' ]
if ( !$bits || !isset( $bits['scheme'] ) ) {
/**
* Check whether a given URL has a domain that occurs in a given set of domains
- * @param string $url URL
+ * @param string $url
* @param array $domains Array of domains (strings)
* @return bool True if the host part of $url ends in one of the strings in $domains
*/
/**
* Reference-counted warning suppression
*
- * @deprecated since 1.26, use MediaWiki\suppressWarnings() directly
+ * @deprecated since 1.26, use Wikimedia\suppressWarnings() directly
* @param bool $end
*/
function wfSuppressWarnings( $end = false ) {
- MediaWiki\suppressWarnings( $end );
+ Wikimedia\suppressWarnings( $end );
}
/**
- * @deprecated since 1.26, use MediaWiki\restoreWarnings() directly
+ * @deprecated since 1.26, use Wikimedia\restoreWarnings() directly
* Restore error level to previous value
*/
function wfRestoreWarnings() {
- MediaWiki\suppressWarnings( true );
+ Wikimedia\restoreWarnings();
}
/**
return defined( 'HHVM_VERSION' );
}
+/**
+ * Check if we are running from the commandline
+ *
+ * @since 1.31
+ * @return bool
+ */
+function wfIsCLI() {
+ return PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg';
+}
+
/**
* Tries to get the system directory for temporary files. First
* $wgTmpDirectory is checked, and then the TMPDIR, TMP, and TEMP
}
// Turn off the normal warning, we're doing our own below
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$ok = mkdir( $dir, $mode, true ); // PHP5 <3
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$ok ) {
// directory may have been created on another request since we last checked
# This check may also protect against code injection in
# case of broken installations.
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( !$haveDiff3 ) {
wfDebug( "diff3 not found\n" );
}
global $wgDiff;
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$haveDiff = $wgDiff && file_exists( $wgDiff );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
# This check may also protect against code injection in
# case of broken installations.
if ( session_id() !== $session->getId() ) {
session_id( $session->getId() );
}
- MediaWiki\quietCall( 'session_start' );
+ Wikimedia\quietCall( 'session_start' );
}
/**
$ifWritesSince = null, $wiki = false, $cluster = false, $timeout = null
) {
if ( $timeout === null ) {
- $timeout = ( PHP_SAPI === 'cli' ) ? 86400 : 10;
+ $timeout = wfIsCLI() ? 86400 : 10;
}
if ( $cluster === '*' ) {
$conflimit = wfShorthandToInteger( $wgMemoryLimit );
if ( $conflimit == -1 ) {
wfDebug( "Removing PHP's memory limit\n" );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
ini_set( 'memory_limit', $conflimit );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $conflimit;
} elseif ( $conflimit > $memlimit ) {
wfDebug( "Raising PHP's memory limit to $conflimit bytes\n" );
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
ini_set( 'memory_limit', $conflimit );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
return $conflimit;
}
}
}
}
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$result = unpack( $format, $data );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $result === false ) {
// If it cannot extract the packed data.
return getrusage( 0 /* RUSAGE_SELF */ );
}
}
-
-/**
- * Begin profiling of a function
- * @param string $functionname Name of the function we will profile
- * @deprecated since 1.25
- */
-function wfProfileIn( $functionname ) {
-}
-
-/**
- * Stop profiling of a function
- * @param string $functionname Name of the function we have profiled
- * @deprecated since 1.25
- */
-function wfProfileOut( $functionname = 'missing' ) {
-}