X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FbackupTextPass.inc;h=7aac4d4a6a0d50ff9e7d09a819f8e6b67ed44200;hb=f3b38123cbd8ac70dcdcbbd5489c588038fc317e;hp=c99f00480c61ad3f27f7465e8f3c22081e2322ad;hpb=bea7a64218b960614aea8284aea597ecf2f02bdf;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/backupTextPass.inc b/maintenance/backupTextPass.inc index c99f00480c..7aac4d4a6a 100644 --- a/maintenance/backupTextPass.inc +++ b/maintenance/backupTextPass.inc @@ -24,7 +24,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/backup.inc' ); +require_once __DIR__ . '/backup.inc'; /** * @ingroup Maintenance @@ -183,7 +183,7 @@ class TextPassDumper extends BackupDumper { global $IP; $url = $this->processFileOpt( $val, $param ); - switch( $opt ) { + switch ( $opt ) { case 'prefetch': require_once "$IP/maintenance/backupPrefetch.inc"; $this->prefetch = new BaseDump( $url ); @@ -215,7 +215,7 @@ class TextPassDumper extends BackupDumper { function processFileOpt( $val, $param ) { $fileURIs = explode( ';', $param ); foreach ( $fileURIs as $URI ) { - switch( $val ) { + switch ( $val ) { case "file": $newURI = $URI; break; @@ -414,6 +414,8 @@ class TextPassDumper extends BackupDumper { * @throws MWException */ function getText( $id ) { + global $wgContentHandlerUseDB; + $prefetchNotTried = true; // Whether or not we already tried to get the text via prefetch. $text = false; // The candidate for a good text. false if no proper value. $failures = 0; // The number of times, this invocation of getText already failed. @@ -479,7 +481,23 @@ class TextPassDumper extends BackupDumper { if ( ! isset( $this->db ) ) { throw new MWException( "No database available" ); } - $revLength = $this->db->selectField( 'revision', 'rev_len', array( 'rev_id' => $revID ) ); + + $revLength = strlen( $text ); + if ( $wgContentHandlerUseDB ) { + $row = $this->db->selectRow( 'revision', array( 'rev_len', 'rev_content_model' ), array( 'rev_id' => $revID ), __METHOD__ ); + if ( $row ) { + // only check the length for the wikitext content handler, + // it's a wasted (and failed) check otherwise + if ( $row->rev_content_model == CONTENT_MODEL_WIKITEXT ) { + $revLength = $row->rev_len; + } + } + + } + else { + $revLength = $this->db->selectField( 'revision', 'rev_len', array( 'rev_id' => $revID ) ); + } + if ( strlen( $text ) == $revLength ) { if ( $tryIsPrefetch ) { $this->prefetchCount++;