EBernhardson has uploaded a new change for review. https://gerrit.wikimedia.org/r/101236
Change subject: Gracefully handle errors applying redlinks ...................................................................... Gracefully handle errors applying redlinks An invalid wikilink like [[Foo&bar]], when it gets through to the redlink handling, will error out because &bar is not a valid html entity. This first repair sets up more gracefull error handling for failures in redlinking(just show the content without redlinks applied). A future fix will also address the html entity in url problem. Change-Id: Iaa36485325668af4bb7b4556e6dedf9c9d3bf346 --- M includes/ParsoidUtils.php M includes/Templating.php 2 files changed, 16 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/36/101236/1 diff --git a/includes/ParsoidUtils.php b/includes/ParsoidUtils.php index 9e2bea9..bcc2431 100644 --- a/includes/ParsoidUtils.php +++ b/includes/ParsoidUtils.php @@ -193,16 +193,17 @@ return !in_array( $error->code, $ignoreErrorCodes ); } ); - if ( $errors ) { - throw new \MWException( - implode( "\n", array_map( $errors, function( $error ) { return $error->message; } ) ) - ); - } - // restore libxml error reporting + // restore libxml state before anything else libxml_clear_errors(); libxml_use_internal_errors( $useErrors ); + if ( $errors ) { + throw new \MWException( + implode( "\n", array_map( function( $error ) { return $error->message; }, $errors ) ) + ); + } + return $dom; } } diff --git a/includes/Templating.php b/includes/Templating.php index f02aa9c..b295dbb 100644 --- a/includes/Templating.php +++ b/includes/Templating.php @@ -276,7 +276,7 @@ * RecentChanges pages. * * Moderation-aware. - * + * * @param AbstractRevision $revision Revision to display * @param User $permissionsUser The User to check permissions for * @return string HTML @@ -359,7 +359,14 @@ if ( $format === 'html' ) { // Parsoid doesn't render redlinks - $content = $this->applyRedlinks( $content ); + try { + $content = $this->applyRedlinks( $content ); + } catch ( \MWException $e ) { + // @todo + wfDebugLog( __CLASS__, __METHOD__ . ': Failed applying redlinks for rev_id = ' . $revision->getRevisionId()->getHex() ); + \MWExceptionHandler::logException( $e ); + } + } return $content; -- To view, visit https://gerrit.wikimedia.org/r/101236 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa36485325668af4bb7b4556e6dedf9c9d3bf346 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits