Provide backwards compatibility for RevisionInsertComplete hook.
[lhc/web/wiklou.git] / includes / Storage / RevisionStore.php
index 1f0afae..733b63a 100644 (file)
@@ -47,6 +47,7 @@ use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerInterface;
 use Psr\Log\NullLogger;
 use RecentChange;
+use Revision;
 use stdClass;
 use Title;
 use User;
@@ -283,7 +284,7 @@ class RevisionStore
         * @param mixed $value
         * @param string $name
         *
-        * @throw IncompleteRevisionException if $value is null
+        * @throws IncompleteRevisionException if $value is null
         * @return mixed $value, if $value is not null
         */
        private function failOnNull( $value, $name ) {
@@ -300,7 +301,7 @@ class RevisionStore
         * @param mixed $value
         * @param string $name
         *
-        * @throw IncompleteRevisionException if $value is empty
+        * @throws IncompleteRevisionException if $value is empty
         * @return mixed $value, if $value is not null
         */
        private function failOnEmpty( $value, $name ) {
@@ -391,7 +392,7 @@ class RevisionStore
 
                // getTextIdFromAddress() is free to insert something into the text table, so $textId
                // may be a new value, not anything already contained in $blobAddress.
-               $blobAddress = 'tt:' . $textId;
+               $blobAddress = SqlBlobStore::makeAddressFromTextId( $textId );
 
                $comment = $this->failOnNull( $rev->getComment( RevisionRecord::RAW ), 'comment' );
                $user = $this->failOnNull( $rev->getUser( RevisionRecord::RAW ), 'user' );
@@ -489,6 +490,10 @@ class RevisionStore
 
                Hooks::run( 'RevisionRecordInserted', [ $rev ] );
 
+               // TODO: deprecate in 1.32!
+               $legacyRevision = new Revision( $rev );
+               Hooks::run( 'RevisionInsertComplete', [ &$legacyRevision, null, null ] );
+
                return $rev;
        }
 
@@ -724,11 +729,6 @@ class RevisionStore
                        'ar_content_model'  => 'rev_content_model',
                ];
 
-               if ( empty( $archiveRow->ar_text_id ) ) {
-                       $fieldMap['ar_text'] = 'old_text';
-                       $fieldMap['ar_flags'] = 'old_flags';
-               }
-
                $revRow = new stdClass();
                foreach ( $fieldMap as $arKey => $revKey ) {
                        if ( property_exists( $archiveRow, $arKey ) ) {
@@ -769,7 +769,9 @@ class RevisionStore
 
                        if ( isset( $row->rev_text_id ) && $row->rev_text_id > 0 ) {
                                $mainSlotRow->slot_content_id = $row->rev_text_id;
-                               $mainSlotRow->content_address = 'tt:' . $row->rev_text_id;
+                               $mainSlotRow->content_address = SqlBlobStore::makeAddressFromTextId(
+                                       $row->rev_text_id
+                               );
                        }
 
                        // This is used by null-revisions
@@ -808,7 +810,7 @@ class RevisionStore
                                ? intval( $row['slot_origin'] )
                                : null;
                        $mainSlotRow->content_address = isset( $row['text_id'] )
-                               ? 'tt:' . intval( $row['text_id'] )
+                               ? SqlBlobStore::makeAddressFromTextId( intval( $row['text_id'] ) )
                                : null;
                        $mainSlotRow->content_size = isset( $row['len'] ) ? intval( $row['len'] ) : null;
                        $mainSlotRow->content_sha1 = isset( $row['sha1'] ) ? strval( $row['sha1'] ) : null;
@@ -892,7 +894,7 @@ class RevisionStore
         * @param string|null $blobFormat MIME type indicating how $dataBlob is encoded
         * @param int $queryFlags
         *
-        * @throw RevisionAccessException
+        * @throws RevisionAccessException
         * @return Content
         */
        private function loadSlotContent(
@@ -1704,7 +1706,6 @@ class RevisionStore
                                        'ar_namespace',
                                        'ar_title',
                                        'ar_rev_id',
-                                       'ar_text',
                                        'ar_text_id',
                                        'ar_timestamp',
                                        'ar_minor_edit',