diff -r 80a400379dd3 -r ea562f37d7a5 Entity/TagRepository.php --- a/Entity/TagRepository.php Thu Dec 08 18:43:14 2011 +0100 +++ b/Entity/TagRepository.php Fri Dec 09 02:21:17 2011 +0100 @@ -58,9 +58,11 @@ $tags = $this->findBy(array('normalizedLabel' => $tag_label_normalized)); $tag = null; foreach ($tags as $t) { - if($tag==null || $t->getUrlStatus()!=Tag::$TAG_URL_STATUS_DICT['null_result']) { + if($tag==null + || $tag->getUrlStatus() === Tag::$TAG_URL_STATUS_DICT['unsemantized'] + || ($tag->getUrlStatus() === Tag::$TAG_URL_STATUS_DICT['null_result'] && $t->getUrlStatus() !== Tag::$TAG_URL_STATUS_DICT['unsemantized'])) { $tag = $t; - if($t->getUrlStatus()!=Tag::$TAG_URL_STATUS_DICT['null_result']) { + if($tag->getUrlStatus()!=Tag::$TAG_URL_STATUS_DICT['unsemantized'] && $tag->getUrlStatus()!=Tag::$TAG_URL_STATUS_DICT['null_result']) { break; } } @@ -75,37 +77,10 @@ } else { $created = false; - $match_exists = false; - // Even if a tag with the normalised label exists, IF this tag is not wikipedia semantised, - // we search if a wikipedia semantised version exists in the base - foreach ($tags as $t) { - if($t->getUrlStatus()==Tag::$TAG_URL_STATUS_DICT['match']) { - $tag = $t; - $match_exists = true; - break; - } - } - if($match_exists==false) { - try { - $wp_response = WikiTagUtils::getWikipediaInfo($tag_label_normalized); - } - catch (\Exception $e){ - throw new \Exception($e->getMessage()); - } - $status = $wp_response['status']; - if($status==Tag::$TAG_URL_STATUS_DICT['match']) { - $tag = new Tag(); - $tag->setLabel($tag_label_normalized); - $tag->setOriginalLabel($tag_label); - $tag->setNormalizedLabel($tag_label_normalized); - $created = true; - $wp_request_done = true; - } - } } - // We request Wikipedia if the tag is created - if($created==true) { + // We request Wikipedia if the tag is created or if this is a null result + if($created==true || $tag->getUrlStatus()===Tag::$TAG_URL_STATUS_DICT['null_result']) { if($wp_request_done==false) { try { @@ -142,5 +117,4 @@ return array($tag, $wikipedia_revision_id, $created);//, $wpReponse); } - -} \ No newline at end of file +}