Merge "Drop DoEditSectionLink, deprecated since 1.25"
[lhc/web/wiklou.git] / includes / Revision.php
index 1e35dda..e8fe8bd 100644 (file)
  * @file
  */
 
-use MediaWiki\Storage\MutableRevisionRecord;
-use MediaWiki\Storage\RevisionAccessException;
-use MediaWiki\Storage\RevisionFactory;
-use MediaWiki\Storage\RevisionLookup;
-use MediaWiki\Storage\RevisionRecord;
-use MediaWiki\Storage\RevisionStore;
-use MediaWiki\Storage\RevisionStoreRecord;
-use MediaWiki\Storage\SlotRecord;
+use MediaWiki\Revision\MutableRevisionRecord;
+use MediaWiki\Revision\RevisionAccessException;
+use MediaWiki\Revision\RevisionFactory;
+use MediaWiki\Revision\RevisionLookup;
+use MediaWiki\Revision\RevisionRecord;
+use MediaWiki\Revision\RevisionStore;
+use MediaWiki\Revision\RevisionStoreRecord;
+use MediaWiki\Revision\SlotRecord;
 use MediaWiki\Storage\SqlBlobStore;
 use Wikimedia\Rdbms\IDatabase;
 use MediaWiki\Linker\LinkTarget;
@@ -318,12 +318,13 @@ class Revision implements IDBAccessObject {
                global $wgActorTableSchemaMigrationStage;
 
                wfDeprecated( __METHOD__, '1.31' );
-               if ( $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
+               if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
                        // If code is using this instead of self::getQueryInfo(), there's
                        // no way the join it's trying to do can work once the old fields
-                       // aren't being written anymore.
+                       // aren't being used anymore.
                        throw new BadMethodCallException(
-                               'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
+                               'Cannot use ' . __METHOD__
+                                       . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
                        );
                }
 
@@ -352,13 +353,14 @@ class Revision implements IDBAccessObject {
                global $wgContentHandlerUseDB, $wgActorTableSchemaMigrationStage;
                global $wgMultiContentRevisionSchemaMigrationStage;
 
-               if ( $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
+               if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
                        // If code is using this instead of self::getQueryInfo(), there's a
                        // decent chance it's going to try to directly access
                        // $row->rev_user or $row->rev_user_text and we can't give it
-                       // useful values here once those aren't being written anymore.
+                       // useful values here once those aren't being used anymore.
                        throw new BadMethodCallException(
-                               'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
+                               'Cannot use ' . __METHOD__
+                                       . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
                        );
                }
 
@@ -411,13 +413,14 @@ class Revision implements IDBAccessObject {
                global $wgContentHandlerUseDB, $wgActorTableSchemaMigrationStage;
                global $wgMultiContentRevisionSchemaMigrationStage;
 
-               if ( $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH ) {
+               if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
                        // If code is using this instead of self::getQueryInfo(), there's a
                        // decent chance it's going to try to directly access
                        // $row->ar_user or $row->ar_user_text and we can't give it
-                       // useful values here once those aren't being written anymore.
+                       // useful values here once those aren't being used anymore.
                        throw new BadMethodCallException(
-                               'Cannot use ' . __METHOD__ . ' when $wgActorTableSchemaMigrationStage > MIGRATION_WRITE_BOTH'
+                               'Cannot use ' . __METHOD__
+                                       . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
                        );
                }
 
@@ -691,7 +694,7 @@ class Revision implements IDBAccessObject {
         * @return SlotRecord
         */
        private function getMainSlotRaw() {
-               return $this->mRecord->getSlot( 'main', RevisionRecord::RAW );
+               return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
        }
 
        /**
@@ -926,7 +929,7 @@ class Revision implements IDBAccessObject {
                }
 
                try {
-                       return $this->mRecord->getContent( 'main', $audience, $user );
+                       return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
                }
                catch ( RevisionAccessException $e ) {
                        return null;
@@ -1179,7 +1182,7 @@ class Revision implements IDBAccessObject {
 
                $rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
 
-               return new Revision( $rec );
+               return $rec ? new Revision( $rec ) : null;
        }
 
        /**