New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WikilogUtils: Replace WikiPage::getText() with getContent() #21
WikilogUtils: Replace WikiPage::getText() with getContent() #21
Conversation
WikilogUtils.php
Outdated
@@ -210,7 +210,7 @@ public static function parsedArticle( Title $title, $feed = false ) { | |||
$parser->startExternalParse( $title, $parserOpt, Parser::OT_HTML ); | |||
|
|||
# Parse article. | |||
$arttext = $article->getText(); | |||
$arttext = $article->getContent()->getNativeData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check, if the returned Content object is a TextContent (instanceof TextContent), as this is currently the implementation, which will return text for getNativeData(). Any other implementation will vary depending on the content model of the page.
Here in this case, I think it's best to just check if the content model is TextContent, and if not return default values (null or empty things).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay!
WikilogUtils.php
Outdated
@@ -328,7 +328,7 @@ public static function categoryList( $list ) { | |||
foreach ( $list as $cat ) { | |||
$title = Title::makeTitle( NS_CATEGORY, $cat ); | |||
$categoryUrl = $title->getPrefixedText(); | |||
$categoryTxt = $title->getText(); | |||
$categoryTxt = $title->getContent()->getNativeData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry my bad, I think $title
here is not related with WikiPage
WikilogUtils.php
Outdated
@@ -365,7 +365,7 @@ public static function tagList( $list ) { | |||
public static function splitSummaryContent( $parserOutput ) { | |||
global $wgUseTidy; | |||
|
|||
$content = Sanitizer::removeHTMLcomments( $parserOutput->getText() ); | |||
$content = Sanitizer::removeHTMLcomments( $parserOutput->getContent()->getNativeData() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $title
here is not related with WikiPage
01f407b
to
11b442b
Compare
WikilogUtils.php
Outdated
@@ -210,7 +210,8 @@ public static function parsedArticle( Title $title, $feed = false ) { | |||
$parser->startExternalParse( $title, $parserOpt, Parser::OT_HTML ); | |||
|
|||
# Parse article. | |||
$arttext = $article->getText(); | |||
$articleContent = $article->getContent(); | |||
$arttext = $articleContent instanceof TextContent ? $articleContent->getNativeData() : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is false really a good default value? What do you think about checking, if the content is a TextContent, and if not, returning with an empty string as the text, as it would be pointless to proceed in the codepath with an empty string I think.
return array( $article, '');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
Replace `WikiPage::getText()` with `WikiPage::getContent()->getNativeData()` in `WikilogUtils.php`, since `WikiPage::getText()` had been removed from `WikiPage`. Bug: T179532
11b442b
to
97d1e06
Compare
$arttext = $article->getText(); | ||
$articleContent = $article->getContent(); | ||
if ( !($articleContent instanceof TextContent) ){ | ||
# Restore default behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From line 230, I think we need to restore the default behavior (I think it's related to the parser).
/**
* Enable special wikilog feed parsing.
*
* This function changes the parser behavior in order to output
*
* The proper way to use this function is:
* @code
* $saveFeedParse = WikilogParser::enableFeedParsing();
* # ...code that uses $wgParser in order to parse articles...
* WikilogParser::enableFeedParsing( $saveFeedParse );
* @endcode
*
* @note Using this function changes the behavior of Parser. When enabled,
* parsed content should be cached under a different key.
*/
public static function enableFeedParsing( $enable = true ) {
$prev = self::$feedParsing;
self::$feedParsing = $enable;
return $prev;
}
Replace
WikiPage::getText()
withWikiPage::getContent()->getNativeData()
inWikilogUtils.php
, sinceWikiPage::getText()
had been removedfrom
WikiPage
.Bug: T179532