Merge "Fix/suppress misc phan errors (#4)"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 5 Apr 2019 22:42:35 +0000 (22:42 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 5 Apr 2019 22:42:35 +0000 (22:42 +0000)
1  2 
includes/Revision/RevisionStore.php

@@@ -1508,11 -1508,9 +1508,11 @@@ class RevisionStor
         * @return RevisionRecord|null
         */
        public function getRevisionByTitle( LinkTarget $linkTarget, $revId = 0, $flags = 0 ) {
 +              // TODO should not require Title in future (T206498)
 +              $title = Title::newFromLinkTarget( $linkTarget );
                $conds = [
 -                      'page_namespace' => $linkTarget->getNamespace(),
 -                      'page_title' => $linkTarget->getDBkey()
 +                      'page_namespace' => $title->getNamespace(),
 +                      'page_title' => $title->getDBkey()
                ];
                if ( $revId ) {
                        // Use the specified revision ID.
                        // Since the caller supplied a revision ID, we are pretty sure the revision is
                        // supposed to exist, so we should try hard to find it.
                        $conds['rev_id'] = $revId;
 -                      return $this->newRevisionFromConds( $conds, $flags );
 +                      return $this->newRevisionFromConds( $conds, $flags, $title );
                } else {
                        // Use a join to get the latest revision.
                        // Note that we don't use newRevisionFromConds here because we don't want to retry
                        $db = $this->getDBConnectionRefForQueryFlags( $flags );
  
                        $conds[] = 'rev_id=page_latest';
 -                      $rev = $this->loadRevisionFromConds( $db, $conds, $flags );
 +                      $rev = $this->loadRevisionFromConds( $db, $conds, $flags, $title );
  
                        return $rev;
                }
        ) {
                if ( !$this->hasMcrSchemaFlags( SCHEMA_COMPAT_READ_NEW ) ) {
                        $mainSlot = $this->emulateMainSlot_1_29( $revisionRow, $queryFlags, $title );
+                       // @phan-suppress-next-line PhanTypeInvalidCallableArraySize false positive
                        $slots = new RevisionSlots( [ SlotRecord::MAIN => $mainSlot ] );
                } else {
                        // XXX: do we need the same kind of caching here
                }
  
                // if we have a content object, use it to set the model and type
 -              if ( !empty( $fields['content'] ) ) {
 -                      if ( !( $fields['content'] instanceof Content ) && !is_array( $fields['content'] ) ) {
 -                              throw new MWException(
 -                                      'content field must contain a Content object or an array of Content objects.'
 -                              );
 -                      }
 +              if ( !empty( $fields['content'] ) && !( $fields['content'] instanceof Content )
 +                      && !is_array( $fields['content'] )
 +              ) {
 +                      throw new MWException(
 +                              'content field must contain a Content object or an array of Content objects.'
 +                      );
                }
  
                if ( !empty( $fields['text_id'] ) ) {