Skip to content

Commit

Permalink
Merge pull request #22 from jweiland-net/typo3_13_compatibility
Browse files Browse the repository at this point in the history
Typo3 13 compatibility
  • Loading branch information
hojalatheef authored Dec 5, 2024
2 parents 38e60e4 + e4ebe4b commit 11d4e5a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 26 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:

matrix:
php:
- '8.1'
- '8.2'
- '8.3'

Expand Down
2 changes: 1 addition & 1 deletion Classes/Command/NotifySearchEngineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$errors = 0;
foreach ($this->stackRepository->findAll() as $urlRecord) {
$total++;
$url = trim($urlRecord['url']);
$url = trim($urlRecord['url'] ?? '');

if ($url === '') {
$this->stackRepository->deleteByUid((int)$urlRecord['uid']);
Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Repository/StackRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace JWeiland\IndexNow\Domain\Repository;

use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;

/**
Expand Down Expand Up @@ -43,7 +44,7 @@ public function deleteByUid(int $uid): void
->where(
$this->queryBuilder->expr()->eq(
'uid',
$this->queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
$this->queryBuilder->createNamedParameter($uid, Connection::PARAM_INT)
)
)
->executeStatement();
Expand Down
21 changes: 6 additions & 15 deletions Classes/Event/ModifyPageUidEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,18 @@
*/
class ModifyPageUidEvent
{
private array $record;

private string $table;

private int $pageUid;

private ?array $pageRecord;

/**
* @param array $record This is the record, which is requested to be stored. Coming from DataHandler.
* @param string $table This is the table name where the record will be stored
* @param int $pageUid This is the page UID. We will use it to create a preview URL for IndexNow request. Set it to 0 to prevent informing IndexNow.
* @param array|null $pageRecord To keep your life easy we provide you the full page record. Be careful, in rare cases it can be NULL!
*/
public function __construct(array $record, string $table, int $pageUid, ?array $pageRecord)
{
$this->record = $record;
$this->table = $table;
$this->pageUid = $pageUid;
$this->pageRecord = $pageRecord;
}
public function __construct(
private readonly array $record,
private readonly string $table,
private int $pageUid,
private readonly ?array $pageRecord
) {}

public function getRecord(): array
{
Expand Down
4 changes: 2 additions & 2 deletions Classes/Hook/DataHandlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function processDatamap_beforeStart(DataHandler $dataHandler): void
$this->stackRepository->insert(
$this->getUrlForSearchEngineEndpoint($url)
);
} catch (ApiKeyNotAvailableException $apiKeyNotAvailableException) {
} catch (ApiKeyNotAvailableException) {
$this->sendBackendNotification(
'Missing API key',
'Please set an API key for EXT:indexnow in extension settings',
Expand Down Expand Up @@ -129,7 +129,7 @@ protected function getPreviewUrl(int $pageUid): ?string
->withAdditionalQueryParameters($additionalParams)
->buildUri()
);
} catch (UnableToLinkToPageException $e) {
} catch (UnableToLinkToPageException) {
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"typo3/cms-core": "^12.4.15"
"typo3/cms-core": "^12.4.15 || ^13.4.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.44",
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
'author' => 'Stefan Froemken',
'author_email' => 'sfroemken@jweiland.net',
'state' => 'experimental',
'version' => '0.0.5',
'version' => '0.0.6',
'constraints' => [
'depends' => [
'typo3' => '12.4.15-12.4.99',
'typo3' => '12.4.15-13.4.99',
],
'conflicts' => [],
'suggests' => [],
Expand Down
10 changes: 7 additions & 3 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
* LICENSE file that was distributed with this source code.
*/

use JWeiland\IndexNow\Hook\DataHandlerHook;
use Psr\Log\LogLevel;
use TYPO3\CMS\Core\Log\Writer\FileWriter;

if (!defined('TYPO3')) {
die('Access denied.');
}

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['indexnow']
= \JWeiland\IndexNow\Hook\DataHandlerHook::class;
= DataHandlerHook::class;

$GLOBALS['TYPO3_CONF_VARS']['LOG']['JWeiland']['IndexNow']['writerConfiguration'] = [
\Psr\Log\LogLevel::WARNING => [
\TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
LogLevel::WARNING => [
FileWriter::class => [
'logFileInfix' => 'indexnow',
],
],
Expand Down

0 comments on commit 11d4e5a

Please sign in to comment.