Example #1
0
 /**
  * Finds the FE user groups used on a page including all groups of content
  * elements and groups of records of extensions that have correctly been
  * pushed through ContentObjectRenderer during rendering.
  *
  * @param Item $item Index queue item representing the current page to get the user groups from
  * @param integer $language The sys_language_uid language ID
  * @return array Array of user group IDs
  */
 protected function getAccessGroupsFromContent(Item $item, $language = 0)
 {
     static $accessGroupsCache;
     $accessGroupsCacheEntryId = $item->getRecordUid() . '|' . $language;
     if (!isset($accessGroupsCache[$accessGroupsCacheEntryId])) {
         $request = $this->buildBasePageIndexerRequest();
         $request->setIndexQueueItem($item);
         $request->addAction('findUserGroups');
         $indexRequestUrl = $this->getDataUrl($item, $language);
         $response = $request->send($indexRequestUrl);
         $groups = $response->getActionResult('findUserGroups');
         if (is_array($groups)) {
             $accessGroupsCache[$accessGroupsCacheEntryId] = $groups;
         }
         if ($this->loggingEnabled) {
             GeneralUtility::devLog('Page Access Groups', 'solr', 0, array('item' => (array) $item, 'language' => $language, 'index request url' => $indexRequestUrl, 'request' => (array) $request, 'response' => (array) $response, 'groups' => $groups));
         }
     }
     return $accessGroupsCache[$accessGroupsCacheEntryId];
 }
Example #2
0
 /**
  * Determines a page ID's URL.
  *
  * Tries to find a domain record to use to build an URL for a given page ID
  * and then actually build and return the page URL.
  *
  * @param Item $item Item to index
  * @param integer $language The language id
  * @return string URL to send the index request to
  * @throws \RuntimeException
  */
 protected function getDataUrl(Item $item, $language = 0)
 {
     $scheme = 'http';
     $host = $item->getSite()->getDomain();
     $path = '/';
     $pageId = $item->getRecordUid();
     // deprecated
     if (!empty($this->options['scheme'])) {
         GeneralUtility::devLog('Using deprecated option "scheme" to set the scheme (http / https) for the page indexer frontend helper. Use plugin.tx_solr.index.queue.pages.indexer.frontendDataHelper.scheme instead', 'solr', 2);
         $scheme = $this->options['scheme'];
     }
     // check whether we should use ssl / https
     if (!empty($this->options['frontendDataHelper.']['scheme'])) {
         $scheme = $this->options['frontendDataHelper.']['scheme'];
     }
     // overwriting the host
     if (!empty($this->options['frontendDataHelper.']['host'])) {
         $host = $this->options['frontendDataHelper.']['host'];
     }
     // setting a path if TYPO3 is installed in a sub directory
     if (!empty($this->options['frontendDataHelper.']['path'])) {
         $path = $this->options['frontendDataHelper.']['path'];
     }
     $mountPointParameter = $this->getMountPageDataUrlParameter($item);
     $dataUrl = $scheme . '://' . $host . $path . 'index.php?id=' . $pageId;
     $dataUrl .= $mountPointParameter !== '' ? '&MP=' . $mountPointParameter : '';
     $dataUrl .= '&L=' . $language;
     if (!GeneralUtility::isValidUrl($dataUrl)) {
         GeneralUtility::devLog('Could not create a valid URL to get frontend data while trying to index a page.', 'solr', 3, array('item' => (array) $item, 'constructed URL' => $dataUrl, 'scheme' => $scheme, 'host' => $host, 'path' => $path, 'page ID' => $pageId, 'indexer options' => $this->options));
         throw new \RuntimeException('Could not create a valid URL to get frontend data while trying to index a page. Created URL: ' . $dataUrl, 1311080805);
     }
     if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueuePageIndexer']['dataUrlModifier']) {
         $dataUrlModifier = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueuePageIndexer']['dataUrlModifier']);
         if ($dataUrlModifier instanceof PageIndexerDataUrlModifier) {
             $dataUrl = $dataUrlModifier->modifyDataUrl($dataUrl, array('item' => $item, 'scheme' => $scheme, 'host' => $host, 'path' => $path, 'pageId' => $pageId, 'language' => $language));
         } else {
             throw new \RuntimeException($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueuePageIndexer']['dataUrlModifier'] . ' is not an implementation of ApacheSolrForTypo3\\Solr\\IndexQueue\\PageIndexerDataUrlModifier', 1290523345);
         }
     }
     return $dataUrl;
 }
Example #3
0
 /**
  * Logs the item and what document was created from it
  *
  * @param Item $item The item that is being indexed.
  * @param array $itemDocuments An array of Solr documents created from the item's data
  * @param Apache_Solr_Response $response The Solr response for the particular index document
  */
 protected function log(Item $item, array $itemDocuments, Apache_Solr_Response $response)
 {
     if (!$this->loggingEnabled) {
         return;
     }
     $message = 'Index Queue indexing ' . $item->getType() . ':' . $item->getRecordUid() . ' - ';
     $severity = 0;
     // info
     // preparing data
     $documents = array();
     foreach ($itemDocuments as $document) {
         $documents[] = (array) $document;
     }
     $logData = array('item' => (array) $item, 'documents' => $documents, 'response' => (array) $response);
     if ($response->getHttpStatus() == 200) {
         $severity = -1;
         $message .= 'Success';
     } else {
         $severity = 3;
         $message .= 'Failure';
         $logData['status'] = $response->getHttpStatus();
         $logData['status message'] = $response->getHttpStatusMessage();
     }
     GeneralUtility::devLog($message, 'solr', $severity, $logData);
 }