summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CommentStreams/includes')
-rw-r--r--CommentStreams/includes/ApiCSBase.php11
-rw-r--r--CommentStreams/includes/ApiCSDeleteComment.php35
-rw-r--r--CommentStreams/includes/ApiCSEditComment.php34
-rw-r--r--CommentStreams/includes/ApiCSPostComment.php36
-rw-r--r--CommentStreams/includes/ApiCSQueryComment.php2
-rw-r--r--CommentStreams/includes/ApiCSUnwatch.php4
-rw-r--r--CommentStreams/includes/ApiCSVote.php8
-rw-r--r--CommentStreams/includes/ApiCSWatch.php4
-rw-r--r--CommentStreams/includes/Comment.php180
-rw-r--r--CommentStreams/includes/CommentStreams.php18
-rw-r--r--CommentStreams/includes/CommentStreamsAllComments.alias.php2
-rw-r--r--CommentStreams/includes/CommentStreamsAllComments.php23
-rw-r--r--CommentStreams/includes/CommentStreamsHooks.php81
-rw-r--r--CommentStreams/includes/CommentStreamsUtils.php6
-rw-r--r--CommentStreams/includes/EchoCSPresentationModel.php6
15 files changed, 305 insertions, 145 deletions
diff --git a/CommentStreams/includes/ApiCSBase.php b/CommentStreams/includes/ApiCSBase.php
index ac0a9991..51ec172e 100644
--- a/CommentStreams/includes/ApiCSBase.php
+++ b/CommentStreams/includes/ApiCSBase.php
@@ -21,6 +21,12 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use ApiBase;
+use ApiMessage;
+use ManualLogEntry;
+
abstract class ApiCSBase extends ApiBase {
private $edit;
@@ -44,11 +50,11 @@ abstract class ApiCSBase extends ApiBase {
$wikipage = $this->getTitleOrPageId( $params,
$this->edit ? 'frommasterdb' : 'fromdb' );
$this->comment = Comment::newFromWikiPage( $wikipage );
- if ( is_null( $this->comment ) ) {
+ if ( $this->comment === null ) {
$this->dieCustomUsageMessage( 'commentstreams-api-error-notacomment' );
}
$result = $this->executeBody();
- if ( !is_null( $result ) ) {
+ if ( $result !== null ) {
$this->getResult()->addValue( null, $this->getModuleName(), $result );
}
}
@@ -112,7 +118,6 @@ abstract class ApiCSBase extends ApiBase {
$logEntry->setTarget( $this->comment->getWikiPage()->getTitle() );
}
$logid = $logEntry->insert();
- $logEntry->publish($logid);
}
/**
diff --git a/CommentStreams/includes/ApiCSDeleteComment.php b/CommentStreams/includes/ApiCSDeleteComment.php
index 7609e2e9..345a314f 100644
--- a/CommentStreams/includes/ApiCSDeleteComment.php
+++ b/CommentStreams/includes/ApiCSDeleteComment.php
@@ -21,6 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
class ApiCSDeleteComment extends ApiCSBase {
/**
@@ -37,7 +39,8 @@ class ApiCSDeleteComment extends ApiCSBase {
* @return result of API request
*/
protected function executeBody() {
- if ( $this->getUser()->isAnon() ) {
+ $user = $this->getUser();
+ if ( $user->isAnon() ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-delete-notloggedin' );
}
@@ -50,10 +53,21 @@ class ApiCSDeleteComment extends ApiCSBase {
$action = 'cs-moderator-delete';
}
- if ( !$this->comment->getWikiPage()->getTitle()->userCan( $action,
- $this->getUser() ) ) {
- $this->dieCustomUsageMessage(
- 'commentstreams-api-error-delete-permissions' );
+ $title = $this->comment->getWikiPage()->getTitle();
+ if ( class_exists( 'MediaWiki\Permissions\PermissionManager' ) ) {
+ // MW 1.33+
+ if ( !\MediaWiki\MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userCan( $action, $user, $title )
+ ) {
+ $this->dieCustomUsageMessage(
+ 'commentstreams-api-error-delete-permissions' );
+ }
+ } else {
+ if ( !$title->userCan( $action, $user ) ) {
+ $this->dieCustomUsageMessage(
+ 'commentstreams-api-error-delete-permissions' );
+ }
}
$childCount = $this->comment->getNumReplies();
@@ -65,15 +79,15 @@ class ApiCSDeleteComment extends ApiCSBase {
'commentstreams-api-error-delete-haschildren' );
}
} else {
- $result = $this->comment->delete();
+ $result = $this->comment->delete( $user );
if ( $action === 'cs-comment' ) {
- if ( is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() === null ) {
$this->logAction( 'comment-delete' );
} else {
$this->logAction( 'reply-delete' );
}
} else {
- if ( is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() === null ) {
$this->logAction( 'comment-moderator-delete' );
} else {
$this->logAction( 'reply-moderator-delete' );
@@ -93,6 +107,7 @@ class ApiCSDeleteComment extends ApiCSBase {
* recursively delete comment and replies
*
* @param Comment $comment the comment to recursively delete
+ * @return bool
*/
private function recursiveDelete( $comment ) {
$replies = Comment::getReplies( $comment->getId() );
@@ -102,9 +117,9 @@ class ApiCSDeleteComment extends ApiCSBase {
return $result;
}
}
- $result = $comment->delete();
+ $result = $comment->delete( $this->getUser() );
$title = $comment->getWikiPage()->getTitle();
- if ( is_null( $comment->getParentId() ) ) {
+ if ( $comment->getParentId() === null ) {
$this->logAction( 'comment-moderator-delete', $title );
} else {
$this->logAction( 'reply-moderator-delete', $title );
diff --git a/CommentStreams/includes/ApiCSEditComment.php b/CommentStreams/includes/ApiCSEditComment.php
index 485553c5..c40f035c 100644
--- a/CommentStreams/includes/ApiCSEditComment.php
+++ b/CommentStreams/includes/ApiCSEditComment.php
@@ -21,6 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use ApiBase;
+
class ApiCSEditComment extends ApiCSBase {
/**
@@ -48,16 +52,28 @@ class ApiCSEditComment extends ApiCSBase {
} else {
$action = 'cs-moderator-edit';
}
- if ( !$this->comment->getWikiPage()->getTitle()->userCan( $action,
- $this->getUser() ) ) {
- $this->dieCustomUsageMessage(
- 'commentstreams-api-error-edit-permissions' );
+
+ $title = $this->comment->getWikiPage()->getTitle();
+ if ( class_exists( 'MediaWiki\Permissions\PermissionManager' ) ) {
+ // MW 1.33+
+ if ( !\MediaWiki\MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userCan( $action, $this->getUser(), $title )
+ ) {
+ $this->dieCustomUsageMessage(
+ 'commentstreams-api-error-edit-permissions' );
+ }
+ } else {
+ if ( !$title->userCan( $action, $this->getUser() ) ) {
+ $this->dieCustomUsageMessage(
+ 'commentstreams-api-error-edit-permissions' );
+ }
}
$comment_title = $this->getMain()->getVal( 'commenttitle' );
$wikitext = $this->getMain()->getVal( 'wikitext' );
- if ( is_null( $this->comment->getParentId() ) && is_null( $comment_title ) ) {
+ if ( $this->comment->getParentId() === null && $comment_title === null ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-missingcommenttitle' );
}
@@ -68,13 +84,13 @@ class ApiCSEditComment extends ApiCSBase {
}
if ( $action === 'cs-comment' ) {
- if ( is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() === null ) {
$this->logAction( 'comment-edit' );
} else {
$this->logAction( 'reply-edit' );
}
} else {
- if ( is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() === null ) {
$this->logAction( 'comment-moderator-edit' );
} else {
$this->logAction( 'reply-moderator-edit' );
@@ -83,7 +99,7 @@ class ApiCSEditComment extends ApiCSBase {
$json = $this->comment->getJSON();
- if ( is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() === null ) {
if ( $GLOBALS['wgCommentStreamsEnableVoting'] ) {
$json['vote'] = $this->comment->getVote( $this->getUser() );
}
@@ -94,7 +110,7 @@ class ApiCSEditComment extends ApiCSBase {
}
/**
- * @return array allowed paramters
+ * @return array allowed parameters
*/
public function getAllowedParams() {
return array_merge( parent::getAllowedParams(),
diff --git a/CommentStreams/includes/ApiCSPostComment.php b/CommentStreams/includes/ApiCSPostComment.php
index 925151f9..c37d6a3d 100644
--- a/CommentStreams/includes/ApiCSPostComment.php
+++ b/CommentStreams/includes/ApiCSPostComment.php
@@ -21,6 +21,15 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use ApiBase;
+use ApiMessage;
+use EchoEvent;
+use ExtensionRegistry;
+use ManualLogEntry;
+use WikiPage;
+
class ApiCSPostComment extends ApiBase {
/**
@@ -46,19 +55,19 @@ class ApiCSPostComment extends ApiBase {
$comment_title = $this->getMain()->getVal( 'commenttitle' );
$wikitext = $this->getMain()->getVal( 'wikitext' );
- if ( is_null( $parentid ) && is_null( $comment_title ) ) {
+ if ( $parentid === null && $comment_title === null ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-missingcommenttitle' );
}
- if ( !is_null( $parentid ) && !is_null( $comment_title ) ) {
+ if ( $parentid !== null && $comment_title !== null ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-post-parentandtitle' );
}
- if ( !is_null( $parentid ) ) {
+ if ( $parentid !== null ) {
$parent_page = WikiPage::newFromId( $parentid );
- if ( is_null( $parent_page ) || !$parent_page->getTitle()->exists() ) {
+ if ( $parent_page === null || !$parent_page->getTitle()->exists() ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-post-parentpagedoesnotexist' );
}
@@ -70,7 +79,7 @@ class ApiCSPostComment extends ApiBase {
}
$associated_page = WikiPage::newFromId( $associatedid );
- if ( is_null( $associated_page ) ||
+ if ( $associated_page === null ||
!$associated_page->getTitle()->exists() ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-post-associatedpagedoesnotexist' );
@@ -83,7 +92,7 @@ class ApiCSPostComment extends ApiBase {
}
$title = $comment->getWikiPage()->getTitle();
- if ( is_null( $comment->getParentId() ) ) {
+ if ( $comment->getParentId() === null ) {
$this->logAction( 'comment-create', $title );
} else {
$this->logAction( 'reply-create', $title );
@@ -91,7 +100,7 @@ class ApiCSPostComment extends ApiBase {
$json = $comment->getJSON();
if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) &&
- is_null( $comment->getParentId() )
+ $comment->getParentId() === null
) {
$json['watching'] = 1;
}
@@ -101,7 +110,7 @@ class ApiCSPostComment extends ApiBase {
}
/**
- * @return array allowed paramters
+ * @return array allowed parameters
*/
public function getAllowedParams() {
return [
@@ -144,15 +153,15 @@ class ApiCSPostComment extends ApiBase {
}
$parent_id = $comment->getParentId();
- if ( is_null( $parent_id ) ) {
+ if ( $parent_id === null ) {
$comment_title = $comment->getCommentTitle();
} else {
$parent_page = WikiPage::newFromId( $parent_id );
- if ( is_null( $parent_page ) ) {
+ if ( $parent_page === null ) {
return;
}
$parent_comment = Comment::newFromWikiPage( $parent_page );
- if ( is_null( $parent_comment ) ) {
+ if ( $parent_comment === null ) {
return;
} else {
$comment_title = $parent_comment->getCommentTitle();
@@ -163,7 +172,7 @@ class ApiCSPostComment extends ApiBase {
$associated_page->getTitle()->getPrefixedText();
if ( class_exists( 'PageProps' ) ) {
$associated_title = $associated_page->getTitle();
- $values = PageProps::getInstance()->getProperties( $associated_title,
+ $values = \PageProps::getInstance()->getProperties( $associated_title,
'displaytitle' );
if ( array_key_exists( $associated_title->getArticleID(), $values ) ) {
$associated_page_display_title =
@@ -181,7 +190,7 @@ class ApiCSPostComment extends ApiBase {
'comment_wikitext' => $comment->getWikitext()
];
- if ( !is_null( $parent_id ) ) {
+ if ( $parent_id !== null ) {
EchoEvent::create( [
'type' => 'commentstreams-reply-on-watched-page',
'title' => $associated_page->getTitle(),
@@ -215,7 +224,6 @@ class ApiCSPostComment extends ApiBase {
$logEntry->setPerformer( $this->getUser() );
$logEntry->setTarget( $title );
$logid = $logEntry->insert();
- $logEntry->publish($logid);
}
/**
diff --git a/CommentStreams/includes/ApiCSQueryComment.php b/CommentStreams/includes/ApiCSQueryComment.php
index d0d290fb..a27196ee 100644
--- a/CommentStreams/includes/ApiCSQueryComment.php
+++ b/CommentStreams/includes/ApiCSQueryComment.php
@@ -21,6 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
class ApiCSQueryComment extends ApiCSBase {
/**
diff --git a/CommentStreams/includes/ApiCSUnwatch.php b/CommentStreams/includes/ApiCSUnwatch.php
index 85d746e3..27251f97 100644
--- a/CommentStreams/includes/ApiCSUnwatch.php
+++ b/CommentStreams/includes/ApiCSUnwatch.php
@@ -21,6 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
class ApiCSUnwatch extends ApiCSBase {
/**
@@ -42,7 +44,7 @@ class ApiCSUnwatch extends ApiCSBase {
'commentstreams-api-error-unwatch-notloggedin' );
}
- if ( !is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() !== null ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-unwatch-nounwatchonreply' );
}
diff --git a/CommentStreams/includes/ApiCSVote.php b/CommentStreams/includes/ApiCSVote.php
index e93021f1..3e92c346 100644
--- a/CommentStreams/includes/ApiCSVote.php
+++ b/CommentStreams/includes/ApiCSVote.php
@@ -21,6 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use ApiBase;
+
class ApiCSVote extends ApiCSBase {
/**
@@ -44,7 +48,7 @@ class ApiCSVote extends ApiCSBase {
$vote = $this->getMain()->getVal( 'vote' );
- if ( !is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() !== null ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-vote-novoteonreply' );
}
@@ -58,7 +62,7 @@ class ApiCSVote extends ApiCSBase {
}
/**
- * @return array allowed paramters
+ * @return array allowed parameters
*/
public function getAllowedParams() {
return array_merge( parent::getAllowedParams(),
diff --git a/CommentStreams/includes/ApiCSWatch.php b/CommentStreams/includes/ApiCSWatch.php
index a1a67072..8c4e9e8c 100644
--- a/CommentStreams/includes/ApiCSWatch.php
+++ b/CommentStreams/includes/ApiCSWatch.php
@@ -21,6 +21,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
class ApiCSWatch extends ApiCSBase {
/**
@@ -42,7 +44,7 @@ class ApiCSWatch extends ApiCSBase {
'commentstreams-api-error-watch-notloggedin' );
}
- if ( !is_null( $this->comment->getParentId() ) ) {
+ if ( $this->comment->getParentId() !== null ) {
$this->dieCustomUsageMessage(
'commentstreams-api-error-watch-nowatchonreply' );
}
diff --git a/CommentStreams/includes/Comment.php b/CommentStreams/includes/Comment.php
index 27a8300c..755c24c3 100644
--- a/CommentStreams/includes/Comment.php
+++ b/CommentStreams/includes/Comment.php
@@ -21,6 +21,21 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use Html;
+use MediaWiki\MediaWikiServices;
+use MWTimestamp;
+use Parser;
+use ParserOptions;
+use SMWDataItem;
+use SMWUpdateJob;
+use Title;
+use User;
+use wAvatar;
+use WikiPage;
+use WikitextContent;
+
class Comment {
// wiki page object for this comment wiki page
@@ -73,7 +88,7 @@ class Comment {
* error
*/
public static function newFromWikiPage( $wikipage ) {
- if ( !is_null( $wikipage ) &&
+ if ( $wikipage !== null &&
$wikipage->getTitle()->getNamespace() === NS_COMMENTSTREAMS ) {
$comment = new Comment( $wikipage );
if ( $wikipage->exists() ) {
@@ -100,10 +115,10 @@ class Comment {
*/
public static function newFromValues( $assoc_page_id, $parent_page_id,
$comment_title, $wikitext, $user ) {
- if ( is_null( $comment_title ) && is_null( $parent_page_id ) ) {
+ if ( $comment_title === null && $parent_page_id === null ) {
return null;
}
- if ( !is_null( $comment_title ) && !is_null( $parent_page_id ) ) {
+ if ( $comment_title !== null && $parent_page_id !== null ) {
return null;
}
$annotated_wikitext = self::addAnnotations( $wikitext, $comment_title,
@@ -114,9 +129,20 @@ class Comment {
$index = wfRandomString();
$title = Title::newFromText( (string)$index, NS_COMMENTSTREAMS );
if ( !$title->isDeletedQuick() && !$title->exists() ) {
- if ( !$title->userCan( 'cs-comment' ) ) {
- return null;
+ if ( class_exists( 'MediaWiki\Permissions\PermissionManager' ) ) {
+ // MW 1.33+
+ if ( !MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userCan( 'cs-comment', $user, $title )
+ ) {
+ return null;
+ }
+ } else {
+ if ( !$title->userCan( 'cs-comment' ) ) {
+ return null;
+ }
}
+
$wikipage = new WikiPage( $title );
$status = $wikipage->doEditContent( $content, '',
EDIT_NEW | EDIT_SUPPRESS_RC, false, $user, null );
@@ -152,15 +178,15 @@ class Comment {
}
$comment->loadFromValues( $assoc_page_id, $parent_page_id, $comment_title );
- if ( is_null( $parent_page_id ) ) {
+ if ( $parent_page_id === null ) {
$comment->watch( $user );
} else {
self::watchComment( $parent_page_id, $user );
}
if ( defined( 'SMW_VERSION' ) ) {
- $job = new SMWUpdateJob( $title );
- JobQueueGroup::singleton()->push( $job );
+ $job = new SMWUpdateJob( $title, [] );
+ \JobQueueGroup::singleton()->push( $job );
}
return $comment;
@@ -195,7 +221,7 @@ class Comment {
if ( $result ) {
$this->assoc_page_id = (int)$result->cst_assoc_page_id;
$this->parent_page_id = $result->cst_parent_page_id;
- if ( !is_null( $this->parent_page_id ) ) {
+ if ( $this->parent_page_id !== null ) {
$this->parent_page_id = (int)$this->parent_page_id;
}
$this->comment_title = $result->cst_comment_title;
@@ -215,7 +241,7 @@ class Comment {
$comment_title ) {
$this->assoc_page_id = (int)$assoc_page_id;
$this->parent_page_id = $parent_page_id;
- if ( !is_null( $this->parent_page_id ) ) {
+ if ( $this->parent_page_id !== null ) {
$this->parent_page_id = (int)$this->parent_page_id;
}
$this->comment_title = $comment_title;
@@ -271,9 +297,9 @@ class Comment {
* @return string wikitext of the comment
*/
public function getWikiText() {
- if ( is_null( $this->wikitext ) ) {
- $wikitext = ContentHandler::getContentText( $this->wikipage->getContent(
- Revision::RAW ) );
+ if ( $this->wikitext === null ) {
+ $wikitext = \ContentHandler::getContentText( $this->wikipage->getContent(
+ \Revision::RAW ) );
$wikitext = $this->removeAnnotations( $wikitext );
$this->wikitext = $wikitext;
}
@@ -284,10 +310,16 @@ class Comment {
* @return string parsed HTML of the comment
*/
public function getHTML() {
- if ( is_null( $this->html ) ) {
+ if ( $this->html === null ) {
$this->getWikiText();
- if ( !is_null( $this->wikitext ) ) {
- $parser = new Parser;
+ if ( $this->wikitext !== null ) {
+ if ( class_exists( \ParserFactory::class ) ) {
+ // @requires MediaWiki >= 1.32.0
+ $parser = MediaWikiServices::getInstance()->getParserFactory()->create();
+ } else {
+ $parser = new Parser();
+ }
+
$this->html = $parser->parse( $this->wikitext,
$this->wikipage->getTitle(), new ParserOptions )->getText();
}
@@ -299,7 +331,7 @@ class Comment {
* @return User the author of this comment
*/
public function getUser() {
- if ( is_null( $this->user ) ) {
+ if ( $this->user === null ) {
$user_id = $this->wikipage->getOldestRevision()->getUser();
$this->user = User::newFromId( $user_id );
}
@@ -342,7 +374,7 @@ class Comment {
* @return string the URL of the avatar of the author of this comment
*/
public function getAvatar() {
- if ( is_null( $this->avatar ) ) {
+ if ( $this->avatar === null ) {
if ( class_exists( 'wAvatar' ) ) {
// from Extension:SocialProfile
$avatar = new wAvatar( $this->getUser()->getId(), 'l' );
@@ -359,7 +391,7 @@ class Comment {
* @return MWTimestamp the earliest revision date for this
*/
public function getCreationTimestamp() {
- if ( is_null( $this->creation_timestamp ) ) {
+ if ( $this->creation_timestamp === null ) {
$this->creation_timestamp = MWTimestamp::getLocalInstance(
$this->wikipage->getTitle()->getEarliestRevTime() );
}
@@ -370,11 +402,7 @@ class Comment {
* @return MWTimestamp the earliest revision date for this
*/
public function getCreationDate() {
- if ( !is_null( $this->getCreationTimestamp() ) ) {
- $user = RequestContext::getMain()->getUser();
- if ($user && !$user->isAnon()) {
- $this->creation_timestamp->offsetForUser($user);
- }
+ if ( $this->getCreationTimestamp() !== null ) {
return $this->creation_timestamp->format( "M j \a\\t g:i a" );
}
return "";
@@ -384,13 +412,20 @@ class Comment {
* @return MWTimestamp the latest revision date for this
*/
public function getModificationTimestamp() {
- if ( is_null( $this->modification_timestamp ) ) {
+ if ( $this->modification_timestamp === null ) {
$title = $this->wikipage->getTitle();
if ( $title->getFirstRevision()->getId() === $title->getLatestRevID() ) {
return null;
}
- $timestamp = Revision::getTimestampFromId( $title,
- $title->getLatestRevID() );
+
+ $revStore = MediaWikiServices::getInstance()->getRevisionStore();
+ $latestRev = $title->getLatestRevId();
+ if ( version_compare( MW_VERSION, '1.34', '<' ) ) {
+ $timestamp = $revStore->getTimestampFromId( $title, $latestRev );
+ } else {
+ $timestamp = $revStore->getTimestampFromId( $latestRev );
+ }
+
$this->modification_timestamp = MWTimestamp::getLocalInstance(
$timestamp );
}
@@ -401,11 +436,7 @@ class Comment {
* @return MWTimestamp the earliest revision date for this
*/
public function getModificationDate() {
- if ( !is_null( $this->getModificationTimestamp() ) ) {
- $user = RequestContext::getMain()->getUser();
- if ($user && !$user->isAnon()) {
- $this->modification_timestamp->offsetForUser($user);
- }
+ if ( $this->getModificationTimestamp() !== null ) {
return $this->modification_timestamp->format( "M j \a\\t g:i a" );
}
return null;
@@ -415,7 +446,7 @@ class Comment {
* @return int number of replies
*/
public function getNumReplies() {
- if ( is_null( $this->num_replies ) ) {
+ if ( $this->num_replies === null ) {
$dbr = wfGetDB( DB_REPLICA );
$this->num_replies = $dbr->selectRowCount(
'cs_comment_data',
@@ -491,7 +522,7 @@ class Comment {
* @return int number of up votes
*/
public function getNumUpVotes() {
- if ( is_null( $this->num_up_votes ) ) {
+ if ( $this->num_up_votes === null ) {
$dbr = wfGetDB( DB_REPLICA );
$this->num_up_votes = $dbr->selectRowCount(
'cs_votes',
@@ -510,7 +541,7 @@ class Comment {
* @return int number of down votes
*/
public function getNumDownVotes() {
- if ( is_null( $this->num_down_votes ) ) {
+ if ( $this->num_down_votes === null ) {
$dbr = wfGetDB( DB_REPLICA );
$this->num_down_votes = $dbr->selectRowCount(
'cs_votes',
@@ -530,7 +561,7 @@ class Comment {
*
* @param string $vote 1 for up vote, -1 for down vote, 0 for no vote
* @param User $user the user voting on the comment
- * @return database status code
+ * @return bool database status code
*/
public function vote( $vote, $user ) {
if ( $vote !== "-1" && $vote !== "0" && $vote !== "1" ) {
@@ -599,7 +630,7 @@ class Comment {
* watch a comment (get page ID from this comment)
*
* @param User $user the user watching the comment
- * @return database true for OK, false for error
+ * @return bool database true for OK, false for error
*/
public function watch( $user ) {
return self::watchComment( $this->getID(), $user );
@@ -608,9 +639,9 @@ class Comment {
/**
* watch a comment (get page ID from parameter)
*
- * @param $pageid the page ID of the comment to watch
+ * @param int $pageid the page ID of the comment to watch
* @param User $user the user watching the comment
- * @return database true for OK, false for error
+ * @return bool database true for OK, false for error
*/
private static function watchComment( $pageid, $user ) {
if ( self::isWatchingComment( $pageid, $user ) ) {
@@ -632,7 +663,7 @@ class Comment {
* unwatch a comment
*
* @param User $user the user unwatching the comment
- * @return database true for OK, false for error
+ * @return bool database true for OK, false for error
*/
public function unwatch( $user ) {
if ( !$this->isWatching( $user ) ) {
@@ -654,7 +685,7 @@ class Comment {
* Check if a particular user is watching this comment
*
* @param User $user the user watching the comment
- * @return database true for OK, false for error
+ * @return bool database true for OK, false for error
*/
public function isWatching( $user ) {
return self::isWatchingComment( $this->getId(), $user );
@@ -663,9 +694,9 @@ class Comment {
/**
* Check if a particular user is watching a comment
*
- * @param $pageid the page ID of the comment to check
+ * @param int $pageid the page ID of the comment to check
* @param User $user the user watching the comment
- * @return database true for OK, false for error
+ * @return bool database true for OK, false for error
*/
private static function isWatchingComment( $pageid, $user ) {
$dbr = wfGetDB( DB_REPLICA );
@@ -724,10 +755,10 @@ class Comment {
* @return bool true if successful
*/
public function update( $comment_title, $wikitext, $user ) {
- if ( is_null( $comment_title ) && is_null( $this->getParentId() ) ) {
+ if ( $comment_title === null && $this->getParentId() === null ) {
return false;
}
- if ( !is_null( $comment_title ) && !is_null( $this->getParentId() ) ) {
+ if ( $comment_title !== null && $this->getParentId() !== null ) {
return false;
}
$annotated_wikitext =
@@ -765,17 +796,28 @@ class Comment {
/**
* delete comment from database
*
+ * @param User $deleter
* @return bool true if successful
*/
- public function delete() {
- $pageid = $this->getId();
+ public function delete( User $deleter ) {
+ if ( version_compare( MW_VERSION, '1.35', '<' ) ) {
+ $status = $this->getWikiPage()->doDeleteArticleReal(
+ 'comment deleted',
+ true
+ );
+ } else {
+ $status = $this->getWikiPage()->doDeleteArticleReal(
+ 'comment deleted',
+ $deleter,
+ true
+ );
+ }
- $status = $this->getWikiPage()->doDeleteArticleReal( 'comment deleted',
- true, 0 );
if ( !$status->isOK() && !$status->isGood() ) {
return false;
}
+ $pageid = $this->getId();
$dbw = wfGetDB( DB_MASTER );
$result = $dbw->delete(
'cs_comment_data',
@@ -797,7 +839,7 @@ class Comment {
*/
public static function addAnnotations( $wikitext, $comment_title,
$assoc_page_id ) {
- if ( !is_null( $comment_title ) ) {
+ if ( $comment_title !== null ) {
$wikitext .= <<<EOT
{{DISPLAYTITLE:
$comment_title
@@ -815,7 +857,7 @@ EOT;
*/
public function removeAnnotations( $wikitext ) {
$comment_title = $this->getCommentTitle();
- if ( !is_null( $comment_title ) ) {
+ if ( $comment_title !== null ) {
$strip = <<<EOT
{{DISPLAYTITLE:
$comment_title
@@ -849,7 +891,7 @@ EOT;
$page_id = $row->cst_page_id;
$wikipage = WikiPage::newFromId( $page_id );
$comment = self::newFromWikiPage( $wikipage );
- if ( !is_null( $comment ) ) {
+ if ( $comment !== null ) {
$comments[] = $comment;
}
}
@@ -879,7 +921,7 @@ EOT;
$page_id = $row->cst_page_id;
$wikipage = WikiPage::newFromId( $page_id );
$comment = self::newFromWikiPage( $wikipage );
- if ( !is_null( $comment ) ) {
+ if ( $comment !== null ) {
$comments[] = $comment;
}
}
@@ -905,23 +947,23 @@ EOT;
}
$userpage = $user->getUserPage();
$displayname = null;
- if ( !is_null( $GLOBALS['wgCommentStreamsUserRealNamePropertyName'] ) ) {
+ if ( $GLOBALS['wgCommentStreamsUserRealNamePropertyName'] !== null ) {
$displayname = self::getUserProperty( $user,
$GLOBALS['wgCommentStreamsUserRealNamePropertyName'] );
}
- if ( is_null( $displayname ) || strlen( $displayname ) == 0 ) {
+ if ( $displayname === null || strlen( $displayname ) == 0 ) {
if ( class_exists( 'PageProps' ) ) {
- $values = PageProps::getInstance()->getProperties( $userpage,
+ $values = \PageProps::getInstance()->getProperties( $userpage,
'displaytitle' );
if ( array_key_exists( $userpage->getArticleID(), $values ) ) {
$displayname = $values[$userpage->getArticleID()];
}
}
}
- if ( is_null( $displayname ) || strlen( $displayname ) == 0 ) {
+ if ( $displayname === null || strlen( $displayname ) == 0 ) {
$displayname = $user->getRealName();
}
- if ( is_null( $displayname ) || strlen( $displayname ) == 0 ) {
+ if ( $displayname === null || strlen( $displayname ) == 0 ) {
$displayname = $user->getName();
}
if ( $linked && $userpage->exists() ) {
@@ -938,13 +980,13 @@ EOT;
*/
public static function getAvatarFromUser( $user ) {
$avatar = null;
- if ( !is_null( $GLOBALS['wgCommentStreamsUserAvatarPropertyName'] ) ) {
+ if ( $GLOBALS['wgCommentStreamsUserAvatarPropertyName'] !== null ) {
$avatar = self::getUserProperty( $user,
$GLOBALS['wgCommentStreamsUserAvatarPropertyName'] );
- if ( !is_null( $avatar ) ) {
+ if ( $avatar !== null ) {
if ( gettype( $avatar ) === 'string' ) {
$avatar = Title::newFromText( $avatar );
- if ( is_null( $avatar ) ) {
+ if ( $avatar === null ) {
return null;
}
}
@@ -952,7 +994,13 @@ EOT;
return null;
}
if ( $avatar->isKnown() && $avatar->getNamespace() === NS_FILE ) {
- $file = wfFindFile( $avatar );
+ if ( method_exists( MediaWikiServices::class, 'getRepoGroup' ) ) {
+ // MediaWiki 1.34+
+ $file = MediaWikiServices::getInstance()->getRepoGroup()
+ ->findFile( $avatar );
+ } else {
+ $file = wfFindFile( $avatar );
+ }
if ( $file ) {
return $file->getFullUrl();
}
@@ -974,9 +1022,9 @@ EOT;
$userpage = $user->getUserPage();
if ( $userpage->exists() ) {
$store = \SMW\StoreFactory::getStore();
- $subject = SMWDIWikiPage::newFromTitle( $userpage );
+ $subject = \SMWDIWikiPage::newFromTitle( $userpage );
$data = $store->getSemanticData( $subject );
- $property = SMWDIProperty::newFromUserLabel( $propertyName );
+ $property = \SMWDIProperty::newFromUserLabel( $propertyName );
$values = $data->getPropertyValues( $property );
if ( count( $values ) > 0 ) {
// this property should only have one value so pick the first one
@@ -1002,9 +1050,9 @@ EOT;
public static function locateUsersWatchingComment( $event ) {
$id = $event->getExtraParam( 'parent_id' );
$wikipage = WikiPage::newFromId( $id );
- if ( !is_null( $wikipage ) ) {
+ if ( $wikipage !== null ) {
$comment = self::newFromWikiPage( $wikipage );
- if ( !is_null( $comment ) ) {
+ if ( $comment !== null ) {
return $comment->getWatchers();
}
}
diff --git a/CommentStreams/includes/CommentStreams.php b/CommentStreams/includes/CommentStreams.php
index fba47e54..d7426969 100644
--- a/CommentStreams/includes/CommentStreams.php
+++ b/CommentStreams/includes/CommentStreams.php
@@ -21,6 +21,11 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use ExtensionRegistry;
+use MWNamespace;
+
class CommentStreams {
// CommentStreams singleton instance
@@ -39,7 +44,7 @@ class CommentStreams {
* @return CommentStreams a singleton CommentStreams instance
*/
public static function singleton() {
- if ( is_null( self::$instance ) ) {
+ if ( self::$instance === null ) {
self::$instance = new CommentStreams();
}
return self::$instance;
@@ -86,7 +91,7 @@ class CommentStreams {
* checks to see if comments should be displayed on this page
*
* @param OutputPage $output the OutputPage object
- * @return boolean true if comments should be displayed on this page
+ * @return bool true if comments should be displayed on this page
*/
private function checkDisplayComments( $output ) {
// don't display comments on this page if they are explicitly disabled
@@ -95,14 +100,14 @@ class CommentStreams {
}
// don't display comments on any page action other than view action
- if ( Action::getActionName( $output->getContext() ) !== "view" ) {
+ if ( \Action::getActionName( $output->getContext() ) !== "view" ) {
return false;
}
// if $wgCommentStreamsAllowedNamespaces is not set, display comments
// in all content namespaces
$csAllowedNamespaces = $GLOBALS['wgCommentStreamsAllowedNamespaces'];
- if ( is_null( $csAllowedNamespaces ) ) {
+ if ( $csAllowedNamespaces === null ) {
$csAllowedNamespaces = $GLOBALS['wgContentNamespaces'];
} elseif ( !is_array( $csAllowedNamespaces ) ) {
$csAllowedNamespaces = [ $csAllowedNamespaces ];
@@ -246,14 +251,15 @@ class CommentStreams {
* return all discussions (top level comments) in an array of comments
*
* @param array $allComments an array of all comments on a page
- * @param boolean $newestOnTop true if array should be sorted from newest to
+ * @param bool $newestOnTop true if array should be sorted from newest to
+ * @param bool $enableVoting
* @return array an array of all discussions
* oldest
*/
private function getDiscussions( $allComments, $newestOnTop, $enableVoting ) {
$array = array_filter(
$allComments, function ( $comment ) {
- return is_null( $comment->getParentId() );
+ return $comment->getParentId() === null;
}
);
usort( $array, function ( $comment1, $comment2 ) use ( $newestOnTop, $enableVoting ) {
diff --git a/CommentStreams/includes/CommentStreamsAllComments.alias.php b/CommentStreams/includes/CommentStreamsAllComments.alias.php
index 7a213537..841defd1 100644
--- a/CommentStreams/includes/CommentStreamsAllComments.alias.php
+++ b/CommentStreams/includes/CommentStreamsAllComments.alias.php
@@ -34,7 +34,7 @@ $specialPageAliases['he'] = [
'CommentStreamsAllComments' => [ 'כל_התגובות' ]
];
-/** Serbian Cyrilic (српски (ћирлица)) */
+/** Serbian Cyrillic (српски (ћирлица)) */
$specialPageAliases['sr-ec'] = [
'CommentStreamsAllComments' => [ 'Сви_коментари' ]
];
diff --git a/CommentStreams/includes/CommentStreamsAllComments.php b/CommentStreams/includes/CommentStreamsAllComments.php
index 52eea7b1..c11810e7 100644
--- a/CommentStreams/includes/CommentStreamsAllComments.php
+++ b/CommentStreams/includes/CommentStreamsAllComments.php
@@ -22,6 +22,13 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use Html;
+use SpecialPage;
+use Title;
+use WikiPage;
+
class CommentStreamsAllComments extends SpecialPage {
public function __construct() {
@@ -75,11 +82,11 @@ class CommentStreamsAllComments extends SpecialPage {
if ( $index < $limit ) {
$wikipage = WikiPage::newFromId( $page->page_id );
$comment = Comment::newFromWikiPage( $wikipage );
- if ( !is_null( $comment ) ) {
+ if ( $comment !== null ) {
$pagename = $comment->getWikiPage()->getTitle()->getPrefixedText();
$associatedpageid = $comment->getAssociatedId();
$associatedpage = WikiPage::newFromId( $associatedpageid );
- if ( !is_null( $associatedpage ) ) {
+ if ( $associatedpage !== null ) {
$associatedpagename =
'[[' . $associatedpage->getTitle()->getPrefixedText() . ']]';
$author = $comment->getUser();
@@ -90,11 +97,11 @@ class CommentStreamsAllComments extends SpecialPage {
$author = $author->getName();
}
$modificationdate = $comment->getModificationDate();
- if ( is_null( $modificationdate ) ) {
+ if ( $modificationdate === null ) {
$lasteditor = '';
} else {
$lasteditor =
- User::newFromId( $wikipage->getRevision()->getUser() );
+ \User::newFromId( $wikipage->getRevision()->getUser() );
if ( $lasteditor->isAnon() ) {
$lasteditor = '<i>' .
wfMessage( 'commentstreams-author-anonymous' ) . '</i>';
@@ -111,7 +118,7 @@ class CommentStreamsAllComments extends SpecialPage {
$wikitext .= '| ' . $lasteditor . PHP_EOL;
$wikitext .= '| ' . $comment->getCreationDate() . PHP_EOL;
$wikitext .= '| ' . $modificationdate . PHP_EOL;
- $index ++;
+ $index++;
}
}
} else {
@@ -120,7 +127,11 @@ class CommentStreamsAllComments extends SpecialPage {
}
$wikitext .= '|}' . PHP_EOL;
- $this->getOutput()->addWikiText( $wikitext );
+ if ( method_exists( 'OutputPage', 'addWikiTextAsInterface' ) ) {
+ $this->getOutput()->addWikiTextAsInterface( $wikitext );
+ } else {
+ $this->getOutput()->addWikiText( $wikitext );
+ }
if ( $offset > 0 || $more ) {
$this->addTableNavigation( $offset, $more, $limit, 'offset' );
diff --git a/CommentStreams/includes/CommentStreamsHooks.php b/CommentStreams/includes/CommentStreamsHooks.php
index 6bfcf99a..38afb6d3 100644
--- a/CommentStreams/includes/CommentStreamsHooks.php
+++ b/CommentStreams/includes/CommentStreamsHooks.php
@@ -21,6 +21,24 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use Article;
+use DatabaseUpdater;
+use MediaWiki;
+use OutputPage;
+use Parser;
+use PPFrame;
+use SearchResult;
+use Skin;
+use SMW\DIWikiPage;
+use SpecialSearch;
+use Status;
+use Title;
+use User;
+use WebRequest;
+use WikiPage;
+
class CommentStreamsHooks {
/**
@@ -92,16 +110,16 @@ class CommentStreamsHooks {
}
$wikipage = new WikiPage( $title );
$comment = Comment::newFromWikiPage( $wikipage );
- if ( !is_null( $comment ) ) {
+ if ( $comment !== null ) {
$commentTitle = $comment->getCommentTitle();
- if ( !is_null( $commentTitle ) ) {
+ if ( $commentTitle !== null ) {
$output->setPageTitle( $commentTitle );
}
$associatedTitle = Title::newFromId( $comment->getAssociatedId() );
- if ( !is_null( $associatedTitle ) ) {
+ if ( $associatedTitle !== null ) {
$values = [];
if ( class_exists( 'PageProps' ) ) {
- $values = PageProps::getInstance()->getProperties( $associatedTitle,
+ $values = \PageProps::getInstance()->getProperties( $associatedTitle,
'displaytitle' );
}
if ( array_key_exists( $comment->getAssociatedId(), $values ) ) {
@@ -117,7 +135,11 @@ class CommentStreamsHooks {
wfMessage( 'commentstreams-error-comment-on-deleted-page' )->text();
$output->addHTML( '<p class="error">' . $message . '</p>' );
}
- $output->addWikitext( $comment->getHTML() );
+ if ( method_exists( 'OutputPage', 'addWikiTextAsInterface' ) ) {
+ $output->addWikiTextAsInterface( $comment->getHTML() );
+ } else {
+ $output->addWikiText( $comment->getHTML() );
+ }
}
return false;
}
@@ -213,11 +235,11 @@ class CommentStreamsHooks {
*/
public static function onParserSetup( Parser $parser ) {
$parser->setHook( 'comment-streams',
- 'CommentStreamsHooks::enableCommentStreams' );
+ 'MediaWiki\Extension\CommentStreams\CommentStreamsHooks::enableCommentStreams' );
$parser->setHook( 'no-comment-streams',
- 'CommentStreamsHooks::disableCommentStreams' );
+ 'MediaWiki\Extension\CommentStreams\CommentStreamsHooks::disableCommentStreams' );
$parser->setHook( 'comment-streams-initially-collapsed',
- 'CommentStreamsHooks::initiallyCollapseCommentStreams' );
+ 'MediaWiki\Extension\CommentStreams\CommentStreamsHooks::initiallyCollapseCommentStreams' );
return true;
}
@@ -233,7 +255,7 @@ class CommentStreamsHooks {
*/
public static function enableCommentStreams( $input, array $args,
Parser $parser, PPFrame $frame ) {
- $parser->disableCache();
+ $parser->getOutput()->updateCacheExpiry( 0 );
$cs = CommentStreams::singleton();
$cs->enableCommentsOnPage();
if ( isset( $args['location'] ) && $args['location'] === 'footer' ) {
@@ -256,7 +278,7 @@ class CommentStreamsHooks {
*/
public static function disableCommentStreams( $input, array $args,
Parser $parser, PPFrame $frame ) {
- $parser->disableCache();
+ $parser->getOutput()->updateCacheExpiry( 0 );
$cs = CommentStreams::singleton();
$cs->disableCommentsOnPage();
return "";
@@ -274,7 +296,7 @@ class CommentStreamsHooks {
*/
public static function initiallyCollapseCommentStreams( $input, array $args,
Parser $parser, PPFrame $frame ) {
- $parser->disableCache();
+ $parser->getOutput()->updateCacheExpiry( 0 );
$cs = CommentStreams::singleton();
$cs->initiallyCollapseCommentsOnPage();
return "";
@@ -312,9 +334,9 @@ class CommentStreamsHooks {
public static function showSearchHitTitle( Title &$title, &$text,
SearchResult $result, array $terms, SpecialSearch $page ) {
$comment = Comment::newFromWikiPage( WikiPage::factory( $title ) );
- if ( !is_null( $comment ) ) {
+ if ( $comment !== null ) {
$t = Title::newFromId( $comment->getAssociatedId() );
- if ( !is_null( $t ) ) {
+ if ( $t !== null ) {
$title = $t;
}
}
@@ -322,9 +344,21 @@ class CommentStreamsHooks {
}
/**
+ * Implements SMW::Settings::BeforeInitializationComplete callback.
+ * See https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks/hook.settings.beforeinitializationcomplete.md
+ * Defines CommentStreams namespace constants.
+ *
+ * @param array &$configuration An array of the configuration options
+ */
+ public static function onSMWInitialization( array &$configuration ) {
+ $namespace = $GLOBALS['wgCommentStreamsNamespaceIndex'];
+ $configuration['smwgNamespacesWithSemanticLinks'][$namespace] = true;
+ }
+
+ /**
* Implements extension registration callback.
* See https://www.mediawiki.org/wiki/Manual:Extension_registration#Customizing_registration
- * Defines CommentStreams namespace constants.
+ * Sets configuration constants.
*
*/
public static function onRegistration() {
@@ -332,7 +366,6 @@ class CommentStreamsHooks {
define( 'NS_COMMENTSTREAMS_TALK',
$GLOBALS['wgCommentStreamsNamespaceIndex'] + 1 );
$GLOBALS['wgNamespacesToBeSearchedDefault'][NS_COMMENTSTREAMS] = true;
- $GLOBALS['smwgNamespacesWithSemanticLinks'][NS_COMMENTSTREAMS] = true;
$found = false;
foreach ( $GLOBALS['wgGroupPermissions'] as $groupperms ) {
if ( isset( $groupperms['cs-comment'] ) ) {
@@ -392,40 +425,40 @@ class CommentStreamsHooks {
*/
public static function updateData( $store, $semanticData ) {
$subject = $semanticData->getSubject();
- if ( !is_null( $subject ) && !is_null( $subject->getTitle() ) &&
+ if ( $subject !== null && $subject->getTitle() !== null &&
$subject->getTitle()->getNamespace() === NS_COMMENTSTREAMS ) {
$page_id = $subject->getTitle()->getArticleID( Title::GAID_FOR_UPDATE );
$wikipage = WikiPage::newFromId( $page_id );
$comment = Comment::newFromWikiPage( $wikipage );
- if ( is_null( $comment ) ) {
+ if ( $comment === null ) {
return true;
}
$assoc_page_id = $comment->getAssociatedId();
- if ( !is_null( $assoc_page_id ) ) {
+ if ( $assoc_page_id !== null ) {
$assoc_wikipage = WikiPage::newFromId( $assoc_page_id );
- if ( !is_null( $assoc_wikipage ) ) {
+ if ( $assoc_wikipage !== null ) {
$propertyDI = new SMW\DIProperty( '___CS_ASSOCPG' );
$dataItem =
- SMW\DIWikiPage::newFromTitle( $assoc_wikipage->getTitle() );
+ DIWikiPage::newFromTitle( $assoc_wikipage->getTitle() );
$semanticData->addPropertyObjectValue( $propertyDI, $dataItem );
}
}
$parent_page_id = $comment->getParentId();
- if ( !is_null( $parent_page_id ) ) {
+ if ( $parent_page_id !== null ) {
$parent_wikipage = WikiPage::newFromId( $parent_page_id );
- if ( !is_null( $parent_wikipage ) ) {
+ if ( $parent_wikipage !== null ) {
$propertyDI = new SMW\DIProperty( '___CS_REPLYTO' );
$dataItem =
- SMW\DIWikiPage::newFromTitle( $parent_wikipage->getTitle() );
+ DIWikiPage::newFromTitle( $parent_wikipage->getTitle() );
$semanticData->addPropertyObjectValue( $propertyDI, $dataItem );
}
}
$commentTitle = $comment->getCommentTitle();
- if ( !is_null( $commentTitle ) ) {
+ if ( $commentTitle !== null ) {
$propertyDI = new SMW\DIProperty( '___CS_TITLE' );
$dataItem = new SMWDIBlob( $comment->getCommentTitle() );
$semanticData->addPropertyObjectValue( $propertyDI, $dataItem );
diff --git a/CommentStreams/includes/CommentStreamsUtils.php b/CommentStreams/includes/CommentStreamsUtils.php
index 10d3446e..1e09303c 100644
--- a/CommentStreams/includes/CommentStreamsUtils.php
+++ b/CommentStreams/includes/CommentStreamsUtils.php
@@ -19,7 +19,11 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use Linker;
use MediaWiki\MediaWikiServices;
+use Title;
class CommentStreamsUtils {
@@ -33,7 +37,7 @@ class CommentStreamsUtils {
if ( method_exists( 'MediaWikiServices', 'getLinkRenderer' ) ) {
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
return $linkRenderer->makeLink( $title, $display );
- };
+ }
return Linker::link( $title, $display );
}
}
diff --git a/CommentStreams/includes/EchoCSPresentationModel.php b/CommentStreams/includes/EchoCSPresentationModel.php
index bc6786cf..3dba5cc9 100644
--- a/CommentStreams/includes/EchoCSPresentationModel.php
+++ b/CommentStreams/includes/EchoCSPresentationModel.php
@@ -21,6 +21,10 @@
* DEALINGS IN THE SOFTWARE.
*/
+namespace MediaWiki\Extension\CommentStreams;
+
+use EchoEventPresentationModel;
+
class EchoCSPresentationModel extends EchoEventPresentationModel {
/**
@@ -81,6 +85,6 @@ class EchoCSPresentationModel extends EchoEventPresentationModel {
* @inheritDoc
*/
public function canRender() {
- return !is_null( $this->event->getTitle() );
+ return $this->event->getTitle() !== null;
}
}