function fetchFullSpot($msgId, $ourUserId) { SpotTiming::start(__CLASS__ . '::' . __FUNCTION__); /* * First try the database for the spot, because if it * is already cached in the database we don't need * anything else */ $fullSpot = $this->_daoFactory->getSpotDao()->getFullSpot($msgId, $ourUserId); if (empty($fullSpot)) { /* * When we retrieve a fullspot entry but there is no spot entry the join in our DB query * causes us to never get the spot, hence we throw this exception */ $spotHeader = $this->_daoFactory->getSpotDao()->getSpotHeader($msgId); if (empty($spotHeader)) { throw new Exception("Spot is not in our Spotweb database"); } # if /* * Retrieve a full loaded spot from the NNTP server */ $newFullSpot = $this->_nntpSpotReading->readFullSpot($msgId); if (!empty($newFullSpot)) { $this->_daoFactory->getSpotDao()->addFullSpots(array($newFullSpot)); } else { SpotTiming::stop(__CLASS__ . '::' . __FUNCTION__, array($msgId, $ourUserId, $fullSpot)); return false; } // else /* * If the title is changed from the header and the full, * we need to update the collection info as well */ if ($newFullSpot['title'] != $spotHeader['title']) { $newFullSpot['collectionid'] = null; /* * Updat the collectionid to match our new title, this * way we know for sure the title matches with the * actual collection */ $svcCollCreate = new Services_Collections_Create($this->_daoFactory); $tmpList = $svcCollCreate->createCollectionsFromList(array($newFullSpot)); $newFullSpot = $tmpList[0]; } else { $newFullSpot['collectionid'] = $spotHeader['collectionid']; } // else /* * If the current spotterid is empty, we probably now have a spotterid because * we have the fullspot. * * We now update the 'basic' spot information, like the spotterid but also the * title. This is necessary because the XML contains better encoding. * * For example take the title from spot bdZZdJ3gPxTAmSE@spot.net. * * We cannot use all information from the XML because because some information just * isn't present in the XML file */ $this->_daoFactory->getSpotDao()->updateSpotInfoFromFull($newFullSpot); /* * We ask our DB to retrieve the fullspot again, this ensures * us all information is present and in always the same format */ $fullSpot = $this->_daoFactory->getSpotDao()->getFullSpot($msgId, $ourUserId); } # if /* * We always have to parse the full spot because the database * does not contain all information */ $spotParser = new Services_Format_Parsing(); $parsedXml = $spotParser->parseFull($fullSpot['fullxml']); $fullSpot = array_merge($parsedXml, $fullSpot); SpotTiming::stop(__CLASS__ . '::' . __FUNCTION__, array($msgId, $ourUserId, $fullSpot)); return $fullSpot; }
# Truncate the current collections tables, and reset all collection id's if (SpotCommandline::get('clean')) { $dbConnection = $daoFactory->getConnection(); echo "Cleaning up all existing collections, "; $dbConnection->rawExec('UPDATE spots SET collectionid = NULL WHERE collectionid IS NOT NULL'); $dbConnection->rawExec('TRUNCATE collections'); $dbConnection->rawExec('TRUNCATE mastercollections'); echo "done." . PHP_EOL; } // if /* Load the complete collection cache in memory */ echo "Loading all existing collections in memory, "; $daoFactory->getCollectionsDao()->loadCollectionCache(array()); echo "done" . PHP_EOL; /* And start creating ocllections */ $svcCreateColl = new Services_Collections_Create($daoFactory); $svcCreateColl->createCollections(0, 'displayProgress'); /* * And actually start updating or creating the schema and settings */ echo "Done creating collections" . PHP_EOL; } catch (Exception $x) { echo PHP_EOL . PHP_EOL; echo 'SpotWeb crashed' . PHP_EOL . PHP_EOL; echo "Creation of collections failed:" . PHP_EOL; echo " " . $x->getMessage() . PHP_EOL; echo PHP_EOL . PHP_EOL; echo $x->getTraceAsString(); die(1); } # catch
/* * Actually retrieve spots from the server */ $currentMaxSpotId = $spotDao->getMaxSpotId(); $retriever = new Services_Retriever_Spots($daoFactory, $settings, $forceMode, $retroMode); $newSpotCount = $retriever->perform(); # Show the cumulative timings of the spotsretrieval if ($showTiming) { SpotTiming::displayCumul(); SpotTiming::clear(); } # if ## Create collections, if enabled if ($settings->get('create_collections')) { echo "Creating collections starting from " . $currentMaxSpotId . ", "; $svcPrvCreateColl = new Services_Collections_Create($daoFactory); $svcPrvCreateColl->createCollections($currentMaxSpotId, null); echo ", done" . PHP_EOL; } // if ## Creating filter counts if ($newSpotCount > 0) { $svcPrv_cacheSpotCount = new Services_Actions_CacheNewSpotCount($daoFactory->getUserFilterCountDao(), $daoFactory->getUserFilterDao(), $daoFactory->getSpotDao(), new Services_Search_QueryParser($daoFactory->getConnection())); echo 'Calculating how many spots are new'; $notifyNewArray = $svcPrv_cacheSpotCount->cacheNewSpotCount(); echo ', done.' . PHP_EOL; # Show the cumulative timings of the caching of these spots if ($showTiming) { SpotTiming::displayCumul(); SpotTiming::clear(); }