Gergő Tisza has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/249898

Change subject: Revert throwing exceptions on preg_* failures
......................................................................

Revert throwing exceptions on preg_* failures

This reverts I3840a56adc0a6e50963b930051892491f8e90245 which
threw exceptions on broken UTF-8 in $text.

Bug: T115514
Bug: T117066
Change-Id: Ie665056a13f9e3678a49790d787b0a41dbba6362
---
M includes/MagicWord.php
1 file changed, 2 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/98/249898/1

diff --git a/includes/MagicWord.php b/includes/MagicWord.php
index 17c7cd4..2c7ba91 100644
--- a/includes/MagicWord.php
+++ b/includes/MagicWord.php
@@ -941,7 +941,6 @@
         *
         * @param string $text
         *
-        * @throws Exception
         * @return array
         */
        public function matchAndRemove( &$text ) {
@@ -952,24 +951,13 @@
                                continue;
                        }
                        $matches = array();
-                       $matched = preg_match_all( $regex, $text, $matches, 
PREG_SET_ORDER );
-                       if ( $matched === false ) {
-                               throw new Exception( __METHOD__ . ': 
preg_match_all returned false with error code '
-                                       . preg_last_error() );
-                       }
-                       if ( $matched ) {
+                       if ( preg_match_all( $regex, $text, $matches, 
PREG_SET_ORDER ) ) {
                                foreach ( $matches as $m ) {
                                        list( $name, $param ) = 
$this->parseMatch( $m );
                                        $found[$name] = $param;
                                }
                        }
-                       $replaced = preg_replace( $regex, '', $text );
-                       if ( $replaced !== null ) {
-                               $text = $replaced;
-                       } else {
-                               throw new Exception( __METHOD__ . ': 
preg_replace returned null with error code '
-                                       . preg_last_error() );
-                       }
+                       $text = preg_replace( $regex, '', $text );
                }
                return $found;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/249898
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie665056a13f9e3678a49790d787b0a41dbba6362
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: GergÅ‘ Tisza <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to