Browse Source

[Wikipedia] Use cache for full articles

logmanoriginal 7 years ago
parent
commit
7363acfa6b
1 changed files with 5 additions and 2 deletions
  1. 5 2
      bridges/WikipediaBridge.php

+ 5 - 2
bridges/WikipediaBridge.php

@@ -3,7 +3,7 @@
 define('WIKIPEDIA_SUBJECT_TFA', 0); // Today's featured article
 define('WIKIPEDIA_SUBJECT_DYK', 1); // Did you know...
 
-class WikipediaBridge extends BridgeAbstract{
+class WikipediaBridge extends HttpCachingBridgeAbstract {
 	public function loadMetadatas(){
 		$this->maintainer = 'logmanoriginal';
 		$this->name = 'Wikipedia bridge for many languages';
@@ -188,7 +188,10 @@ class WikipediaBridge extends BridgeAbstract{
 	* Loads the full article from a given URI
 	*/
 	private function LoadFullArticle($uri){
-		$content_html = $this->getSimpleHTMLDOM($uri);
+		if($this->get_cached_time($uri) <= strtotime('-24 hours'))
+			$this->remove_from_cache($uri);
+
+		$content_html = $this->get_cached($uri);
 
 		if(!$content_html)
 			$this->returnServerError('Could not load site: ' . $uri . '!');