Example #1
0
    /**
     * Removes all items of a certain site from the Index Queue. Accepts an
     * optional parameter to limit the deleted items by indexing configuration.
     *
     * @param Tx_Solr_Site $site The site to remove items for.
     * @param string $indexingConfigurationName Name of a specific indexing
     *      configuration
     */
    public function deleteItemsBySite(Tx_Solr_Site $site, $indexingConfigurationName = '')
    {
        $rootPageConstraint = 'tx_solr_indexqueue_item.root = ' . $site->getRootPageId();
        $indexingConfigurationConstraint = '';
        if (!empty($indexingConfigurationName)) {
            $indexingConfigurationConstraint = ' AND tx_solr_indexqueue_item.indexing_configuration = \'' . $indexingConfigurationName . '\'';
        }
        Tx_Solr_DatabaseUtility::transactionStart();
        try {
            // reset Index Queue
            $result = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_solr_indexqueue_item', $rootPageConstraint . $indexingConfigurationConstraint);
            if (!$result) {
                throw new RuntimeException('Failed to reset Index Queue for site ' . $site->getLabel(), 1412986560);
            }
            // reset Index Queue Properties
            $indexQueuePropertyResetQuery = '
				DELETE tx_solr_indexqueue_indexing_property.*
				FROM tx_solr_indexqueue_indexing_property
				INNER JOIN tx_solr_indexqueue_item
					ON tx_solr_indexqueue_item.uid = tx_solr_indexqueue_indexing_property.item_id
					AND ' . $rootPageConstraint . $indexingConfigurationConstraint;
            $result = $GLOBALS['TYPO3_DB']->sql_query($indexQueuePropertyResetQuery);
            if (!$result) {
                throw new RuntimeException('Failed to reset Index Queue properties for site ' . $site->getLabel(), 1412986604);
            }
            Tx_Solr_DatabaseUtility::transactionCommit();
        } catch (RuntimeException $e) {
            Tx_Solr_DatabaseUtility::transactionRollback();
        }
    }
Example #2
0
 /**
  * Initializes Mount Pages to be indexed through the Index Queue. The Mount
  * Pages are searched and their mounted virtual sub-trees are then resolved
  * and added to the Index Queue as if they were actually present below the
  * Mount Page.
  *
  * @return boolean TRUE if initialization of the Mount Pages was successful, FALSE otherwise
  */
 protected function initializeMountPages()
 {
     $mountPagesInitialized = FALSE;
     $mountPages = $this->findMountPages();
     if (empty($mountPages)) {
         $mountPagesInitialized = TRUE;
         return $mountPagesInitialized;
     }
     foreach ($mountPages as $mountPage) {
         if (!$this->validateMountPage($mountPage)) {
             continue;
         }
         $mountedPages = $this->resolveMountPageTree($mountPage['mountPageSource']);
         // handling mount_pid_ol behavior
         if ($mountPage['mountPageOverlayed']) {
             // the page shows the mounted page's content
             $mountedPages[] = $mountPage['mountPageSource'];
         } else {
             // Add page like a regular page, as only the sub tree is
             // mounted. The page itself has its own content.
             \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_IndexQueue_Queue')->updateItem($this->type, $mountPage['uid'], $this->indexingConfigurationName);
         }
         // This can happen when the mount point does not show the content of the
         // mounted page and the mounted page does not have any subpages.
         if (empty($mountedPages)) {
             continue;
         }
         Tx_Solr_DatabaseUtility::transactionStart();
         try {
             $this->addMountedPagesToIndexQueue($mountedPages);
             $this->addIndexQueueItemIndexingProperties($mountPage, $mountedPages);
             Tx_Solr_DatabaseUtility::transactionCommit();
             $mountPagesInitialized = TRUE;
         } catch (Exception $e) {
             Tx_Solr_DatabaseUtility::transactionRollback();
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Index Queue initialization failed for mount pages', 'solr', 3, array($e->__toString()));
             break;
         }
     }
     return $mountPagesInitialized;
 }