Add Blob to accepted types for uploads
[lhc/web/wiklou.git] / includes / MagicWord.php
index 186821d..80e60d2 100644 (file)
@@ -23,6 +23,8 @@
  * @ingroup Parser
  */
 
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * This class encapsulates "magic words" such as "#redirect", __NOTOC__, etc.
  *
@@ -718,9 +720,6 @@ class MagicWordArray {
 
        private $regex;
 
-       /** @todo Unused? */
-       private $matches;
-
        /**
         * @param array $names
         */
@@ -953,12 +952,29 @@ class MagicWordArray {
                        if ( $regex === '' ) {
                                continue;
                        }
-                       preg_match_all( $regex, $text, $matches, PREG_SET_ORDER );
-                       foreach ( $matches as $m ) {
-                               list( $name, $param ) = $this->parseMatch( $m );
-                               $found[$name] = $param;
+                       $matches = array();
+                       $res = preg_match_all( $regex, $text, $matches, PREG_SET_ORDER );
+                       if ( $res === false ) {
+                               LoggerFactory::getInstance( 'parser' )->warning( 'preg_match_all returned false', array(
+                                       'code' => preg_last_error(),
+                                       'regex' => $regex,
+                                       'text' => $text,
+                               ) );
+                       } elseif ( $res ) {
+                               foreach ( $matches as $m ) {
+                                       list( $name, $param ) = $this->parseMatch( $m );
+                                       $found[$name] = $param;
+                               }
+                       }
+                       $res = preg_replace( $regex, '', $text );
+                       if ( $res === null ) {
+                               LoggerFactory::getInstance( 'parser' )->warning( 'preg_replace returned null', array(
+                                       'code' => preg_last_error(),
+                                       'regex' => $regex,
+                                       'text' => $text,
+                               ) );
                        }
-                       $text = preg_replace( $regex, '', $text );
+                       $text = $res;
                }
                return $found;
        }