Index: trunk/extensions/ExternalData/ED_ParserFunctions.php |
— | — | @@ -133,11 +133,14 @@ |
134 | 134 | static function doRequest( $url, $post_vars = array(), $get_fresh=false, $try_count=1 ) { |
135 | 135 | $dbr = wfGetDB( DB_SLAVE ); |
136 | 136 | //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 ); |
139 | 139 | |
| 140 | + if( !isset($edCacheTable) ) |
| 141 | + return @file_get_contents( $url ); |
| 142 | + |
140 | 143 | // 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' ); |
142 | 145 | // @@todo check date |
143 | 146 | if ( $res->numRows() == 0 || $get_fresh) { |
144 | 147 | //echo "do web request: " . $url . "\n"; |
— | — | @@ -155,7 +158,7 @@ |
156 | 159 | if ( $page != '' ) { |
157 | 160 | $dbw = wfGetDB( DB_MASTER ); |
158 | 161 | // 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() ) ); |
160 | 163 | return $page; |
161 | 164 | } |
162 | 165 | } 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` ( |
3 | 3 | `id` int(10) unsigned NOT NULL auto_increment, |
4 | 4 | `url` varchar(255) NOT NULL, |
5 | 5 | `post_vars` text, |
Index: trunk/extensions/ExternalData/README |
— | — | @@ -33,6 +33,10 @@ |
34 | 34 | line to your 'LocalSettings.php' file: |
35 | 35 | |
36 | 36 | 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 |
37 | 41 | |
38 | 42 | == Contact == |
39 | 43 | |