Skip to content

Commit

Permalink
[TASK] replace usage of deprecated or outdated TYPO3 API calls (#2361) (
Browse files Browse the repository at this point in the history
  • Loading branch information
achimfritz authored and timohund committed Sep 11, 2019
1 parent eeae75d commit 7d0241d
Show file tree
Hide file tree
Showing 53 changed files with 156 additions and 220 deletions.
1 change: 1 addition & 0 deletions Classes/Command/SolrCommandController.php
Expand Up @@ -19,6 +19,7 @@

/**
* Controller to run solr specific tasks via CLI
* @extensionScannerIgnoreFile
*/
class SolrCommandController extends CommandController
{
Expand Down
1 change: 1 addition & 0 deletions Classes/ConnectionManager.php
Expand Up @@ -419,6 +419,7 @@ protected function getConfiguredSolrConnectionByRootPage(array $rootPage, $langu
$GLOBALS['TSFE']->tmpl = new \stdClass();
$GLOBALS['TSFE']->cObjectDepthCounter = 50;
$GLOBALS['TSFE']->tmpl->rootLine = $rootLine;
// @extensionScannerIgnoreLine
$GLOBALS['TSFE']->sys_page = $pageSelect;
$GLOBALS['TSFE']->id = $rootPage['uid'];
$GLOBALS['TSFE']->page = $rootPage;
Expand Down
1 change: 1 addition & 0 deletions Classes/Controller/AbstractBaseController.php
Expand Up @@ -94,6 +94,7 @@ abstract class AbstractBaseController extends ActionController
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
$this->configurationManager = $configurationManager;
// @extensionScannerIgnoreLine
$this->contentObjectRenderer = $this->configurationManager->getContentObject();
}

Expand Down
1 change: 1 addition & 0 deletions Classes/Domain/Search/ApacheSolrDocument/Builder.php
Expand Up @@ -102,6 +102,7 @@ public function fromPage(TypoScriptFrontendController $page, $url, Rootline $pag
$this->addEndtimeField($document, $pageRecord);

// content
// @extensionScannerIgnoreLine
$contentExtractor = $this->getExtractorForPageContent($page->content);
$document->setField('title', $contentExtractor->getPageTitle());
$document->setField('subTitle', $pageRecord['subtitle']);
Expand Down
Expand Up @@ -147,7 +147,10 @@ protected function applyManualSortOrder(AbstractOptionsFacet $facet, array $face
return $facet;
}
$fields = GeneralUtility::trimExplode(',', $facetConfiguration['manualSortOrder']);
// @extensionScannerIgnoreLine
$sortedOptions = $facet->getOptions()->getManualSortedCopy($fields);

// @extensionScannerIgnoreLine
$facet->setOptions($sortedOptions);

return $facet;
Expand All @@ -164,6 +167,7 @@ protected function applyReverseOrder(AbstractOptionsFacet $facet, array $facetCo
return $facet;
}

// @extensionScannerIgnoreLine
$facet->setOptions($facet->getOptions()->getReversedOrderCopy());

return $facet;
Expand Down
Expand Up @@ -63,6 +63,7 @@ public function setObjectManager($objectManager)
*/
protected function getFacetRegistry()
{
// @extensionScannerIgnoreLine
return $this->getObjectManager()->get(FacetRegistry::class);
}

Expand Down Expand Up @@ -250,6 +251,7 @@ protected function applyRequirements(SearchResultSet $resultSet)
*/
protected function getRequirementsService()
{
// @extensionScannerIgnoreLine
return $this->getObjectManager()->get(RequirementsService::class);
}
}
2 changes: 1 addition & 1 deletion Classes/Domain/Site/SiteRepository.php
Expand Up @@ -332,7 +332,7 @@ protected function getDomainFromConfigurationOrFallbackToDomainRecord($rootPageI
*/
private function firstDomainRecordFromLegacyDomainResolver($rootLine)
{
trigger_error('BackendUtility::firstDomainRecord() will be removed in TYPO3 v10.0. Use sitehandling instead.', E_USER_DEPRECATED);
trigger_error('Method firstDomainRecordFromLegacyDomainResolver is deprecated since EXT:solr 10 and will be removed in v11, use sitehandling instead.', E_USER_DEPRECATED);
$domainResolver = GeneralUtility::makeInstance(LegacyDomainResolver::class);
foreach ($rootLine as $row) {
$domain = $domainResolver->matchRootPageId($row['uid']);
Expand Down
3 changes: 3 additions & 0 deletions Classes/HtmlContentExtractor.php
Expand Up @@ -94,6 +94,7 @@ class HtmlContentExtractor
*/
public function __construct($content)
{
// @extensionScannerIgnoreLine
$this->content = $content;
}

Expand Down Expand Up @@ -127,6 +128,7 @@ public function setConfiguration(TypoScriptConfiguration $configuration)
*/
public function getIndexableContent()
{
// @extensionScannerIgnoreLine
$content = self::cleanContent($this->content);
$content = trim($content);

Expand Down Expand Up @@ -211,6 +213,7 @@ public static function stripUnicodeRange($content, $start, $end)
*/
public function getContentMarkedForIndexing()
{
// @extensionScannerIgnoreLine
return $this->content;
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/IndexQueue/FrontendHelper/AuthorizationService.php
Expand Up @@ -27,7 +27,7 @@
use ApacheSolrForTypo3\Solr\Access\Rootline;
use ApacheSolrForTypo3\Solr\IndexQueue\PageIndexerRequestHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Sv\AbstractAuthenticationService;
use TYPO3\CMS\Core\Authentication\AbstractAuthenticationService;

/**
* Authentication service to authorize the Index Queue page indexer to access
Expand Down
15 changes: 4 additions & 11 deletions Classes/IndexQueue/Indexer.php
Expand Up @@ -37,6 +37,7 @@
use ApacheSolrForTypo3\Solr\Util;
use Solarium\Exception\HttpException;
use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\RootlineUtility;
use TYPO3\CMS\Frontend\Page\PageRepository;
Expand Down Expand Up @@ -203,7 +204,9 @@ protected function getFullItemRecord(Item $item, $language = 0)
{
Util::initializeTsfe($item->getRootPageUid(), $language);

$systemLanguageContentOverlay = $GLOBALS['TSFE']->sys_language_contentOL;
$languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');

$systemLanguageContentOverlay = $languageAspect->getLegacyOverlayType();
$itemRecord = $this->getItemRecordOverlayed($item, $language, $systemLanguageContentOverlay);

/*
Expand Down Expand Up @@ -618,16 +621,6 @@ private function getDefaultLanguageUid(Item $item, array $rootPage, array $siteL
return $defaultLanguageUid;
}

/**
* Returns an array of system languages.
*
* @return array
*/
protected function getSystemLanguages()
{
return GeneralUtility::makeInstance(TranslationConfigurationProvider::class)->getSystemLanguages();
}

/**
* Checks for which languages connections have been configured and returns
* these connections.
Expand Down
2 changes: 2 additions & 0 deletions Classes/IndexQueue/Initializer/Page.php
Expand Up @@ -199,6 +199,7 @@ protected function validateMountPage(array $mountPage)
'Failed to initialize Mount Page tree. ',
FlashMessage::ERROR
);
// @extensionScannerIgnoreLine
$this->flashMessageQueue->addMessage($flashMessage);
}

Expand All @@ -215,6 +216,7 @@ protected function validateMountPage(array $mountPage)
'Failed to initialize Mount Page tree. ',
FlashMessage::ERROR
);
// @extensionScannerIgnoreLine
$this->flashMessageQueue->addMessage($flashMessage);
}

Expand Down
Empty file.
2 changes: 1 addition & 1 deletion Classes/System/Configuration/ExtensionConfiguration.php
Expand Up @@ -48,7 +48,7 @@ class ExtensionConfiguration
public function __construct($configurationToUse = [])
{
if (empty($configurationToUse)) {
$this->configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['solr']);
$this->configuration = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('solr');
} else {
$this->configuration = $configurationToUse;
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/System/Language/FrontendOverlayService.php
Expand Up @@ -27,7 +27,6 @@

use ApacheSolrForTypo3\Solr\System\TCA\TCAService;
use ApacheSolrForTypo3\Solr\Util;
use Doctrine\DBAL\Driver\Statement;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
Expand Down Expand Up @@ -69,9 +68,11 @@ public function __construct(TCAService $tcaService = null, TypoScriptFrontendCon
public function getOverlay($tableName, $record)
{
if ($tableName === 'pages') {
// @extensionScannerIgnoreLine
return $this->tsfe->sys_page->getPageOverlay($record, Util::getLanguageUid());
}

// @extensionScannerIgnoreLine
return $this->tsfe->sys_page->getRecordOverlay($tableName, $record, Util::getLanguageUid());
}

Expand Down
3 changes: 2 additions & 1 deletion Classes/System/Solr/Service/AbstractSolrService.php
Expand Up @@ -231,6 +231,7 @@ protected function buildLogDataFromResponse(ResponseAdapter $solrResponse, \Exce
return $logData;
} else {
// trigger data parsing
// @extensionScannerIgnoreLine
$solrResponse->response;
$logData['response data'] = print_r($solrResponse, true);
return $logData;
Expand Down Expand Up @@ -364,4 +365,4 @@ protected function buildSolariumRequestFromUrl($url, $httpMethod = Request::METH
$request->setHandler($handler);
return $request;
}
}
}
6 changes: 4 additions & 2 deletions Classes/Task/IndexQueueWorkerTaskAdditionalFieldProvider.php
Expand Up @@ -30,6 +30,7 @@
use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
use TYPO3\CMS\Scheduler\Task\AbstractTask;
use TYPO3\CMS\Scheduler\Task\Enumeration\Action;

/**
* Additional field provider for the index queue worker task
Expand Down Expand Up @@ -75,13 +76,14 @@ public function getAdditionalFields(
return $additionalFields;
}

if ($schedulerModule->CMD === 'add') {
$currentAction = $schedulerModule->getCurrentAction();
if ($currentAction->equals(Action::ADD)) {
$taskInfo['site'] = null;
$taskInfo['documentsToIndexLimit'] = 50;
$taskInfo['forcedWebRoot'] = '';
}

if ($schedulerModule->CMD === 'edit') {
if ($currentAction->equals(Action::EDIT)) {
$taskInfo['site'] = $this->siteRepository->getSiteByRootPageId($task->getRootPageId());
$taskInfo['documentsToIndexLimit'] = $task->getDocumentsToIndexLimit();
$taskInfo['forcedWebRoot'] = $task->getForcedWebRoot();
Expand Down
5 changes: 4 additions & 1 deletion Classes/Task/ReIndexTaskAdditionalFieldProvider.php
Expand Up @@ -35,6 +35,7 @@
use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
use TYPO3\CMS\Scheduler\Task\AbstractTask;
use TYPO3\CMS\Scheduler\Task\Enumeration\Action;

/**
* Adds an additional field to specify the Solr server to initialize the index queue for
Expand Down Expand Up @@ -106,7 +107,9 @@ protected function initialize(
$this->task = $task;
$this->schedulerModule = $schedulerModule;

if ($schedulerModule->CMD === 'edit') {
$currentAction = $schedulerModule->getCurrentAction();

if ($currentAction->equals(Action::EDIT)) {
$this->site = $this->siteRepository->getSiteByRootPageId($task->getRootPageId());
}
}
Expand Down
3 changes: 3 additions & 0 deletions Classes/Typo3PageContentExtractor.php
Expand Up @@ -47,6 +47,7 @@ class Typo3PageContentExtractor extends HtmlContentExtractor
*/
public function getContentMarkedForIndexing()
{
// @extensionScannerIgnoreLine
return $this->extractContentMarkedForIndexing($this->content);
}

Expand Down Expand Up @@ -127,6 +128,7 @@ public function excludeContentByClass($indexableContent)
*/
public function getIndexableContent()
{
// @extensionScannerIgnoreLine
$content = $this->extractContentMarkedForIndexing($this->content);

// clean content
Expand Down Expand Up @@ -165,6 +167,7 @@ public function getPageTitle()
*/
public function getPageBody()
{
// @extensionScannerIgnoreLine
$pageContent = $this->content;

return stristr($pageContent, '<body');
Expand Down
Expand Up @@ -18,6 +18,7 @@
use ApacheSolrForTypo3\Solr\Domain\Search\Score\ScoreCalculationService;
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSet;
use ApacheSolrForTypo3\Solr\ViewHelpers\AbstractSolrFrontendViewHelper;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
Expand Down Expand Up @@ -63,7 +64,8 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
$content = '';
// only check whether a BE user is logged in, don't need to check
// for enabled score analysis as we wouldn't be here if it was disabled
if (empty($GLOBALS['TSFE']->beUserLogin)) {
$backendUserIsLoggedIn = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('backend.user', 'isLoggedIn');
if ($backendUserIsLoggedIn === false) {
return $content;
}

Expand Down
5 changes: 4 additions & 1 deletion Classes/ViewHelpers/Debug/QueryViewHelper.php
Expand Up @@ -15,6 +15,8 @@
*/

use ApacheSolrForTypo3\Solr\ViewHelpers\AbstractSolrFrontendViewHelper;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;

Expand Down Expand Up @@ -43,7 +45,8 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
{
$content = '';
$resultSet = self::getUsedSearchResultSetFromRenderingContext($renderingContext);
if (!empty($GLOBALS['TSFE']->beUserLogin) && $resultSet && $resultSet->getUsedSearch() !== null) {
$backendUserIsLoggedIn = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('backend.user', 'isLoggedIn');
if ($backendUserIsLoggedIn === true && $resultSet && $resultSet->getUsedSearch() !== null) {
$content = '<br><strong>Parsed Query:</strong><br>' . htmlspecialchars($resultSet->getUsedSearch()->getDebugResponse()->parsedquery);
}
return $content;
Expand Down
11 changes: 10 additions & 1 deletion Classes/ViewHelpers/SearchFormViewHelper.php
Expand Up @@ -115,17 +115,26 @@ public function render()
$this->tag->addAttribute('accept-charset', $this->frontendController->metaCharset);

// Get search term
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('q', $this->getQueryString());
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('pageUid', $pageUid);
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('languageUid', Util::getLanguageUid());
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('existingParameters', $this->getExistingSearchParameters());

// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->add('addPageAndLanguageId', !$this->getIsSiteManagedSite($pageUid));
$formContent = $this->renderChildren();
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('addPageAndLanguageId');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('q');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('pageUid');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('languageUid');
// @extensionScannerIgnoreLine
$this->getTemplateVariableContainer()->remove('existingParameters');

$this->tag->setContent($formContent);
Expand Down
Empty file.

This file was deleted.

0 comments on commit 7d0241d

Please sign in to comment.