function process($postId) { //get links $postDao = new \com\indigloo\sc\dao\Post(); $linkData = $postDao->getLinkDataOnId($postId); $links = $linkData["links"]; if (is_null($links)) { return; } $version = $linkData["version"]; //clean tmp post-site table mysql\Site::deleteTmpPSData($postId); foreach ($links as $link) { $page = $this->processUrl($link); if (empty($page) || empty($page["canonicalUrl"]) || empty($page["hash"]) || empty($page["host"])) { $message = "URL_PROC_ERROR :: [%s] of post [%d] is missing required data \n\n"; $message = sprintf($message, $link, $postId); Logger::getInstance()->error($message); //write to bad.url log file $fhandle = NULL; $logfile = Config::getInstance()->get_value("bad.url.log"); if (!file_exists($logfile)) { //create the file $fhandle = fopen($logfile, "x+"); } else { $fhandle = fopen($logfile, "a+"); } fwrite($fhandle, $message); fclose($fhandle); // process next URL // there are pros and cons of continuing on bad url vs. bailing out // however URL processing is intensive job and it is better to examine // bad URL in leisure because we may not have a solution for processing // bad urls immediately continue; } $siteId = $this->getOrCreate($page["hash"], $page["host"], $page["canonicalUrl"]); if (!is_null($siteId)) { mysql\Site::addTmpPSData($postId, $siteId); } else { trigger_error("URL_PROC_ERROR :: Null site.id for {$link}", E_USER_ERROR); } } //Add new post+site data and update tracker mysql\Site::updateTracker($postId, $version); }