Unsuppress phan issues, part 8
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 173fdc6..9c5c4e0 100644 (file)
@@ -41,6 +41,8 @@ use Wikimedia\Rdbms\LoadBalancer;
  *
  * Some fields are public only for backwards-compatibility. Use accessors.
  * In the past, this class was part of Article.php and everything was public.
+ *
+ * @phan-file-suppress PhanAccessMethodInternal Due to the use of DerivedPageDataUpdater
  */
 class WikiPage implements Page, IDBAccessObject {
        // Constants for $mDataLoadedFrom and related
@@ -68,7 +70,9 @@ class WikiPage implements Page, IDBAccessObject {
         */
        public $mLatest = false;
 
-       /** @var PreparedEdit Map of cache fields (text, parser output, ect) for a proposed/new edit */
+       /**
+        * @var PreparedEdit|false Map of cache fields (text, parser output, ect) for a proposed/new edit
+        */
        public $mPreparedEdit = false;
 
        /**
@@ -1063,6 +1067,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Insert or update the redirect table entry for this page to indicate it redirects to $rt
         * @param Title $rt Redirect target
         * @param int|null $oldLatest Prior page_latest for check and set
+        * @return bool Success
         */
        public function insertRedirectEntry( Title $rt, $oldLatest = null ) {
                $dbw = wfGetDB( DB_MASTER );
@@ -1089,9 +1094,14 @@ class WikiPage implements Page, IDBAccessObject {
                                ],
                                __METHOD__
                        );
+                       $success = true;
+               } else {
+                       $success = false;
                }
 
                $dbw->endAtomic( __METHOD__ );
+
+               return $success;
        }
 
        /**
@@ -1461,18 +1471,19 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                if ( $isRedirect ) {
-                       $this->insertRedirectEntry( $redirectTitle );
+                       $success = $this->insertRedirectEntry( $redirectTitle );
                } else {
                        // This is not a redirect, remove row from redirect table
                        $where = [ 'rd_from' => $this->getId() ];
                        $dbw->delete( 'redirect', $where, __METHOD__ );
+                       $success = true;
                }
 
                if ( $this->getTitle()->getNamespace() == NS_FILE ) {
                        RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $this->getTitle() );
                }
 
-               return ( $dbw->affectedRows() != 0 );
+               return $success;
        }
 
        /**
@@ -2383,7 +2394,7 @@ class WikiPage implements Page, IDBAccessObject {
                if ( !is_null( $nullRevision ) ) {
                        $logEntry->setAssociatedRevId( $nullRevision->getId() );
                }
-               $logEntry->setTags( $tags );
+               $logEntry->addTags( $tags );
                if ( $logRelationsField !== null && count( $logRelationsValues ) ) {
                        $logEntry->setRelations( [ $logRelationsField => $logRelationsValues ] );
                }
@@ -2784,7 +2795,7 @@ class WikiPage implements Page, IDBAccessObject {
                        $logEntry->setPerformer( $deleter );
                        $logEntry->setTarget( $logTitle );
                        $logEntry->setComment( $reason );
-                       $logEntry->setTags( $tags );
+                       $logEntry->addTags( $tags );
                        $logid = $logEntry->insert();
 
                        $dbw->onTransactionPreCommitOrIdle(
@@ -3242,7 +3253,10 @@ class WikiPage implements Page, IDBAccessObject {
                        $flags |= EDIT_MINOR;
                }
 
-               if ( $bot && ( $guser->isAllowedAny( 'markbotedits', 'bot' ) ) ) {
+               if ( $bot && ( MediaWikiServices::getInstance()
+                               ->getPermissionManager()
+                               ->userHasAnyRight( $guser, 'markbotedits', 'bot' ) )
+               ) {
                        $flags |= EDIT_FORCE_BOT;
                }
 
@@ -3503,7 +3517,7 @@ class WikiPage implements Page, IDBAccessObject {
                self::purgeInterwikiCheckKey( $title );
        }
 
-       /**#@-*/
+       /** #@- */
 
        /**
         * Purge the check key for cross-wiki cache entries referencing this page