Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 2b6088e..f9f499a 100644 (file)
@@ -40,7 +40,7 @@ use Wikimedia\ScopedCallback;
  */
 
 // hash_equals function only exists in PHP >= 5.6.0
-// http://php.net/hash_equals
+// https://secure.php.net/hash_equals
 if ( !function_exists( 'hash_equals' ) ) {
        /**
         * Check whether a user-provided string is equal to a fixed-length secret string
@@ -1625,11 +1625,13 @@ function wfShowingResults( $offset, $limit ) {
 }
 
 /**
- * @todo document
- * @todo FIXME: We may want to blacklist some broken browsers
+ * Whether the client accept gzip encoding
  *
- * @param bool $force
- * @return bool Whereas client accept gzip compression
+ * Uses the Accept-Encoding header to check if the client supports gzip encoding.
+ * Use this when considering to send a gzip-encoded response to the client.
+ *
+ * @param bool $force Forces another check even if we already have a cached result.
+ * @return bool
  */
 function wfClientAcceptsGzip( $force = false ) {
        static $result = null;
@@ -1668,7 +1670,9 @@ function wfClientAcceptsGzip( $force = false ) {
 function wfEscapeWikiText( $text ) {
        global $wgEnableMagicLinks;
        static $repl = null, $repl2 = null;
-       if ( $repl === null ) {
+       if ( $repl === null || defined( 'MW_PARSER_TEST' ) || defined( 'MW_PHPUNIT_TEST' ) ) {
+               // Tests depend upon being able to change $wgEnableMagicLinks, so don't cache
+               // in those situations
                $repl = [
                        '"' => '&#34;', '&' => '&#38;', "'" => '&#39;', '<' => '&#60;',
                        '=' => '&#61;', '>' => '&#62;', '[' => '&#91;', ']' => '&#93;',
@@ -2134,7 +2138,7 @@ function wfMkdirParents( $dir, $mode = null, $caller = null ) {
  */
 function wfRecursiveRemoveDir( $dir ) {
        wfDebug( __FUNCTION__ . "( $dir )\n" );
-       // taken from http://de3.php.net/manual/en/function.rmdir.php#98622
+       // taken from https://secure.php.net/manual/en/function.rmdir.php#98622
        if ( is_dir( $dir ) ) {
                $objects = scandir( $dir );
                foreach ( $objects as $object ) {
@@ -2227,8 +2231,8 @@ function wfEscapeShellArg( /*...*/ ) {
                        // Escaping for an MSVC-style command line parser and CMD.EXE
                        // @codingStandardsIgnoreStart For long URLs
                        // Refs:
-                       //  * http://web.archive.org/web/20020708081031/http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html
-                       //  * http://technet.microsoft.com/en-us/library/cc723564.aspx
+                       //  * https://web.archive.org/web/20020708081031/http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html
+                       //  * https://technet.microsoft.com/en-us/library/cc723564.aspx
                        //  * T15518
                        //  * CR r63214
                        // Double the backslashes before any double quotes. Escape the double quotes.
@@ -2328,7 +2332,7 @@ function wfShellExec( $cmd, &$retval = null, $environ = [],
                if ( wfIsWindows() ) {
                        /* Surrounding a set in quotes (method used by wfEscapeShellArg) makes the quotes themselves
                         * appear in the environment variable, so we must use carat escaping as documented in
-                        * http://technet.microsoft.com/en-us/library/cc723564.aspx
+                        * https://technet.microsoft.com/en-us/library/cc723564.aspx
                         * Note however that the quote isn't listed there, but is needed, and the parentheses
                         * are listed there but doesn't appear to need it.
                         */
@@ -2546,7 +2550,7 @@ function wfShellExecWithStderr( $cmd, &$retval = null, $environ = [], $limits =
 }
 
 /**
- * Workaround for http://bugs.php.net/bug.php?id=45132
+ * Workaround for https://bugs.php.net/bug.php?id=45132
  * escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale
  */
 function wfInitShellLocale() {
@@ -2798,7 +2802,7 @@ function wfUseMW( $req_ver ) {
 /**
  * Return the final portion of a pathname.
  * Reimplemented because PHP5's "basename()" is buggy with multibyte text.
- * http://bugs.php.net/bug.php?id=33898
+ * https://bugs.php.net/bug.php?id=33898
  *
  * PHP's basename() only considers '\' a pathchar on Windows and Netware.
  * We'll consider it so always, as we don't want '\s' in our Unix paths either.
@@ -3514,7 +3518,7 @@ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
        # Run the extension hook
        $bad = false;
        if ( !Hooks::run( 'BadImage', [ $name, &$bad ] ) ) {
-               return $bad;
+               return (bool)$bad;
        }
 
        $cache = ObjectCache::getLocalServerInstance( 'hash' );