r23193 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23192‎ | r23193 | r23194 >
Date:02:52, 22 June 2007
Author:greg
Status:old
Tags:
Comment:
Postgres compatibility
Modified paths:
  • /trunk/extensions/BookInformation/bookinfo.pg.sql (added) (history)
  • /trunk/extensions/BookInformation/bookinfo.sql (modified) (history)
  • /trunk/extensions/BookInformation/drivers/Cache.php (modified) (history)

Diff [purge]

Index: trunk/extensions/BookInformation/bookinfo.sql
@@ -12,5 +12,5 @@
1313 -- Result; a serialised BookInformationDriver
1414 bi_result blob NOT NULL,
1515
16 - PRIMARY KEY (bi_isbn)
17 -) ENGINE=InnoDB;
\ No newline at end of file
 16+ PRIMARY KEY (bi_isbn)
 17+) ENGINE=InnoDB;
Index: trunk/extensions/BookInformation/bookinfo.pg.sql
@@ -0,0 +1,17 @@
 2+-- BookInformation cache table
 3+-- Postgres version
 4+--
 5+-- This will speed up multiple requests for the same item, and
 6+-- reduce hits on the provider -- set $wgBookInformationCache = true;
 7+-- to use
 8+
 9+CREATE TABLE bookinfo (
 10+
 11+ -- ISBN, 10 or 13 characters
 12+ bi_isbn varchar(13) NOT NULL,
 13+
 14+ -- Result; a serialised BookInformationDriver
 15+ bi_result bytea NOT NULL,
 16+
 17+ PRIMARY KEY (bi_isbn)
 18+);
Property changes on: trunk/extensions/BookInformation/bookinfo.pg.sql
___________________________________________________________________
Added: svn:eol-style
119 + native
Index: trunk/extensions/BookInformation/drivers/Cache.php
@@ -21,7 +21,7 @@
2222 $dbr = wfGetDB( DB_SLAVE );
2323 $res = $dbr->selectRow( 'bookinfo', '*', array( 'bi_isbn' => $isbn ), __METHOD__ );
2424 if( $res ) {
25 - $result = unserialize( $res->bi_result );
 25+ $result = unserialize( $dbr->decodeBlob( $res->bi_result ) );
2626 if( is_object( $result ) && $result instanceof BookInformationResult ) {
2727 wfDebugLog( 'bookinfo', "Cache hit for {$isbn}\n" );
2828 return $result;
@@ -43,14 +43,14 @@
4444 global $wgBookInformationCache;
4545 if( $wgBookInformationCache ) {
4646 $dbw = wfGetDB( DB_MASTER );
47 - $dbw->insert( 'bookinfo', self::prepareValues( $isbn, $result ), __METHOD__, 'IGNORE' );
 47+ $dbw->insert( 'bookinfo', self::prepareValues( $isbn, $result, $dbw ), __METHOD__, 'IGNORE' );
4848 }
4949 }
5050
51 - private static function prepareValues( $isbn, $result ) {
 51+ private static function prepareValues( $isbn, $result, $dbw ) {
5252 return array(
5353 'bi_isbn' => $isbn,
54 - 'bi_result' => serialize( $result ),
 54+ 'bi_result' => $dbw->encodeBlob( serialize( $result ) ),
5555 );
5656 }
5757

Status & tagging log