- function fetchFromLocation( $location, $hash ) {
- global $wgLoadBalancer;
- $fname = 'fetchFromLocation';
- wfProfileIn( $fname );
-
- $p = strpos( $location, ':' );
- if ( $p === false ) {
- wfProfileOut( $fname );
- return false;
- }
-
- $type = substr( $location, 0, $p );
- $text = false;
- switch ( $type ) {
- case 'mysql':
- # MySQL locations are specified by mysql://<machineID>/<dbname>/<tblname>/<index>
- # Machine ID 0 is the current connection
- if ( preg_match( '/^mysql:\/\/(\d+)\/([A-Za-z_]+)\/([A-Za-z_]+)\/([A-Za-z_]+)$/',
- $location, $matches ) ) {
- $machineID = $matches[1];
- $dbName = $matches[2];
- $tblName = $matches[3];
- $index = $matches[4];
- if ( $machineID == 0 ) {
- # Current connection
- $db =& $this->getDB();
- } else {
- # Alternate connection
- $db =& $wgLoadBalancer->getConnection( $machineID );
-
- if ( array_key_exists( $machineId, $wgKnownMysqlServers ) ) {
- # Try to open, return false on failure
- $params = $wgKnownDBServers[$machineId];
- $db = Database::newFromParams( $params['server'], $params['user'], $params['password'],
- $dbName, 1, DBO_IGNORE );
- }
- }
- if ( $db->isOpen() ) {
- $index = $db->strencode( $index );
- $res = $db->query( "SELECT blob_data FROM $dbName.$tblName " .
- "WHERE blob_index='$index' " . $this->getSelectOptions(), $fname );
- $row = $db->fetchObject( $res );
- $text = $row->text_data;
- }
- }
- break;
- case 'file':
- # File locations are of the form file://<filename>, relative to the current directory
- if ( preg_match( '/^file:\/\/(.*)$', $location, $matches ) )
- $filename = strstr( $location, 'file://' );
- $text = @file_get_contents( $matches[1] );
- }
- if ( $text !== false ) {
- # Got text, now we need to interpret it
- # The first line contains information about how to do this
- $p = strpos( $text, '\n' );
- $type = substr( $text, 0, $p );
- $text = substr( $text, $p + 1 );
- switch ( $type ) {
- case 'plain':
- break;
- case 'gzip':
- $text = gzinflate( $text );
- break;
- case 'object':
- $object = unserialize( $text );
- $text = $object->getItem( $hash );
- break;
- default:
- $text = false;
+ function compressRevisionText( &$text ) {
+ global $wgCompressRevisions, $wgUseLatin1;
+ $flags = array();
+ if( !$wgUseLatin1 ) {
+ # Revisions not marked this way will be converted
+ # on load if $wgLegacyCharset is set in the future.
+ $flags[] = 'utf-8';
+ }
+ if( $wgCompressRevisions ) {
+ if( function_exists( 'gzdeflate' ) ) {
+ $text = gzdeflate( $text );
+ $flags[] = 'gzip';
+ } else {
+ wfDebug( "Article::compressRevisionText() -- no zlib support, not compressing\n" );