r46750 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46749‎ | r46750 | r46751 >
Date:00:26, 3 February 2009
Author:dale
Status:deferred
Tags:
Comment:
extension-specific variable names
Modified paths:
  • /trunk/extensions/ExternalData/ED_ParserFunctions.php (modified) (history)
  • /trunk/extensions/ExternalData/ExternalData.sql (modified) (history)
  • /trunk/extensions/ExternalData/README (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_ParserFunctions.php
@@ -133,11 +133,14 @@
134134 static function doRequest( $url, $post_vars = array(), $get_fresh=false, $try_count=1 ) {
135135 $dbr = wfGetDB( DB_SLAVE );
136136 //do any special variable replace (right now just sunlight api key)
137 - global $mvSunlightAPIKey;
138 - $url = str_replace('$$SLAPIKEY', $mvSunlightAPIKey, $url );
 137+ global $edSunlightAPIKey, $edCacheTable;
 138+ $url = str_replace('$$SLAPIKEY', $edSunlightAPIKey, $url );
139139
 140+ if( !isset($edCacheTable) )
 141+ return @file_get_contents( $url );
 142+
140143 // check the cache (only the first 254 chars of the url)
141 - $res = $dbr->select( 'mv_url_cache', '*', array( 'url' => substr($url,0,254) ), 'EDParserFunctions::doRequest' );
 144+ $res = $dbr->select( $edCacheTable, '*', array( 'url' => substr($url,0,254) ), 'EDParserFunctions::doRequest' );
142145 // @@todo check date
143146 if ( $res->numRows() == 0 || $get_fresh) {
144147 //echo "do web request: " . $url . "\n";
@@ -155,7 +158,7 @@
156159 if ( $page != '' ) {
157160 $dbw = wfGetDB( DB_MASTER );
158161 // insert back into the db:
159 - $dbw->insert( 'mv_url_cache', array( 'url' => substr($url,0,254), 'result' => $page, 'req_time' => time() ) );
 162+ $dbw->insert( $edCacheTable, array( 'url' => substr($url,0,254), 'result' => $page, 'req_time' => time() ) );
160163 return $page;
161164 }
162165 } else {
Index: trunk/extensions/ExternalData/ExternalData.sql
@@ -1,4 +1,4 @@
2 -CREATE TABLE IF NOT EXISTS `mv_url_cache` (
 2+CREATE TABLE IF NOT EXISTS `ed_url_cache` (
33 `id` int(10) unsigned NOT NULL auto_increment,
44 `url` varchar(255) NOT NULL,
55 `post_vars` text,
Index: trunk/extensions/ExternalData/README
@@ -33,6 +33,10 @@
3434 line to your 'LocalSettings.php' file:
3535
3636 require_once( "$IP/extensions/ExternalData/ED_Settings.php" );
 37+ //some vars:
 38+ $edCacheTable = 'ed_url_cache';
 39+ //if your using the sunlight api:
 40+ $edSunlightAPIKey = your sunlight api key
3741
3842 == Contact ==
3943

Status & tagging log