equal
deleted
inserted
replaced
45 * |
45 * |
46 * @param string $tag_label_normalized |
46 * @param string $tag_label_normalized |
47 * @param bigint $page_id |
47 * @param bigint $page_id |
48 * @return array |
48 * @return array |
49 */ |
49 */ |
50 public static function getWikipediaInfo($tag_label_normalized, $page_id=null, $ignore_wikipedia_error=false) |
50 public static function getWikipediaInfo($tag_label_normalized, $page_id=null, $ignore_wikipedia_error=false, $logger = null) |
51 { |
51 { |
52 // get ignore_wikipedia_error parameter |
52 |
53 |
|
54 $params = array('action'=>'query', 'prop'=>'info|categories|langlinks', 'inprop'=>'url', 'lllimit'=>'500', 'cllimit'=>'500', 'rvprop'=>'ids', 'format'=>'json'); |
53 $params = array('action'=>'query', 'prop'=>'info|categories|langlinks', 'inprop'=>'url', 'lllimit'=>'500', 'cllimit'=>'500', 'rvprop'=>'ids', 'format'=>'json'); |
55 if($tag_label_normalized!=null){ |
54 if($tag_label_normalized!=null){ |
56 $params['titles'] = urlencode($tag_label_normalized); |
55 $params['titles'] = urlencode($tag_label_normalized); |
57 } |
56 } |
58 else if($page_id!=null){ |
57 else if($page_id!=null){ |
65 try { |
64 try { |
66 $ar = WikiTagUtils::requestWikipedia($params); |
65 $ar = WikiTagUtils::requestWikipedia($params); |
67 } |
66 } |
68 catch(\Exception $e) { |
67 catch(\Exception $e) { |
69 if($ignore_wikipedia_error) { |
68 if($ignore_wikipedia_error) { |
|
69 if(!is_null($logger)) { |
|
70 $logger->err("Error when querying wikipedia : ".$e->getMessage()." with trace : ".$e->getTraceAsString()); |
|
71 } |
70 return WikiTagUtils::returnNullResult(null); |
72 return WikiTagUtils::returnNullResult(null); |
71 } |
73 } |
72 else { |
74 else { |
73 throw $e; |
75 throw $e; |
74 } |
76 } |
114 try { |
116 try { |
115 $ar = WikiTagUtils::requestWikipedia($params); |
117 $ar = WikiTagUtils::requestWikipedia($params); |
116 } |
118 } |
117 catch(\Exception $e) { |
119 catch(\Exception $e) { |
118 if($ignore_wikipedia_error) { |
120 if($ignore_wikipedia_error) { |
|
121 if(!is_null($logger)) { |
|
122 $logger->error("Error when querying wikipedia for redirection : ".$e->getMessage()." with trace : ".$e->getTraceAsString()); |
|
123 } |
119 return WikiTagUtils::returnNullResult(null); |
124 return WikiTagUtils::returnNullResult(null); |
120 } |
125 } |
121 else { |
126 else { |
122 throw $e; |
127 throw $e; |
123 } |
128 } |