Skip to content

Commit

Permalink
[!!!][TASK] Remove deprecated functionality
Browse files Browse the repository at this point in the history
This change removes deprecated features of EXT:solr

a) PageDocumentPostProcessor

The interface PageDocumentPostProcessor
is removed, along with the registration
in ext_localconf.php.

The PostProcessor is now removed in favor
of the PageIndexerDocumentsModifier interface,
and can be used already in EXT:solr v11.

Check in your extensions' ext_localconf.php
and look for
`$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPagePostProcessPageDocument']`
to see if you are affected.

In addition, some rather unintrusive, deprecated
methods in UrlHelper have been removed
as UrlHelper is just a small
extension for UriInterface, and might
vanish altogether in the future.

Relates: #3376
  • Loading branch information
bmack authored and dkd-kaehm committed May 30, 2023
1 parent 15891e1 commit 192664d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ protected function applyTypoScriptOverridesOnIndexingUrl(UrlHelper $urlHelper, a
{
// check whether we should use ssl / https
if (!empty($overrideConfiguration['scheme'])) {
$urlHelper->setScheme($overrideConfiguration['scheme']);
$urlHelper = $urlHelper->withScheme($overrideConfiguration['scheme']);
}

// overwriting the host
if (!empty($overrideConfiguration['host'])) {
$urlHelper->setHost($overrideConfiguration['host']);
$urlHelper = $urlHelper->withHost($overrideConfiguration['host']);
}

// overwriting the port
if (!empty($overrideConfiguration['port'])) {
$urlHelper->setPort((int)$overrideConfiguration['port']);
$urlHelper = $urlHelper->withPort((int)$overrideConfiguration['port']);
}

// setting a path if TYPO3 is installed in a subdirectory
if (!empty($overrideConfiguration['path'])) {
$urlHelper->setPath($overrideConfiguration['path']);
$urlHelper = $urlHelper->withPath($overrideConfiguration['path']);
}

return $urlHelper;
Expand All @@ -75,7 +75,7 @@ public function getPageIndexingUriFromPageItemAndLanguageId(
$urlHelper = GeneralUtility::makeInstance(UrlHelper::class, $pageIndexUri);
$overrideConfiguration = $options['frontendDataHelper.'] ?? [];
$urlHelper = $this->applyTypoScriptOverridesOnIndexingUrl($urlHelper, $overrideConfiguration);
$dataUrl = $urlHelper->getUrl();
$dataUrl = (string)$urlHelper;

if (!GeneralUtility::isValidUrl($dataUrl)) {
$this->logger->log(
Expand Down
41 changes: 0 additions & 41 deletions Classes/PageDocumentPostProcessor.php

This file was deleted.

99 changes: 0 additions & 99 deletions Classes/System/Url/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace ApacheSolrForTypo3\Solr\System\Url;

use InvalidArgumentException;
use TYPO3\CMS\Core\Http\Uri;

/**
Expand All @@ -25,57 +24,6 @@
*/
class UrlHelper extends Uri
{
/**
* @deprecated Will be removed with v12. Use withHost instead.
* @see Uri::withHost()
*/
public function setHost(string $host): UrlHelper
{
$this->host = $host;
return $this;
}

/**
* @deprecated Will be removed with v12. Use withPort instead.
* @see Uri::withPort()
*/
public function setPort(int $port): UrlHelper
{
if ($port < 1 || $port > 65535) {
throw new InvalidArgumentException('Invalid port "' . $port . '" specified, must be a valid TCP/UDP port.', 1436717326);
}

$this->port = $port;
return $this;
}

/**
* @deprecated Will be removed with v12. Use Uri::withScheme instead.
* @see Uri::withScheme()
*/
public function setScheme(string $scheme): UrlHelper
{
$this->scheme = $this->sanitizeScheme($scheme);
return $this;
}

/**
* @deprecated Will be removed with v12. Use withPath instead.
* @see Uri::withPath()
*/
public function setPath(string $path): UrlHelper
{
if (str_contains($path, '?')) {
throw new InvalidArgumentException('Invalid path provided. Must not contain a query string.', 1436717330);
}

if (str_contains($path, '#')) {
throw new InvalidArgumentException('Invalid path provided; must not contain a URI fragment', 1436717332);
}
$this->path = $this->sanitizePath($path);
return $this;
}

/**
* Remove a given parameter from the query and create a new instance.
*/
Expand All @@ -95,25 +43,6 @@ public function withoutQueryParameter(string $parameterName): UrlHelper
return $clonedObject;
}

/**
* @throws InvalidArgumentException
* @deprecated Will be removed with v12. Use {@link withoutQueryParameter()} instead.
*/
public function removeQueryParameter(string $parameterName): UrlHelper
{
parse_str($this->query, $parameters);
if (isset($parameters[$parameterName])) {
unset($parameters[$parameterName]);
}
$query = '';
if (!empty($parameters)) {
$query = http_build_query($parameters);
}
$this->query = $this->sanitizeQuery($query);

return $this;
}

/**
* Add a given parameter with value to the query and create a new instance.
*/
Expand All @@ -130,32 +59,4 @@ public function withQueryParameter(string $parameterName, $value): UrlHelper
$clonedObject->query = $query;
return $clonedObject;
}

/**
* @throws InvalidArgumentException
* @deprecated Will be removed with v12. Use {@link withQueryParameter()} instead.
*/
public function addQueryParameter(string $parameterName, $value): UrlHelper
{
$parameters = $this->query;
parse_str($this->query, $parameters);
if (empty($parameters)) {
$parameters = [];
}
$parameters[$parameterName] = $value;
$query = '';
if (!empty($parameters)) {
$query = http_build_query($parameters);
}
$this->query = $this->sanitizeQuery($query);
return $this;
}

/**
* @deprecated Will be removed with v12. Use {@link __toString()} instead.
*/
public function getUrl(): string
{
return $this->__toString();
}
}
31 changes: 0 additions & 31 deletions Classes/Typo3PageIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ public function indexPage(): bool
$pageDocument = $this->getPageDocument();
$pageDocument = $this->substitutePageDocument($pageDocument);

$this->applyIndexPagePostProcessors($pageDocument);

self::$pageSolrDocument = $pageDocument;
$documents[] = $pageDocument;
$documents = $this->getAdditionalDocuments($pageDocument, $documents);
Expand All @@ -236,32 +234,6 @@ public function indexPage(): bool
return $pageIndexed;
}

/**
* Applies the configured post processors (indexPagePostProcessPageDocument)
*
* @deprecated
*/
protected function applyIndexPagePostProcessors(Document $pageDocument): void
{
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPagePostProcessPageDocument'] ?? null)) {
return;
}

trigger_error(
"The hook indexPagePostProcessPageDocument has been superseded by \$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['preAddModifyDocuments']",
E_USER_DEPRECATED
);

foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPagePostProcessPageDocument'] as $classReference) {
$postProcessor = GeneralUtility::makeInstance($classReference);
if (!$postProcessor instanceof PageDocumentPostProcessor) {
throw new UnexpectedValueException(get_class($pageDocument) . ' must implement interface ' . PageDocumentPostProcessor::class, 1397739154);
}

$postProcessor->postProcessPageDocument($pageDocument, $this->page);
}
}

/**
* Builds the Solr document for the current page.
*
Expand All @@ -280,9 +252,6 @@ protected function getPageDocument(): Document
return $document;
}

// Logging
// TODO replace by a central logger

/**
* Gets the mount point parameter that is used in the Frontend controller.
*/
Expand Down
10 changes: 0 additions & 10 deletions Documentation/Development/Indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ Registered classes can be used to replace/substitute a Solr document of a page.
Registration with: $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageSubstitutePageDocument']
Required Interface: SubstitutePageIndexer

indexPagePostProcessPageDocument
--------------------------------

This is deprecated in favor of preAddModifyDocuments.

Registered classes can be used to post process a Solr document of a page.

Registration with: $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPagePostProcessPageDocument']
Required Interface: PageDocumentPostProcessor


preAddModifyDocuments
---------------------
Expand Down
37 changes: 0 additions & 37 deletions Tests/Integration/IndexQueue/FrontendHelper/TestPostProcessor.php

This file was deleted.

55 changes: 6 additions & 49 deletions Tests/Unit/System/Url/UrlHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
*/
class UrlHelperTest extends SetUpUnitTestCase
{
/**
* @return array
*/
public function removeQueryParameter()
public function withoutQueryParameter(): array
{
return [
'cHash at the end' => [
Expand Down Expand Up @@ -59,14 +56,14 @@ public function removeQueryParameter()
];
}
/**
* @dataProvider removeQueryParameter
* @dataProvider withoutQueryParameter
* @test
*/
public function testCanRemoveQueryParameter($input, $queryParameterToRemove, $expectedUrl)
{
$urlHelper = new UrlHelper($input);
$urlHelper->removeQueryParameter($queryParameterToRemove);
self::assertSame($expectedUrl, $urlHelper->getUrl(), 'Can not remove query parameter as expected');
$urlHelper = $urlHelper->withoutQueryParameter($queryParameterToRemove);
self::assertSame($expectedUrl, (string)$urlHelper, 'Can not remove query parameter as expected');
}

/**
Expand All @@ -91,47 +88,7 @@ public function getUrl()
public function testGetUrl($inputUrl, $expectedOutputUrl)
{
$urlHelper = new UrlHelper($inputUrl);
self::assertSame($expectedOutputUrl, $urlHelper->getUrl(), 'Can not get expected output url');
}

/**
* @test
*/
public function testSetHost()
{
$urlHelper = new UrlHelper('http://www.google.de/test/index.php?foo=bar');
$urlHelper->setHost('www.test.de');
self::assertSame('http://www.test.de/test/index.php?foo=bar', $urlHelper->getUrl());
}

/**
* @test
*/
public function testSetHostWithPort()
{
$urlHelper = new UrlHelper('http://www.google.de/test/index.php?foo=bar');
$urlHelper->setHost('www.test.de:8080');
self::assertSame('http://www.test.de:8080/test/index.php?foo=bar', $urlHelper->getUrl());
}

/**
* @test
*/
public function testSetScheme()
{
$urlHelper = new UrlHelper('http://www.google.de/test/index.php?foo=bar');
$urlHelper->setScheme('https');
self::assertSame('https://www.google.de/test/index.php?foo=bar', $urlHelper->getUrl());
}

/**
* @test
*/
public function testSetPath()
{
$urlHelper = new UrlHelper('http://www.google.de/one/two?foo=bar');
$urlHelper->setPath('/one/two');
self::assertSame('http://www.google.de/one/two?foo=bar', $urlHelper->getUrl());
self::assertSame($expectedOutputUrl, (string)$urlHelper, 'Can not get expected output url');
}

public function unmodifiedUrl()
Expand All @@ -149,7 +106,7 @@ public function unmodifiedUrl()
public function testGetUnmodifiedUrl($uri)
{
$urlHelper = new UrlHelper($uri);
self::assertSame($uri, $urlHelper->getUrl(), 'Could not get unmodified url');
self::assertSame($uri, (string)$urlHelper, 'Could not get unmodified url');
}

/**
Expand Down

0 comments on commit 192664d

Please sign in to comment.