From cbecc9d1ee230d1e5e50c8d2587b5d80be7964e8 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 5 Apr 2012 16:38:53 +0200 Subject: [PATCH] fix getAutosummary() for cases where is empty Change-Id: I21143dff15bf47ff9fa5ee51a88b046988c8367a --- includes/ContentHandler.php | 10 +++++----- includes/WikiPage.php | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/ContentHandler.php b/includes/ContentHandler.php index 4eb40610c9..a6269eba04 100644 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@ -274,20 +274,20 @@ abstract class ContentHandler { /** * Return an applicable autosummary if one exists for the given edit. * - * @param $oldContent Content: the previous text of the page. - * @param $newContent Content: The submitted text of the page. + * @param $oldContent Content|null: the previous text of the page. + * @param $newContent Content|null: The submitted text of the page. * @param $flags Int bitmask: a bitmask of flags submitted for the edit. * * @return string An appropriate autosummary, or an empty string. */ - public function getAutosummary( Content $oldContent, Content $newContent, $flags ) { + public function getAutosummary( Content $oldContent = null, Content $newContent = null, $flags ) { global $wgContLang; # Decide what kind of autosummary is needed. # Redirect autosummaries - $ot = $oldContent->getRedirectTarget(); - $rt = $newContent->getRedirectTarget(); + $ot = !empty( $ot ) ? $oldContent->getRedirectTarget() : false; + $rt = !empty( $rt ) ? $newContent->getRedirectTarget() : false; if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) { diff --git a/includes/WikiPage.php b/includes/WikiPage.php index e992efdb35..f91f758d52 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1375,6 +1375,7 @@ class WikiPage extends Page { # Provide autosummaries if one is not provided and autosummaries are enabled. if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) { + if ( !$old_content ) $old_content = null; $summary = $handler->getAutosummary( $old_content, $content, $flags ); } @@ -2560,8 +2561,8 @@ class WikiPage extends Page { # NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't. $handler = ContentHandler::getForModelName( CONTENT_MODEL_WIKITEXT ); - $oldContent = $handler->unserialize( $oldtext ); - $newContent = $handler->unserialize( $newtext ); + $oldContent = $oldtext ? $handler->unserialize( $oldtext ) : null; + $newContent = $newtext ? $handler->unserialize( $newtext ) : null; return $handler->getAutosummary( $oldContent, $newContent, $flags ); } -- 2.20.1