Index: trunk/extensions/BookInformation/bookinfo.sql |
— | — | @@ -12,5 +12,5 @@ |
13 | 13 | -- Result; a serialised BookInformationDriver |
14 | 14 | bi_result blob NOT NULL, |
15 | 15 | |
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 |
1 | 19 | + native |
Index: trunk/extensions/BookInformation/drivers/Cache.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | $dbr = wfGetDB( DB_SLAVE ); |
23 | 23 | $res = $dbr->selectRow( 'bookinfo', '*', array( 'bi_isbn' => $isbn ), __METHOD__ ); |
24 | 24 | if( $res ) { |
25 | | - $result = unserialize( $res->bi_result ); |
| 25 | + $result = unserialize( $dbr->decodeBlob( $res->bi_result ) ); |
26 | 26 | if( is_object( $result ) && $result instanceof BookInformationResult ) { |
27 | 27 | wfDebugLog( 'bookinfo', "Cache hit for {$isbn}\n" ); |
28 | 28 | return $result; |
— | — | @@ -43,14 +43,14 @@ |
44 | 44 | global $wgBookInformationCache; |
45 | 45 | if( $wgBookInformationCache ) { |
46 | 46 | $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' ); |
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | | - private static function prepareValues( $isbn, $result ) { |
| 51 | + private static function prepareValues( $isbn, $result, $dbw ) { |
52 | 52 | return array( |
53 | 53 | 'bi_isbn' => $isbn, |
54 | | - 'bi_result' => serialize( $result ), |
| 54 | + 'bi_result' => $dbw->encodeBlob( serialize( $result ) ), |
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |