Merge "Fixed dependencies for jquery.collapsibleTabs"
[lhc/web/wiklou.git] / includes / filerepo / file / LocalFile.php
index 695c4e9..caa93a4 100644 (file)
@@ -1006,7 +1006,7 @@ class LocalFile extends File {
        {
                $pageText = SpecialUpload::getInitialPageText( $desc, $license, $copyStatus, $source );
 
-               if ( !$this->recordUpload2( $oldver, $desc, $pageText ) ) {
+               if ( !$this->recordUpload2( $oldver, $desc, $pageText, false, $timestamp ) ) {
                        return false;
                }
 
@@ -1186,8 +1186,9 @@ class LocalFile extends File {
                } else {
                        # New file; create the description page.
                        # There's already a log entry, so don't make a second RC entry
-                       # Squid and file cache for the description page are purged by doEdit.
-                       $status = $wikiPage->doEdit( $pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user );
+                       # Squid and file cache for the description page are purged by doEditContent.
+                       $content = ContentHandler::makeContent( $pageText, $descTitle );
+                       $status = $wikiPage->doEditContent( $content, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user );
 
                        if ( isset( $status->value['revision'] ) ) { // XXX; doEdit() uses a transaction
                                $dbw->begin();
@@ -1475,9 +1476,9 @@ class LocalFile extends File {
                global $wgParser;
                $revision = Revision::newFromTitle( $this->title, false, Revision::READ_NORMAL );
                if ( !$revision ) return false;
-               $text = $revision->getText();
-               if ( !$text ) return false;
-               $pout = $wgParser->parse( $text, $this->title, new ParserOptions() );
+               $content = $revision->getContent();
+               if ( !$content ) return false;
+               $pout = $content->getParserOutput( $this->title, null, new ParserOptions() );
                return $pout->getText();
        }
 
@@ -1773,7 +1774,8 @@ class LocalFileDeleteBatch {
                                        'fa_description'  => 'img_description',
                                        'fa_user'         => 'img_user',
                                        'fa_user_text'    => 'img_user_text',
-                                       'fa_timestamp'    => 'img_timestamp'
+                                       'fa_timestamp'    => 'img_timestamp',
+                                       'fa_sha1'         => 'img_sha1',
                                ), $where, __METHOD__ );
                }
 
@@ -1805,6 +1807,7 @@ class LocalFileDeleteBatch {
                                        'fa_user'         => 'oi_user',
                                        'fa_user_text'    => 'oi_user_text',
                                        'fa_timestamp'    => 'oi_timestamp',
+                                       'fa_sha1'         => 'oi_sha1',
                                ), $where, __METHOD__ );
                }
        }
@@ -2037,7 +2040,12 @@ class LocalFileRestoreBatch {
                        $deletedRel = $this->file->repo->getDeletedHashPath( $row->fa_storage_key ) . $row->fa_storage_key;
                        $deletedUrl = $this->file->repo->getVirtualUrl() . '/deleted/' . $deletedRel;
 
-                       $sha1 = substr( $row->fa_storage_key, 0, strcspn( $row->fa_storage_key, '.' ) );
+                       if( isset( $row->fa_sha1 ) ) {
+                               $sha1 = $row->fa_sha1;
+                       } else {
+                               // old row, populate from key
+                               $sha1 = LocalRepo::getHashFromKey( $row->fa_storage_key );
+                       }
 
                        # Fix leading zero
                        if ( strlen( $sha1 ) == 32 && $sha1[0] == '0' ) {