From 4e77a8f8b734d13ff4937dc4c7a9a5ca71e10865 Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Thu, 10 Oct 2024 12:40:48 +0200 Subject: [PATCH] [MAINTENANCE] Add support for Typo3 v12 (fixes #900) (#1337) Co-authored-by: Sebastian Meyer --- .github/phpstan.neon | 1 - .github/workflows/tests.yml | 8 +- Build/Test/runTests.sh | 4 +- Classes/Command/BaseCommand.php | 2 +- Classes/Common/Helper.php | 12 +- Classes/Common/KitodoFlashMessageRenderer.php | 27 ++++- Classes/Common/Solr/SolrSearch.php | 18 +++ Classes/Common/Solr/SolrSearchQuery.php | 69 +---------- Classes/Controller/AbstractController.php | 20 +++- Classes/Controller/AnnotationController.php | 8 +- Classes/Controller/AudioPlayerController.php | 9 +- .../Backend/NewTenantController.php | 109 +++++++++--------- Classes/Controller/BasketController.php | 41 ++++--- Classes/Controller/CalendarController.php | 30 +++-- Classes/Controller/CollectionController.php | 29 +++-- .../Controller/Embedded3dViewerController.php | 8 +- Classes/Controller/FeedsController.php | 11 +- Classes/Controller/ListViewController.php | 11 +- Classes/Controller/MetadataController.php | 11 +- Classes/Controller/NavigationController.php | 17 ++- Classes/Controller/OaiPmhController.php | 12 +- Classes/Controller/PageGridController.php | 9 +- Classes/Controller/PageViewController.php | 29 ++--- Classes/Controller/SearchController.php | 25 ++-- Classes/Controller/StatisticsController.php | 7 +- .../Controller/TableOfContentsController.php | 9 +- Classes/Controller/ToolboxController.php | 7 +- Classes/Domain/Model/PageSelectForm.php | 2 +- .../Repository/CollectionRepository.php | 14 +-- .../Domain/Repository/DocumentRepository.php | 10 +- .../Domain/Repository/MetadataRepository.php | 2 +- Classes/Domain/Repository/TokenRepository.php | 2 +- .../DocumentTypeFunctionProvider.php | 6 - Classes/Hooks/DataHandler.php | 29 +---- Classes/Hooks/ItemsProcFunc.php | 6 +- Classes/Updates/FileLocationUpdater.php | 1 - Classes/Validation/AbstractDlfValidator.php | 4 +- Configuration/Backend/Modules.php | 33 ++++++ Configuration/Services.yaml | 9 ++ Configuration/TCA/Overrides/sys_template.php | 2 +- Configuration/TCA/Overrides/tt_content.php | 4 +- Configuration/TCA/tx_dlf_collections.php | 1 - Configuration/TypoScript/setup.typoscript | 2 +- README.md | 10 +- .../Partials/TableOfContents/Children.html | 4 +- .../Templates/Backend/NewTenant/Index.html | 4 + .../Private/Templates/Navigation/Main.html | 26 ++--- Resources/Private/Templates/OaiPmh/Main.xml | 9 +- Tests/Fixtures/Common/pages.csv | 6 +- Tests/Fixtures/Common/pages.xml | 12 -- Tests/Fixtures/OaiPmh/pages.xml | 32 ----- Tests/Functional/Api/OaiPmhTest.php | 2 +- Tests/Functional/FunctionalTestCase.php | 27 ++--- .../ViewHelpers/JsFooterViewHelperTest.php | 4 +- .../MetadataWrapVariableViewHelperTest.php | 2 +- .../ViewHelpers/StdWrapViewHelperTest.php | 2 +- composer.json | 21 ++-- ext_emconf.php | 2 +- ext_localconf.php | 2 +- ext_tables.php | 37 +++--- ext_tables.sql | 2 +- 61 files changed, 455 insertions(+), 419 deletions(-) create mode 100644 Configuration/Backend/Modules.php diff --git a/.github/phpstan.neon b/.github/phpstan.neon index 86b7418e6d..fcfc7e1576 100644 --- a/.github/phpstan.neon +++ b/.github/phpstan.neon @@ -23,7 +23,6 @@ parameters: - '#Constant LOG_SEVERITY_ERROR not found\.#' - '#Constant LOG_SEVERITY_NOTICE not found\.#' - '#Constant LOG_SEVERITY_WARNING not found\.#' - - '#Constant TYPO3_MODE not found\.#' level: 5 paths: - ../Classes/ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 52e4a0e4ac..bdf7bee45c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,19 +12,19 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - typo3: [ 10.4, 11.5 ] + variants: [ {typo3: 11.5, php: 7.4}, {typo3: 12.4, php: 8.1} ] steps: - name: Checkout code uses: actions/checkout@v4 - name: Install dependencies - run: Build/Test/runTests.sh -s composerInstall -t ${{ matrix.typo3 }} + run: Build/Test/runTests.sh -s composerInstall -t ${{ matrix.variants.typo3 }} -p ${{ matrix.variants.php }} - name: Run unit tests - run: Build/Test/runTests.sh -s unit + run: Build/Test/runTests.sh -s unit -p ${{ matrix.variants.php }} - name: Run functional tests - run: Build/Test/runTests.sh -s functional + run: Build/Test/runTests.sh -s functional -p ${{ matrix.variants.php }} - name: Upload coverage reports uses: codecov/codecov-action@v4 diff --git a/Build/Test/runTests.sh b/Build/Test/runTests.sh index 7b5483d1ca..bf35b7ff2d 100755 --- a/Build/Test/runTests.sh +++ b/Build/Test/runTests.sh @@ -74,12 +74,12 @@ Options: - functional: PHP functional tests - unit (default): PHP unit tests - -t <|10.4|11.5> + -t <|11.5|12.4> Only with -s composerInstall Specifies which TYPO3 version to install. When unset, installs either the packages from composer.lock, or the latest version otherwise (default behavior of "composer install"). - - 10.4 - 11.5 + - 12.4 -a Only with -s functional diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index b9e5dc9e38..cdee66da0d 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -146,7 +146,7 @@ protected function initializeRepositories(int $storagePid): void * * @return int matching uid of Solr core */ - protected function getSolrCoreUid(array $solrCores, $inputSolrId): int + protected function getSolrCoreUid(array $solrCores, $inputSolrId): ?int { if (MathUtility::canBeInterpretedAsInteger($inputSolrId)) { $solrCoreUid = MathUtility::forceIntegerInRange((int) $inputSolrId, 0); diff --git a/Classes/Common/Helper.php b/Classes/Common/Helper.php index 6037a96bba..72815a62f0 100644 --- a/Classes/Common/Helper.php +++ b/Classes/Common/Helper.php @@ -14,8 +14,10 @@ use TYPO3\CMS\Core\Configuration\ConfigurationManager; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Http\Uri; +use TYPO3\CMS\Core\Http\ApplicationType; use TYPO3\CMS\Core\Http\RequestFactory; use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Context\Context; @@ -583,7 +585,7 @@ public static function processDatabaseAsAdmin(array $data = [], array $cmd = [], $context = GeneralUtility::makeInstance(Context::class); if ( - \TYPO3_MODE === 'BE' + ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && $context->getPropertyFromAspect('backend.user', 'isAdmin') ) { // Instantiate TYPO3 core engine. @@ -783,8 +785,7 @@ public static function translate(string $indexName, string $table, string $pid): */ public static function whereExpression(string $table, bool $showHidden = false): string { - // TODO: Check with applicationType; TYPO3_MODE is removed in v12 - if (\TYPO3_MODE === 'FE') { + if (!Environment::isCli() && ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) { // Should we ignore the record's hidden flag? $ignoreHide = 0; if ($showHidden) { @@ -799,14 +800,13 @@ public static function whereExpression(string $table, bool $showHidden = false): } else { return ''; } - // TODO: Check with applicationType; TYPO3_MODE is removed in v12 - } elseif (\TYPO3_MODE === 'BE') { + } elseif (Environment::isCli() || ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) { return GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable($table) ->expr() ->eq($table . '.' . $GLOBALS['TCA'][$table]['ctrl']['delete'], 0); } else { - self::log('Unexpected TYPO3_MODE', LOG_SEVERITY_ERROR); + self::log('Unexpected application type (neither frontend or backend)', LOG_SEVERITY_ERROR); return '1=-1'; } } diff --git a/Classes/Common/KitodoFlashMessageRenderer.php b/Classes/Common/KitodoFlashMessageRenderer.php index d47e915741..d9acb0c819 100644 --- a/Classes/Common/KitodoFlashMessageRenderer.php +++ b/Classes/Common/KitodoFlashMessageRenderer.php @@ -33,6 +33,7 @@ class KitodoFlashMessageRenderer implements FlashMessageRendererInterface * @var array The message severity class names */ protected static array $classes = [ + // Todo: FlashMessage constants deprecated in v12, remove when dropping v11 support FlashMessage::NOTICE => 'notice', FlashMessage::INFO => 'info', FlashMessage::OK => 'success', @@ -44,6 +45,7 @@ class KitodoFlashMessageRenderer implements FlashMessageRendererInterface * @var array The message severity icon names */ protected static array $icons = [ + // Todo: FlashMessage constants deprecated in v12, remove when dropping v11 support FlashMessage::NOTICE => 'lightbulb-o', FlashMessage::INFO => 'info', FlashMessage::OK => 'check', @@ -65,6 +67,27 @@ public function render(array $flashMessages): string return $this->getMessageAsMarkup($flashMessages); } + /** + * Gets the message severity as integer value for compatibility with Typo3 v12 + * + * @access public + * + * @param FlashMessage $flashMessage + * + * @return int The message severity as integer + */ + protected function getSeverityAsInt(FlashMessage $flashMessage): int + { + $severity = $flashMessage->getSeverity(); + if (is_int($severity)) { + // $severity is integer constant from FlashMessage in Typo3 v11 + return $severity; + } + // $severity is instance of ContextualFeedbackSeverity enum introduced in Typo3 v12 + // TODO: migrate message severity to ContextualFeedbackSeverity when dropping support for Typo3 v11 + return $severity->value; + } + /** * Gets the message severity class name * @@ -76,7 +99,7 @@ public function render(array $flashMessages): string */ protected function getClass(FlashMessage $flashMessage): string { - return 'alert-' . self::$classes[$flashMessage->getSeverity()]; + return 'alert-' . self::$classes[$this->getSeverityAsInt($flashMessage)]; } /** @@ -90,7 +113,7 @@ protected function getClass(FlashMessage $flashMessage): string */ protected function getIconName(FlashMessage $flashMessage): string { - return self::$icons[$flashMessage->getSeverity()]; + return self::$icons[$this->getSeverityAsInt($flashMessage)]; } /** diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index 7047faaa2d..03bd976852 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -2,6 +2,7 @@ namespace Kitodo\Dlf\Common\Solr; +use Exception; use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Indexer; @@ -13,6 +14,7 @@ use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; +use TYPO3\CMS\Extbase\Persistence\QueryInterface; /** * Targeted towards being used in ``PaginateController`` (````). @@ -318,6 +320,22 @@ public function getQuery() return new SolrSearchQuery($this); } + /** + * Sets query. + * + * @access public + * + * @param QueryInterface $query the query + * + * @throws Exception not implemented + * + * @return void + */ + public function setQuery(QueryInterface $query): void + { + throw new Exception("setQuery not supported on SolrSearch instance"); + } + /** * Gets first. * diff --git a/Classes/Common/Solr/SolrSearchQuery.php b/Classes/Common/Solr/SolrSearchQuery.php index 33419e226f..f1da660785 100644 --- a/Classes/Common/Solr/SolrSearchQuery.php +++ b/Classes/Common/Solr/SolrSearchQuery.php @@ -3,9 +3,7 @@ namespace Kitodo\Dlf\Common\Solr; use TYPO3\CMS\Extbase\Persistence\QueryInterface; -use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface; -use TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface; -use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface; +use TYPO3\CMS\Extbase\Persistence\Generic\Query; /** * Targeted towards being used in ``PaginateController`` (````). @@ -18,7 +16,7 @@ * @property int $limit * @property int $offset */ -class SolrSearchQuery implements QueryInterface +class SolrSearchQuery extends Query { /** * @access private @@ -27,18 +25,6 @@ class SolrSearchQuery implements QueryInterface private SolrSearch $solrSearch; /** - * @access private - * @var int - */ - private int $limit; - - /** - * @access private - * @var int - */ - private int $offset; - - /** * Constructs SolrSearchQuery instance. * * @access public @@ -55,10 +41,6 @@ public function __construct($solrSearch) $this->limit = count($solrSearch); } - // this class contains a lot of methods which are inherited but not implemented - // @phpstan-ignore-next-line - public function getSource() {} - /** * Executes SOLR search query. * @@ -83,9 +65,6 @@ public function execute($returnRawQueryResult = false) return $result; } - // @phpstan-ignore-next-line - public function setOrderings(array $orderings) {} - /** * Sets limit for SOLR search query. * @@ -116,44 +95,6 @@ public function setOffset($offset): SolrSearchQuery return $this; } - // @phpstan-ignore-next-line - public function matching($constraint) {} - // @phpstan-ignore-next-line - public function logicalAnd($constraint1) {} - // @phpstan-ignore-next-line - public function logicalOr($constraint1) {} - // @phpstan-ignore-next-line - public function logicalNot(ConstraintInterface $constraint) {} - // @phpstan-ignore-next-line - public function equals($propertyName, $operand, $caseSensitive = true) {} - // @phpstan-ignore-next-line - public function like($propertyName, $operand) {} - // @phpstan-ignore-next-line - public function contains($propertyName, $operand) {} - // @phpstan-ignore-next-line - public function in($propertyName, $operand) {} - // @phpstan-ignore-next-line - public function lessThan($propertyName, $operand) {} - // @phpstan-ignore-next-line - public function lessThanOrEqual($propertyName, $operand) {} - // @phpstan-ignore-next-line - public function greaterThan($propertyName, $operand) {} - // @phpstan-ignore-next-line - public function greaterThanOrEqual($propertyName, $operand) {} - // @phpstan-ignore-next-line - public function getType() {} - public function setQuerySettings(QuerySettingsInterface $querySettings) {} - // @phpstan-ignore-next-line - public function getQuerySettings() {} - - public function count() - {// @phpstan-ignore-next-line - // TODO? - } - - // @phpstan-ignore-next-line - public function getOrderings() {} - /** * Gets limit for SOLR search query. * @@ -178,10 +119,4 @@ public function getOffset(): int return $this->offset; } - // @phpstan-ignore-next-line - public function getConstraint() {} - public function isEmpty($propertyName) {} - public function setSource(SourceInterface $source) {} - // @phpstan-ignore-next-line - public function getStatement() {} } diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 1ae9b6861e..8857722fb9 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -15,16 +15,19 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Domain\Model\Document; use Kitodo\Dlf\Domain\Repository\DocumentRepository; +use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Pagination\PaginationInterface; +use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Core\Pagination\PaginatorInterface; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use TYPO3\CMS\Extbase\Mvc\RequestInterface; /** * Abstract controller class for most of the plugin controller. @@ -99,10 +102,13 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) * * @access protected * + * @param RequestInterface $request the HTTP request + * * @return void */ - protected function initialize(): void + protected function initialize(RequestInterface $request): void { + // replace with $this->request->getQueryParams() when dropping support for Typo3 v11, see Deprecation-100596 $this->requestData = GeneralUtility::_GPmerged('tx_dlf'); $this->pageUid = (int) GeneralUtility::_GET('id'); @@ -386,15 +392,19 @@ protected function setDefaultPage(): void } /** - * This is the constructor + * Wrapper for ActionController::processRequest in order to initialize things + * without using a constructor. * * @access public * - * @return void + * @param RequestInterface $request the request + * + * @return ResponseInterface the response */ - public function __construct() + public function processRequest(RequestInterface $request): ResponseInterface { - $this->initialize(); + $this->initialize($request); + return parent::processRequest($request); } /** diff --git a/Classes/Controller/AnnotationController.php b/Classes/Controller/AnnotationController.php index 9d5b2a577f..5d5591ea24 100644 --- a/Classes/Controller/AnnotationController.php +++ b/Classes/Controller/AnnotationController.php @@ -13,6 +13,7 @@ */ use Kitodo\Dlf\Common\DocumentAnnotation; +use Psr\Http\Message\ResponseInterface; /** * Controller class for plugin 'Annotation'. @@ -26,9 +27,9 @@ class AnnotationController extends AbstractController /** * The main method of the plugin * - * @return void + * @return ResponseInterface the response */ - public function mainAction() + public function mainAction(): ResponseInterface { $this->loadDocument(); @@ -37,12 +38,13 @@ public function mainAction() || $this->document->getCurrentDocument() === null ) { // Quit without doing anything if required variables are not set. - return; } else { $documentAnnotation = DocumentAnnotation::getInstance($this->document); $this->view->assign('annotations', $documentAnnotation->getAnnotations()); $this->view->assign('currentPage', $this->requestData['page']); } + + return $this->htmlResponse(); } } diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index 1ac7dfc878..d78e86572c 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -11,6 +11,7 @@ namespace Kitodo\Dlf\Controller; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -71,15 +72,15 @@ protected function addPlayerJS(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // Load current document. $this->loadDocument(); if ($this->isDocMissingOrEmpty()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } $this->setDefaultPage(); @@ -103,5 +104,7 @@ public function mainAction(): void // Add jPlayer javascript. $this->addPlayerJS(); } + + return $this->htmlResponse(); } } diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index 2b5d0b64a4..600a84cc8f 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -20,17 +20,22 @@ use Kitodo\Dlf\Domain\Repository\MetadataRepository; use Kitodo\Dlf\Domain\Repository\SolrCoreRepository; use Kitodo\Dlf\Domain\Repository\StructureRepository; +use Psr\Http\Message\ResponseInterface; +use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Backend\View\BackendTemplateView; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Exception\SiteNotFoundException; use TYPO3\CMS\Core\Localization\LocalizationFactory; +use TYPO3\CMS\Core\Messaging\FlashMessageService; +use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Site\Entity\NullSite; use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; +use TYPO3\CMS\Extbase\Mvc\Request; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; +use TYPO3\CMS\Fluid\View\TemplateView; +use TYPO3Fluid\Fluid\View\ViewInterface; /** * Controller class for the backend module 'New Tenant'. @@ -66,12 +71,6 @@ class NewTenantController extends AbstractController */ protected LocalizationFactory $languageFactory; - /** - * @access protected - * @var string Backend Template Container - */ - protected $defaultViewObjectName = BackendTemplateView::class; - /** * @access protected * @var FormatRepository @@ -144,6 +143,27 @@ public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) $this->solrCoreRepository = $solrCoreRepository; } + /** + * Returns a response object with either the given html string or the current rendered view as content. + * + * @access protected + * + * @param ?string $html optional html + * + * @return ResponseInterface the response + */ + protected function htmlResponse(?string $html = null): ResponseInterface + { + $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); + $messageQueue = $flashMessageService->getMessageQueueByIdentifier(); + + $moduleTemplateFactory = GeneralUtility::makeInstance(ModuleTemplateFactory::class); + $moduleTemplate = $moduleTemplateFactory->create($this->request); + $moduleTemplate->setContent($this->view->render()); + $moduleTemplate->setFlashMessageQueue($messageQueue); + return parent::htmlResponse(($html ?? $moduleTemplate->renderContent())); + } + /** * Initialization for all actions * @@ -153,6 +173,7 @@ public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) */ protected function initializeAction(): void { + // replace with $this->request->getQueryParams() when dropping support for Typo3 v11, see Deprecation-100596 $this->pid = (int) GeneralUtility::_GP('id'); $frameworkConfiguration = $this->configurationManager->getConfiguration($this->configurationManager::CONFIGURATION_TYPE_FRAMEWORK); @@ -175,9 +196,9 @@ protected function initializeAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function addFormatAction(): void + public function addFormatAction(): ResponseInterface { // Include formats definition file. $formatsDefaults = $this->getRecords('Format'); @@ -209,7 +230,7 @@ public function addFormatAction(): void $persistenceManager->persistAll(); } - $this->forward('index'); + return $this->redirect('index'); } /** @@ -217,9 +238,9 @@ public function addFormatAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function addMetadataAction(): void + public function addMetadataAction(): ResponseInterface { // Include metadata definition file. $metadataDefaults = $this->getRecords('Metadata'); @@ -296,7 +317,7 @@ public function addMetadataAction(): void Helper::processDatabaseAsAdmin($translateData); } - $this->forward('index'); + return $this->redirect('index'); } /** @@ -304,9 +325,9 @@ public function addMetadataAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function addSolrCoreAction(): void + public function addSolrCoreAction(): ResponseInterface { $doPersist = false; @@ -332,7 +353,7 @@ public function addSolrCoreAction(): void $persistenceManager->persistAll(); } - $this->forward('index'); + return $this->redirect('index'); } /** @@ -340,9 +361,9 @@ public function addSolrCoreAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function addStructureAction(): void + public function addStructureAction(): ResponseInterface { // Include structure definition file. $structureDefaults = $this->getRecords('Structure'); @@ -387,29 +408,7 @@ public function addStructureAction(): void Helper::processDatabaseAsAdmin($translateData); } - $this->forward('index'); - } - - /** - * Set up the doc header properly here - * - * @access protected - * - * @param ViewInterface $view - * - * @return void - */ - protected function initializeView(ViewInterface $view): void - { - /** @var BackendTemplateView $view */ - parent::initializeView($view); - if ($this->actionMethodName == 'indexAction') { - $this->pageInfo = BackendUtility::readPageAccess($this->pid, $GLOBALS['BE_USER']->getPagePermsClause(1)); - $view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); - } - if ($view instanceof BackendTemplateView) { - $view->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal'); - } + return $this->redirect('index'); } /** @@ -417,14 +416,16 @@ protected function initializeView(ViewInterface $view): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function indexAction(): void + public function indexAction(): ResponseInterface { $recordInfos = []; - if ($this->pageInfo['doktype'] != 254) { - $this->forward('error'); + $this->pageInfo = BackendUtility::readPageAccess($this->pid, $GLOBALS['BE_USER']->getPagePermsClause(1)); + + if (!isset($this->pageInfo['doktype']) || $this->pageInfo['doktype'] != 254) { + return $this->redirect('error'); } $formatsDefaults = $this->getRecords('Format'); @@ -442,6 +443,8 @@ public function indexAction(): void $recordInfos['solrcore']['numCurrent'] = $this->solrCoreRepository->countByPid($this->pid); $this->view->assign('recordInfos', $recordInfos); + + return $this->htmlResponse(); } /** @@ -452,9 +455,9 @@ public function indexAction(): void * @return void */ // @phpstan-ignore-next-line - public function errorAction(): void + public function errorAction(): ResponseInterface { - // TODO: Call parent::errorAction() when dropping support for TYPO3 v10. + return $this->htmlResponse(); } /** @@ -490,13 +493,9 @@ private function getLLL(string $index, string $lang, array $langArray): string */ private function getRecords(string $recordType): array { - $filePath = Environment::getPublicPath() . '/typo3conf/ext/dlf/Resources/Private/Data/' . $recordType . 'Defaults.json'; - - $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class); - $fileObject = $resourceFactory->getFileObjectFromCombinedIdentifier($filePath); - - if ($fileObject !== null) { - $fileContents = $fileObject->getContents(); + $filePath = GeneralUtility::getFileAbsFileName('EXT:dlf/Resources/Private/Data/' . $recordType . 'Defaults.json'); + if (file_exists($filePath)) { + $fileContents = file_get_contents($filePath); $records = json_decode($fileContents, true); if (json_last_error() === JSON_ERROR_NONE) { diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index 2240cbd271..c4396da092 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -19,6 +19,7 @@ use Kitodo\Dlf\Domain\Repository\MailRepository; use Kitodo\Dlf\Domain\Repository\BasketRepository; use Kitodo\Dlf\Domain\Repository\PrinterRepository; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Mail\MailMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MailUtility; @@ -112,9 +113,9 @@ public function injectActionLogRepository(ActionLogRepository $actionLogReposito * * @access public * - * @return void + * @return ResponseInterface the response */ - public function basketAction(): void + public function basketAction(): ResponseInterface { $basket = $this->getBasketData(); @@ -153,7 +154,7 @@ public function basketAction(): void } } - $this->redirect('main'); + return $this->redirect('main'); } /** @@ -161,9 +162,9 @@ public function basketAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function addAction(): void + public function addAction(): ResponseInterface { $basket = $this->getBasketData(); @@ -174,7 +175,7 @@ public function addAction(): void $basket = $this->addToBasket($this->requestData, $basket); } - $this->redirect('main'); + return $this->redirect('main'); } /** @@ -182,9 +183,9 @@ public function addAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { $basket = $this->getBasketData(); @@ -224,6 +225,8 @@ public function mainAction(): void } $this->view->assign('entries', $entries); } + + return $this->htmlResponse(); } /** @@ -237,10 +240,9 @@ protected function getBasketData(): Basket { // get user session $userSession = $GLOBALS['TSFE']->fe_user->getSession(); - $context = GeneralUtility::makeInstance(Context::class); // Checking if a user is logged in - $userIsLoggedIn = $context->getPropertyFromAspect('frontend.user', 'isLoggedIn'); + $userIsLoggedIn = $this->isUserLoggedIn(); if ($userIsLoggedIn) { $basket = $this->basketRepository->findOneByFeUserId((int) $GLOBALS['TSFE']->fe_user->user['uid']); @@ -601,7 +603,7 @@ protected function sendMail(): void $newActionLog->setCountPages($numberOfPages); $newActionLog->setLabel('Mail: ' . $mailObject->getMail()); - if ($GLOBALS["TSFE"]->loginUser) { + if ($this->isUserLoggedIn()) { // internal user $newActionLog->setUserId($GLOBALS["TSFE"]->fe_user->user['uid']); $newActionLog->setName($GLOBALS["TSFE"]->fe_user->user['username']); @@ -612,8 +614,6 @@ protected function sendMail(): void } $this->actionLogRepository->add($newActionLog); - - $this->redirect('main'); } /** @@ -661,7 +661,7 @@ protected function printDocument(): void $actionLog->setFileName($pdfUrl); $actionLog->setCountPages($numberOfPages); - if ($GLOBALS["TSFE"]->loginUser) { + if ($this->isUserLoggedIn()) { // internal user $actionLog->setUserId($GLOBALS["TSFE"]->fe_user->user['uid']); $actionLog->setName($GLOBALS["TSFE"]->fe_user->user['username']); @@ -677,4 +677,17 @@ protected function printDocument(): void $this->redirectToUri($pdfUrl); } + + /** + * Return true if the user is logged in. + * + * @access protected + * + * @return bool whether the user is logged in + */ + protected function isUserLoggedIn(): bool + { + $context = GeneralUtility::makeInstance(Context::class); + return $context->getPropertyFromAspect('frontend.user', 'isLoggedIn'); + } } diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index 4b52a68a63..8e084a5e79 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -15,6 +15,7 @@ use Generator; use Kitodo\Dlf\Domain\Model\Document; use Kitodo\Dlf\Domain\Repository\StructureRepository; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; /** @@ -56,9 +57,9 @@ public function injectStructureRepository(StructureRepository $structureReposito * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // Set initial document (anchor or year file) if configured. if (empty($this->requestData['id']) && !empty($this->settings['initialDocument'])) { @@ -69,27 +70,28 @@ public function mainAction(): void $this->loadDocument(); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } $metadata = $this->document->getCurrentDocument()->getToplevelMetadata(); if (!empty($metadata['type'][0])) { $type = $metadata['type'][0]; } else { - return; + return $this->htmlResponse(); } switch ($type) { case 'newspaper': case 'ephemera': - $this->forward('years', null, null, $this->requestData); + return $this->redirect('years', null, null, $this->requestData); case 'year': - $this->forward('calendar', null, null, $this->requestData); + return $this->redirect('calendar', null, null, $this->requestData); case 'issue': default: break; } + return $this->htmlResponse(); } /** @@ -97,9 +99,9 @@ public function mainAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function calendarAction(): void + public function calendarAction(): ResponseInterface { // access arguments passed by the mainAction() $mainRequestData = $this->request->getArguments(); @@ -111,7 +113,7 @@ public function calendarAction(): void $this->loadDocument(); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } $calendarData = $this->buildCalendar(); @@ -136,6 +138,8 @@ public function calendarAction(): void $this->view->assign('yearLinkTitle', $yearLinkTitle); $this->view->assign('parentDocumentId', $this->document->getPartof() ?: $this->document->getCurrentDocument()->tableOfContents[0]['points']); $this->view->assign('allYearDocTitle', $this->document->getCurrentDocument()->getTitle($this->document->getPartof()) ?: $this->document->getCurrentDocument()->tableOfContents[0]['label']); + + return $this->htmlResponse(); } /** @@ -143,9 +147,9 @@ public function calendarAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function yearsAction(): void + public function yearsAction(): ResponseInterface { // access arguments passed by the mainAction() $mainRequestData = $this->request->getArguments(); @@ -157,7 +161,7 @@ public function yearsAction(): void $this->loadDocument(); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } // Get all children of anchor. This should be the year anchor documents @@ -221,6 +225,8 @@ public function yearsAction(): void $this->view->assign('documentId', $this->document->getUid()); $this->view->assign('allYearDocTitle', $this->document->getCurrentDocument()->getTitle((int) $this->document->getUid()) ?: $this->document->getCurrentDocument()->tableOfContents[0]['label']); + + return $this->htmlResponse(); } /** diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index ed1e2d44b7..161c32532d 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -14,6 +14,7 @@ use Kitodo\Dlf\Common\SolrPaginator; use Kitodo\Dlf\Common\Solr\Solr; use Kitodo\Dlf\Domain\Model\Collection; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Pagination\SimplePagination; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -71,15 +72,15 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @access public * - * @return void + * @return ResponseInterface the response */ - public function listAction(): void + public function listAction(): ResponseInterface { $solr = Solr::getInstance($this->settings['solrcore']); if (!$solr->ready) { $this->logger->error('Apache Solr not available'); - return; + return $this->htmlResponse(); } $collections = []; @@ -96,7 +97,7 @@ public function listAction(): void } if (count($collections) == 1 && empty($this->settings['dont_show_single']) && is_array($collections)) { - $this->forward('show', null, null, ['collection' => array_pop($collections)]); + return $this->redirect('show', null, null, ['collection' => array_pop($collections)]); } $processedCollections = $this->processCollections($collections, $solr); @@ -107,6 +108,8 @@ public function listAction(): void } $this->view->assign('collections', $processedCollections); + + return $this->htmlResponse(); } /** @@ -116,9 +119,9 @@ public function listAction(): void * * @param Collection $collection The collection object * - * @return void + * @return ResponseInterface the response */ - public function showAction(Collection $collection): void + public function showAction(Collection $collection): ResponseInterface { $searchParams = $this->getParametersSafely('searchParameter'); @@ -126,7 +129,7 @@ public function showAction(Collection $collection): void $solr = Solr::getInstance($this->settings['solrcore']); if (!$solr->ready) { $this->logger->error('Apache Solr not available'); - return; + return $this->htmlResponse(); } // Pagination of Results: Pass the currentPage to the fluid template to calculate current index of search result. @@ -138,7 +141,8 @@ public function showAction(Collection $collection): void $searchParams['collection'] = $collection; // If a targetPid is given, the results will be shown by ListView on the target page. if (!empty($this->settings['targetPid'])) { - $this->redirect('main', 'ListView', null, + return $this->redirect( + 'main', 'ListView', null, [ 'searchParameter' => $searchParams, 'page' => $currentPage @@ -178,6 +182,8 @@ public function showAction(Collection $collection): void $this->view->assign('lastSearch', $searchParams); $this->view->assign('sortableMetadata', $sortableMetadata); $this->view->assign('listedMetadata', $listedMetadata); + + return $this->htmlResponse(); } /** @@ -185,9 +191,9 @@ public function showAction(Collection $collection): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function showSortedAction(): void + public function showSortedAction(): ResponseInterface { // if search was triggered, get search parameters from POST variables $searchParams = $this->getParametersSafely('searchParameter'); @@ -198,8 +204,7 @@ public function showSortedAction(): void } // output is done by show action - $this->forward('show', null, null, ['searchParameter' => $searchParams, 'collection' => $collection]); - + return $this->redirect('show', null, null, ['searchParameter' => $searchParams, 'collection' => $collection]); } /** diff --git a/Classes/Controller/Embedded3dViewerController.php b/Classes/Controller/Embedded3dViewerController.php index e43d3b6b48..f74463f52b 100644 --- a/Classes/Controller/Embedded3dViewerController.php +++ b/Classes/Controller/Embedded3dViewerController.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Controller; use Kitodo\Dlf\Common\AbstractDocument; +use Psr\Http\Message\ResponseInterface; /** * Plugin 'Embedded3dViewer' for the 'dlf' extension @@ -29,13 +30,13 @@ class Embedded3dViewerController extends AbstractController /** * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { if (!empty($this->requestData['model']) || !empty($this->settings['model'])) { $this->view->assign('embedded3dViewerUrl', $this->buildEmbedded3dViewerUrl()); - return; + return $this->htmlResponse(); } if (!empty($this->settings['document'])) { @@ -47,6 +48,7 @@ public function mainAction(): void } } + return $this->htmlResponse(); } /** diff --git a/Classes/Controller/FeedsController.php b/Classes/Controller/FeedsController.php index 4fc137f3fb..53e0e4dbc4 100644 --- a/Classes/Controller/FeedsController.php +++ b/Classes/Controller/FeedsController.php @@ -13,6 +13,7 @@ use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Domain\Repository\LibraryRepository; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -50,7 +51,7 @@ public function injectLibraryRepository(LibraryRepository $libraryRepository): v */ public function initializeAction(): void { - $this->request->setFormat('xml'); + $this->request = $this->request->withFormat("xml"); } /** @@ -58,9 +59,9 @@ public function initializeAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // access to GET parameter tx_dlf_feeds['collection'] $requestData = $this->request->getArguments(); @@ -84,7 +85,7 @@ public function mainAction(): void || GeneralUtility::inList($this->settings['collections'], $requestData['collection']) ) { - $documents = $this->documentRepository->findAllByCollectionsLimited(GeneralUtility::intExplode(',', $requestData['collection'], true), $this->settings['limit']); + $documents = $this->documentRepository->findAllByCollectionsLimited(GeneralUtility::intExplode(',', $requestData['collection'] ?? "", true), $this->settings['limit']); foreach ($documents as $document) { @@ -123,5 +124,7 @@ public function mainAction(): void $this->view->assign('documents', $documents); $this->view->assign('feedMeta', $feedMeta); + + return $this->htmlResponse(); } } diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index 3485015401..278ba30550 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Controller; use Kitodo\Dlf\Common\SolrPaginator; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Pagination\SimplePagination; use Kitodo\Dlf\Domain\Repository\MetadataRepository; use Kitodo\Dlf\Domain\Repository\CollectionRepository; @@ -73,9 +74,9 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { $this->searchParams = $this->getParametersSafely('searchParameter'); @@ -83,7 +84,9 @@ public function mainAction(): void $collections = []; if (is_array($this->searchParams) && array_key_exists('collection', $this->searchParams)) { foreach(explode(',', $this->searchParams['collection']) as $collectionEntry) { - $collections[] = $this->collectionRepository->findByUid((int) $collectionEntry); + if (!empty($collectionEntry)) { + $collections[] = $this->collectionRepository->findByUid((int) $collectionEntry); + } } } @@ -123,5 +126,7 @@ public function mainAction(): void $this->view->assign('lastSearch', $this->searchParams); $this->view->assign('sortableMetadata', $sortableMetadata); $this->view->assign('listedMetadata', $listedMetadata); + + return $this->htmlResponse(); } } diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index 48f943d5d5..6b8abc90e0 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -17,6 +17,7 @@ use Kitodo\Dlf\Domain\Repository\CollectionRepository; use Kitodo\Dlf\Domain\Repository\MetadataRepository; use Kitodo\Dlf\Domain\Repository\StructureRepository; +use Psr\Http\Message\ResponseInterface; use Ubl\Iiif\Context\IRI; /** @@ -98,15 +99,15 @@ public function injectStructureRepository(StructureRepository $structureReposito /** * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // Load current document. $this->loadDocument(); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } $this->setPage(); @@ -131,11 +132,13 @@ public function mainAction(): void if (empty(array_filter($metadata))) { $this->logger->warning('No metadata found for document with UID ' . $this->document->getUid()); - return; + return $this->htmlResponse(); } ksort($metadata); $this->printMetadata($metadata); + + return $this->htmlResponse(); } /** diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 698d8a4799..9d288eadec 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -13,6 +13,7 @@ use Kitodo\Dlf\Common\MetsDocument; use Kitodo\Dlf\Domain\Model\PageSelectForm; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\MathUtility; /** @@ -32,9 +33,9 @@ class NavigationController extends AbstractController * * @param PageSelectForm|NULL $pageSelectForm * - * @return void + * @return ResponseInterface the response */ - public function pageSelectAction(PageSelectForm $pageSelectForm = NULL): void + public function pageSelectAction(PageSelectForm $pageSelectForm = null): ResponseInterface { if ($pageSelectForm) { $uri = $this->uriBuilder->reset() @@ -48,8 +49,10 @@ public function pageSelectAction(PageSelectForm $pageSelectForm = NULL): void ] ) ->uriFor('main'); - $this->redirectToUri($uri); + return $this->redirectToUri($uri); } + + return $this->htmlResponse(); } /** @@ -57,15 +60,15 @@ public function pageSelectAction(PageSelectForm $pageSelectForm = NULL): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // Load current document. $this->loadDocument(); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } // Set default values if not set. @@ -138,5 +141,7 @@ public function mainAction(): void $this->view->assign('measurePages', $measurePages); } } + + return $this->htmlResponse(); } } diff --git a/Classes/Controller/OaiPmhController.php b/Classes/Controller/OaiPmhController.php index 5ceb558ea7..760a5e4c54 100644 --- a/Classes/Controller/OaiPmhController.php +++ b/Classes/Controller/OaiPmhController.php @@ -17,6 +17,7 @@ use Kitodo\Dlf\Domain\Repository\CollectionRepository; use Kitodo\Dlf\Domain\Repository\LibraryRepository; use Kitodo\Dlf\Domain\Repository\TokenRepository; +use Psr\Http\Message\ResponseInterface; /** * Controller class for the plugin 'OAI-PMH Interface'. @@ -91,7 +92,7 @@ public function injectLibraryRepository(LibraryRepository $libraryRepository) */ public function initializeAction() { - $this->request->setFormat('xml'); + $this->request = $this->request->withFormat("xml"); } /** @@ -163,6 +164,7 @@ protected function getUrlParams() $this->parameters = []; // Set only allowed parameters. foreach ($allowedParams as $param) { + // replace with $this->request->getQueryParams() when dropping support for Typo3 v11, see Deprecation-100596 if (GeneralUtility::_GP($param)) { $this->parameters[$param] = GeneralUtility::_GP($param); } @@ -263,9 +265,9 @@ protected function getMetsData(array $record) * * @access public * - * @return void + * @return ResponseInterface */ - public function mainAction() + public function mainAction(): ResponseInterface { // Get allowed GET and POST variables. $this->getUrlParams(); @@ -273,7 +275,7 @@ public function mainAction() // Delete expired resumption tokens. $this->deleteExpiredTokens(); - switch ($this->parameters['verb']) { + switch ($this->parameters['verb'] ?? null) { case 'GetRecord': $this->verbGetRecord(); break; @@ -300,7 +302,7 @@ public function mainAction() $this->view->assign('parameters', $this->parameters); $this->view->assign('error', $this->error); - return; + return $this->htmlResponse(); } /** diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index b3fb67fcd9..7a995b20f4 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -13,6 +13,7 @@ use Kitodo\Dlf\Pagination\PageGridPagination; use Kitodo\Dlf\Pagination\PageGridPaginator; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -30,9 +31,9 @@ class PageGridController extends AbstractController * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { $this->loadDocument(); if ( @@ -40,7 +41,7 @@ public function mainAction(): void || empty($this->extConf['files']['fileGrpThumbs']) ) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } $entryArray = []; @@ -68,6 +69,8 @@ public function mainAction(): void $this->view->assignMultiple([ 'pagination' => $pagination, 'paginator' => $pageGridPaginator ]); $this->view->assign('docUid', $this->requestData['id']); + + return $this->htmlResponse(); } /** diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index 78b8305354..29e188adbd 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -17,6 +17,7 @@ use Kitodo\Dlf\Common\MetsDocument; use Kitodo\Dlf\Domain\Model\Document; use Kitodo\Dlf\Domain\Model\FormAddDocument; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; use Ubl\Iiif\Presentation\Common\Model\Resources\ManifestInterface; @@ -89,15 +90,15 @@ class PageViewController extends AbstractController * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // Load current document. $this->loadDocument(); if ($this->isDocMissingOrEmpty()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } else { if (isset($this->settings['multiViewType']) && $this->document->getCurrentDocument()->tableOfContents[0]['type'] === $this->settings['multiViewType'] && empty($this->requestData['multiview'])) { $params = array_merge( @@ -140,13 +141,13 @@ public function mainAction(): void $this->addViewerJS(); - $this->view->assign('docCount', count($this->documentArray)); + $this->view->assign('docCount', is_array($this->documentArray) ? count($this->documentArray) : 0); $this->view->assign('docArray', $this->documentArray); - $this->view->assign('docPage', $this->requestData['docPage']); + $this->view->assign('docPage', $this->requestData['docPage'] ?? null); $this->view->assign('docType', $this->document->getCurrentDocument()->tableOfContents[0]['type']); - $this->view->assign('multiview', $this->requestData['multiview']); - if ($this->requestData['multiview']) { + $this->view->assign('multiview', $this->requestData['multiview'] ?? null); + if ($this->requestData['multiview'] ?? false) { $this->multipageNavigation(); } @@ -154,6 +155,7 @@ public function mainAction(): void $this->view->assign('docId', $this->requestData['id']); $this->view->assign('page', $this->requestData['page']); + return $this->htmlResponse(); } /** @@ -271,9 +273,9 @@ public function convertMeasureOrPage($document, $measure = null, $page = null) /** * Action to add multiple mets sources (multi page view) - * @return void + * @return ResponseInterface the response */ - public function addDocumentAction(FormAddDocument $formAddDocument) + public function addDocumentAction(FormAddDocument $formAddDocument): ResponseInterface { if (GeneralUtility::isValidUrl($formAddDocument->getLocation())) { $nextMultipleSourceKey = 0; @@ -291,9 +293,10 @@ public function addDocumentAction(FormAddDocument $formAddDocument) ->setArgumentPrefix('tx_dlf') ->uriFor('main'); - $this->redirectToUri($uri); + return $this->redirectToUri($uri); } + return $this->htmlResponse(); } /** @@ -413,7 +416,7 @@ protected function getScore(int $page, MetsDocument $specificDoc = null) } if (empty($score)) { - $this->logger->notice('No score file found for page "' . $page . '" in fileGrps "' . $this->settings['fileGrpScore'] . '"'); + $this->logger->notice('No score file found for page "' . $page . '" in fileGrps "' . ($this->settings['fileGrpScore'] ?? '') . '"'); } return $score; } @@ -462,7 +465,7 @@ protected function getFulltext(int $page): array */ protected function addViewerJS(): void { - if (count($this->documentArray) > 1) { + if (is_array($this->documentArray) && count($this->documentArray) > 1) { $jsViewer = 'tx_dlf_viewer = [];'; $i = 0; foreach ($this->documentArray as $document) { @@ -526,7 +529,7 @@ protected function addViewerJS(): void $docPage = $this->requestData['page']; $docMeasures = $this->getMeasures($docPage); - if ($this->requestData['measure']) { + if ($this->requestData['measure'] ?? false) { $currentMeasureId = $docMeasures['measureCounterToMeasureId'][$this->requestData['measure']]; } diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index 6ebc52383f..3add779da6 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -19,10 +19,12 @@ use Kitodo\Dlf\Domain\Model\Collection; use Kitodo\Dlf\Domain\Repository\CollectionRepository; use Kitodo\Dlf\Domain\Repository\MetadataRepository; +use Psr\Http\Message\ResponseInterface; use Solarium\Component\Result\FacetSet; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Pagination\SimplePagination; +use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -82,15 +84,15 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @access public * - * @return void + * @return ResponseInterface the response */ - public function searchAction(): void + public function searchAction(): ResponseInterface { // if search was triggered, get search parameters from POST variables $this->searchParams = $this->getParametersSafely('searchParameter'); // output is done by main action - $this->forward('main', null, null, ['searchParameter' => $this->searchParams]); + return $this->redirect('main', null, null, ['searchParameter' => $this->searchParams]); } /** @@ -100,25 +102,26 @@ public function searchAction(): void * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { $listViewSearch = false; // Quit without doing anything if required variables are not set. if (empty($this->settings['solrcore'])) { $this->logger->warning('Incomplete plugin configuration'); - return; + return $this->htmlResponse(); } // if search was triggered, get search parameters from POST variables $this->searchParams = $this->getParametersSafely('searchParameter'); // if search was triggered by the ListView plugin, get the parameters from GET variables + // replace with $this->request->getQueryParams() when dropping support for Typo3 v11, see Deprecation-100596 $listRequestData = GeneralUtility::_GPmerged('tx_dlf_listview'); // Quit without doing anything if no search parameters. if (empty($this->searchParams) && empty($listRequestData)) { $this->logger->warning('Missing search parameters'); - return; + return $this->htmlResponse(); } if (isset($listRequestData['searchParameter']) && is_array($listRequestData['searchParameter'])) { @@ -152,7 +155,7 @@ public function mainAction(): void // If a targetPid is given, the results will be shown by ListView on the target page. if (!empty($this->settings['targetPid']) && !empty($this->searchParams) && !$listViewSearch) { - $this->redirect( + return $this->redirect( 'main', 'ListView', null, @@ -219,6 +222,8 @@ public function mainAction(): void } $this->view->assign('viewData', $this->viewData); + + return $this->htmlResponse(); } /** @@ -395,7 +400,9 @@ private function addCollectionsQuery(string $query): string $collections = null; if (array_key_exists('collection', $this->searchParams)) { foreach (explode(',', $this->searchParams['collection']) as $collectionEntry) { - $collections[] = $this->collectionRepository->findByUid((int) $collectionEntry); + if (!empty($collectionEntry)) { + $collections[] = $this->collectionRepository->findByUid((int) $collectionEntry); + } } } if ($collections) { diff --git a/Classes/Controller/StatisticsController.php b/Classes/Controller/StatisticsController.php index 779648e6e8..6dbe48387c 100644 --- a/Classes/Controller/StatisticsController.php +++ b/Classes/Controller/StatisticsController.php @@ -11,6 +11,7 @@ namespace Kitodo\Dlf\Controller; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** @@ -28,9 +29,9 @@ class StatisticsController extends AbstractController * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { $foundNumbers = $this->documentRepository->getStatisticsForSelectedCollection($this->settings); @@ -54,5 +55,7 @@ public function mainAction(): void } $this->view->assign('content', $content); + + return $this->htmlResponse(); } } diff --git a/Classes/Controller/TableOfContentsController.php b/Classes/Controller/TableOfContentsController.php index a6c54f8ad8..8747672d27 100644 --- a/Classes/Controller/TableOfContentsController.php +++ b/Classes/Controller/TableOfContentsController.php @@ -13,6 +13,7 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\MetsDocument; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\MathUtility; /** @@ -38,20 +39,22 @@ class TableOfContentsController extends AbstractController * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // Load current document. $this->loadDocument(); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return $this->htmlResponse(); } else { $this->setPage(); $this->view->assign('toc', $this->makeMenuArray()); } + + return $this->htmlResponse(); } /** diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index b7eddb4c8e..dd8179fb15 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -13,6 +13,7 @@ use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -38,9 +39,9 @@ class ToolboxController extends AbstractController * * @access public * - * @return void + * @return ResponseInterface the response */ - public function mainAction(): void + public function mainAction(): ResponseInterface { // Load current document. $this->loadDocument(); @@ -53,6 +54,8 @@ public function mainAction(): void $this->renderTools(); $this->view->assign('viewData', $this->viewData); + + return $this->htmlResponse(); } /** diff --git a/Classes/Domain/Model/PageSelectForm.php b/Classes/Domain/Model/PageSelectForm.php index 9d883b570a..bdd3fb107d 100644 --- a/Classes/Domain/Model/PageSelectForm.php +++ b/Classes/Domain/Model/PageSelectForm.php @@ -83,7 +83,7 @@ public function setRecordId(string $recordId): void /** * @return string */ - public function getDouble(): string + public function getDouble(): ?string { return $this->double; } diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index c57e0eebd1..0f8da9a4d4 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -12,7 +12,7 @@ namespace Kitodo\Dlf\Domain\Repository; -use Doctrine\DBAL\ForwardCompatibility\Result; +use Doctrine\DBAL\Result; use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -57,7 +57,7 @@ public function findAllByUids(array $uids): QueryResultInterface $constraints[] = $query->in('uid', $uids); if (count($constraints)) { - $query->matching($query->logicalAnd($constraints)); + $query->matching($query->logicalAnd(...array_values($constraints))); } return $query->execute(); @@ -97,27 +97,27 @@ public function findCollectionsBySettings(array $settings = []): QueryResultInte $constraints = []; - if ($settings['collections']) { + if ($settings['collections'] ?? false) { $constraints[] = $query->in('uid', GeneralUtility::intExplode(',', $settings['collections'])); } - if ($settings['index_name']) { + if ($settings['index_name'] ?? false) { $constraints[] = $query->in('index_name', $settings['index_name']); } // do not find user created collections (used by oai-pmh plugin) - if (!$settings['show_userdefined']) { + if (!($settings['show_userdefined'] ?? false)) { $constraints[] = $query->equals('fe_cruser_id', 0); } // do not find collections without oai_name set (used by oai-pmh plugin) - if ($settings['hideEmptyOaiNames']) { + if ($settings['hideEmptyOaiNames'] ?? false) { $constraints[] = $query->logicalNot($query->equals('oai_name', '')); } if (count($constraints)) { $query->matching( - $query->logicalAnd($constraints) + $query->logicalAnd(...array_values($constraints)) ); } diff --git a/Classes/Domain/Repository/DocumentRepository.php b/Classes/Domain/Repository/DocumentRepository.php index 25785b8789..e77a040aaf 100644 --- a/Classes/Domain/Repository/DocumentRepository.php +++ b/Classes/Domain/Repository/DocumentRepository.php @@ -12,7 +12,7 @@ namespace Kitodo\Dlf\Domain\Repository; -use Doctrine\DBAL\ForwardCompatibility\Result; +use Doctrine\DBAL\Result; use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Solr\SolrSearch; @@ -172,8 +172,8 @@ public function findDocumentsBySettings($settings = []) $constraints = []; - if ($settings['documentSets']) { - $constraints[] = $query->in('uid', GeneralUtility::intExplode(',', $settings['documentSets'])); + if ($settings['documentSets'] ?? false) { + $constraints[] = $query->in('uid', GeneralUtility::intExplode(',', ((string) $settings['documentSets']))); } if (isset($settings['excludeOther']) && (int) $settings['excludeOther'] === 0) { @@ -182,7 +182,7 @@ public function findDocumentsBySettings($settings = []) if (count($constraints)) { $query->matching( - $query->logicalAnd($constraints) + $query->logicalAnd(...array_values($constraints)) ); } @@ -216,7 +216,7 @@ public function findAllByCollectionsLimited($collections, int $limit = 50, int $ if (count($constraints)) { $query->matching( - $query->logicalAnd($constraints) + $query->logicalAnd(...array_values($constraints)) ); } diff --git a/Classes/Domain/Repository/MetadataRepository.php b/Classes/Domain/Repository/MetadataRepository.php index 5c0c89c6d1..ae58e61b3a 100644 --- a/Classes/Domain/Repository/MetadataRepository.php +++ b/Classes/Domain/Repository/MetadataRepository.php @@ -51,7 +51,7 @@ public function findBySettings(array $settings = []): QueryResultInterface if (count($constraints)) { $query->matching( - $query->logicalAnd($constraints) + $query->logicalAnd(...array_values($constraints)) ); } diff --git a/Classes/Domain/Repository/TokenRepository.php b/Classes/Domain/Repository/TokenRepository.php index fcc1fc194d..19fbfa4b59 100644 --- a/Classes/Domain/Repository/TokenRepository.php +++ b/Classes/Domain/Repository/TokenRepository.php @@ -42,7 +42,7 @@ public function deleteExpiredTokens(int $expireTime): void $constraints[] = $query->lessThan('tstamp', (int) (time() - $expireTime)); if (count($constraints)) { - $query->matching($query->logicalAnd($constraints)); + $query->matching($query->logicalAnd(...array_values($constraints))); } $tokensToBeRemoved = $query->execute(); diff --git a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php index 1c3a5f62d1..ea04383693 100644 --- a/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php +++ b/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php @@ -25,7 +25,6 @@ use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; -use TYPO3\CMS\Extbase\Object\ObjectManager; /** * Provider class for additional "getDocumentType" function to the ExpressionLanguage. @@ -92,11 +91,6 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) */ protected function initializeRepositories(int $storagePid): void { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - // TODO: change it as it is deprecated since 10.4 and will be removed in 12.x - // TODO: necessary to test calendar view after updating this code - $configurationManager = $objectManager->get(ConfigurationManager::class); - $this->injectConfigurationManager($configurationManager); $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $frameworkConfiguration['persistence']['storagePid'] = MathUtility::forceIntegerInRange((int) $storagePid, 0); $this->configurationManager->setConfiguration($frameworkConfiguration); diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index a809fbd565..236a74dcf6 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -23,7 +23,6 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; /** * Hooks and helper for \TYPO3\CMS\Core\DataHandling\DataHandler @@ -37,29 +36,6 @@ class DataHandler implements LoggerAwareInterface { use LoggerAwareTrait; - /** - * @access protected - * @var DocumentRepository - */ - protected DocumentRepository $documentRepository; - - /** - * Gets document repository - * - * @access protected - * - * @return DocumentRepository - */ - protected function getDocumentRepository(): DocumentRepository - { - if (!isset($this->documentRepository)) { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); - $this->documentRepository = $objectManager->get(DocumentRepository::class); - } - - return $this->documentRepository; - } - /** * Field post-processing hook for the process_datamap() method. * @@ -365,11 +341,12 @@ private function deleteDocument($core, $id): void */ private function reindexDocument($id):void { - $document = $this->getDocumentRepository()->findByUid((int) $id); + $documentRepository = GeneralUtility::makeInstance(DocumentRepository::class); + $document = $documentRepository->findByUid((int) $id); $doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $document->getPid()], true); if ($document !== null && $doc !== null) { $document->setCurrentDocument($doc); - Indexer::add($document, $this->getDocumentRepository()); + Indexer::add($document, $documentRepository); } else { $this->logger->error('Failed to re-index document with UID ' . (string) $id); } diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index f4f82c7832..58371b1d27 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -20,7 +20,6 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\TypoScript\TemplateService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; /** * Helper for FlexForm's custom "itemsProcFunc" @@ -69,19 +68,18 @@ public function toolList(array &$params): void */ public function getTyposcriptConfigFromPluginSiteRoot(array $params): void { - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $pid = $params['flexParentDatabaseRow']['pid']; $rootLine = BackendUtility::BEgetRootLine($pid); $siteRootRow = []; foreach ($rootLine as $row) { - if ($row['is_siteroot'] == '1') { + if (isset($row['is_siteroot'])) { $siteRootRow = $row; break; } } try { - $ts = $objectManager->get(TemplateService::class, [$siteRootRow['uid']]); + $ts = GeneralUtility::makeInstance(TemplateService::class); $ts->rootLine = $rootLine; $ts->runThroughTemplates($rootLine, 0); $ts->generateConfig(); diff --git a/Classes/Updates/FileLocationUpdater.php b/Classes/Updates/FileLocationUpdater.php index 044dcf348f..256f985865 100644 --- a/Classes/Updates/FileLocationUpdater.php +++ b/Classes/Updates/FileLocationUpdater.php @@ -304,7 +304,6 @@ protected function migrateField(string $table, array $row): void if ($fileUid > 0) { $fields = [ 'fieldname' => $this->fieldsToMigrate[$table], - 'table_local' => 'sys_file', 'pid' => ($table === 'pages' ? $row['uid'] : $row['pid']), 'uid_foreign' => $row['uid'], 'uid_local' => $fileUid, diff --git a/Classes/Validation/AbstractDlfValidator.php b/Classes/Validation/AbstractDlfValidator.php index 0a09283c00..fd692a9a68 100644 --- a/Classes/Validation/AbstractDlfValidator.php +++ b/Classes/Validation/AbstractDlfValidator.php @@ -18,6 +18,7 @@ use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Error\Result; use TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator; /** @@ -39,12 +40,11 @@ abstract class AbstractDlfValidator extends AbstractValidator */ public function __construct(string $valueClassName) { - parent::__construct(); $this->logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(static::class); $this->valueClassName = $valueClassName; } - public function validate($value) + public function validate($value): Result { if (!$value instanceof $this->valueClassName) { $this->logger->debug('Value must be an instance of ' . $this->valueClassName . '.'); diff --git a/Configuration/Backend/Modules.php b/Configuration/Backend/Modules.php new file mode 100644 index 0000000000..69e626b2ff --- /dev/null +++ b/Configuration/Backend/Modules.php @@ -0,0 +1,33 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +if (!defined('TYPO3')) { + die('Access denied.'); +} + +// register backend modules +return [ + 'newTenantModule' => [ + 'extensionName' => 'Dlf', + 'parent' => 'tools', + 'position' => 'bottom', + 'access' => 'admin', + 'labels' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_mod_newtenant.xlf', + 'icon' => 'EXT:dlf/Resources/Public/Icons/Extension.svg', + 'navigationComponentId' => '@typo3/backend/page-tree/page-tree-element', + 'controllerActions' => [ + \Kitodo\Dlf\Controller\Backend\NewTenantController::class => [ + 'index','error','addFormat','addMetadata','addSolrCore','addStructure' + ], + ], + ], +]; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index a59aeee894..b03ffe1967 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -36,3 +36,12 @@ services: tags: - name: console.command command: 'kitodo:suggestBuld' + + Kitodo\Dlf\Validation\DOMDocumentValidationStack: + autowire: false + + Kitodo\Dlf\Validation\SaxonXslToSvrlValidator: + autowire: false + + Kitodo\Dlf\Validation\XmlSchemesValidator: + autowire: false \ No newline at end of file diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index b8de696335..ff47bf7408 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -10,7 +10,7 @@ * LICENSE.txt file that was distributed with this source code. */ -if (!defined('TYPO3_MODE')) { +if (!defined('TYPO3')) { die('Access denied.'); } // Register static typoscript. diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index ab98fc84a3..91ff564a6a 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -10,7 +10,7 @@ * LICENSE.txt file that was distributed with this source code. */ -if (!defined('TYPO3_MODE')) { +if (!defined('TYPO3')) { die('Access denied.'); } // Plugin "audioplayer". @@ -191,7 +191,7 @@ ); \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( - 'Kitodo.Dlf', + 'Dlf', 'Annotation', 'LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.annotation.title', ); diff --git a/Configuration/TCA/tx_dlf_collections.php b/Configuration/TCA/tx_dlf_collections.php index de7f1e54cd..7b7668a9ef 100644 --- a/Configuration/TCA/tx_dlf_collections.php +++ b/Configuration/TCA/tx_dlf_collections.php @@ -180,7 +180,6 @@ 'foreign_match_fields' => [ 'fieldname' => 'thumbnail', 'tablenames' => 'tx_dlf_collections', - 'table_local' => 'sys_file', ], ], $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 120789456b..048b5ddad7 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -70,7 +70,7 @@ page { } } -[like(traverse(request.getQueryParams(), 'tx_dlf/multiview'), '1')] +[request && like(traverse(request.getQueryParams(), 'tx_dlf/multiview'), '1')] page.includeJSFooter { # Gridstack gridstack = EXT:dlf/Resources/Public/JavaScript/Gridstack/gridstack-all.js diff --git a/README.md b/README.md index 1be7426d79..abe161beb0 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ For a complete overview of all features, visit the [Kitodo homepage](https://www Kitodo.Presentation requires [TYPO3](https://get.typo3.org) with [PHP](https://www.php.net). It uses [MySQL](https://www.mysql.com) or [MariaDB](https://mariadb.com) as database and [Apache Solr](https://solr.apache.org) via [Solarium](https://www.solarium-project.org) as search engine backend. -Currently **TYPO3 10.4 ELTS** and **TYPO3 11.5 LTS** is supported with the following system requirements: +Currently **TYPO3 11.5 ELTS** and **TYPO3 12.4 LTS** is supported with the following system requirements: -| Component | Constraints for 10 LTS | Constraints for 11 LTS | +| Component | Constraints for 11 LTS | Constraints for 12 LTS | | ----------------------- | ---------------------- | ---------------------- | -| TYPO3 | 10.4.45+ (ELTS) | 11.5.37+ | -| PHP | 7.4.x | 7.4.x - 8.3.x | -| MySQL | 5.7.x - 8.0.x | 5.7.9 - 8.0.x | +| TYPO3 | 11.5.37+ | 12.4.16+ | +| PHP | 7.4.x - 8.3.x | 8.1.x - 8.3.x | +| MySQL | 5.7.9 - 8.0.x | 5.7.9 - 8.0.x | | MariaDB | 10.2.7 - 10.11.x | 10.2.7 - 10.11.x | | Apache Solr | 8.x | 8.x | | OCR Highlighting Plugin | 0.8.x-solr78 | 0.8.x-solr78 | diff --git a/Resources/Private/Partials/TableOfContents/Children.html b/Resources/Private/Partials/TableOfContents/Children.html index ba2d77a7f5..2a3f6bfd51 100644 --- a/Resources/Private/Partials/TableOfContents/Children.html +++ b/Resources/Private/Partials/TableOfContents/Children.html @@ -46,7 +46,7 @@ pageUid="{settings.targetPid}" additionalParams="{f:if(condition:'{child.id}', then:'{\'tx_dlf[id]\':child.id, \'tx_dlf[page]\':child.page}', else: '{\'tx_dlf[page]\':child.page}')}" argumentsToBeExcludedFromQueryString="{0: 'tx_dlf[measure]'}" - addQueryString="1" + addQueryString="untrusted" title="{f:if(condition:'{child.title}', then: '{child.title}', else: '{child.type}')}"> @@ -60,7 +60,7 @@ action="main" controller="Basket" additionalParams="{'tx_dlf[addToBasket]':'toc', 'tx_dlf[logId]':child.basketButton.logId, 'tx_dlf[startpage]':child.basketButton.startpage, 'tx_dlf_basket[action]':'add', 'tx_dlf_basket[controller]':'Basket'}" - addQueryString="1"> + addQueryString="untrusted"> diff --git a/Resources/Private/Templates/Backend/NewTenant/Index.html b/Resources/Private/Templates/Backend/NewTenant/Index.html index 18514d4678..9a838447c9 100644 --- a/Resources/Private/Templates/Backend/NewTenant/Index.html +++ b/Resources/Private/Templates/Backend/NewTenant/Index.html @@ -12,6 +12,10 @@ + +

diff --git a/Resources/Private/Templates/Navigation/Main.html b/Resources/Private/Templates/Navigation/Main.html index 3b10203880..109c95812c 100644 --- a/Resources/Private/Templates/Navigation/Main.html +++ b/Resources/Private/Templates/Navigation/Main.html @@ -26,7 +26,7 @@
- @@ -34,7 +34,7 @@
- @@ -49,7 +49,7 @@
- @@ -72,7 +72,7 @@
- @@ -90,7 +90,7 @@
- @@ -108,7 +108,7 @@
- @@ -124,7 +124,7 @@
  • - + @@ -150,7 +150,7 @@
    - @@ -168,7 +168,7 @@
    - @@ -186,7 +186,7 @@
    - @@ -252,7 +252,7 @@ - + @@ -278,13 +278,13 @@ - + + addQueryString="untrusted" additionalParams="{'tx_dlf[measure]':'1', 'tx_dlf[page]':'{measurePages.1}'}"> diff --git a/Resources/Private/Templates/OaiPmh/Main.xml b/Resources/Private/Templates/OaiPmh/Main.xml index d96dd223fb..5bac4a6551 100644 --- a/Resources/Private/Templates/OaiPmh/Main.xml +++ b/Resources/Private/Templates/OaiPmh/Main.xml @@ -17,7 +17,14 @@ now As per the specification, don't show arguments on badVerb or badArgument. {f:if(condition: '{error} == "badVerb" || {error} == "badArgument"', then: '{}', else: '{parameters}') -> f:variable(name: 'shownParameters')} - f:for(each:'{shownParameters}', as:'value', key:'key', iteration:'i')}> + + + f:for(each:'{shownParameters}', as:'value', key:'key', iteration:'i')}> + + + + + diff --git a/Tests/Fixtures/Common/pages.csv b/Tests/Fixtures/Common/pages.csv index b8ec5a4ed6..be9073b4e7 100644 --- a/Tests/Fixtures/Common/pages.csv +++ b/Tests/Fixtures/Common/pages.csv @@ -1,4 +1,4 @@ pages,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,uid,pid,tstamp,crdate,cruser_id,deleted,hidden,starttime,endtime,fe_group,sorting,rowDescription,editlock,sys_language_uid,l10n_parent,l10n_source,t3_origuid,l10n_diffsource,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_stage,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,title,slug,doktype,TSconfig,is_siteroot,php_tree_stop,url,shortcut,shortcut_mode,subtitle,layout,target,media,lastUpdated,keywords,cache_timeout,cache_tags,newUntil,description,no_search,SYS_LASTCHANGED,abstract,module,extendToSubpages,author,author_email,nav_title,nav_hide,content_from_pid,mount_pid,mount_pid_ol,l18n_cfg,fe_login_mode,backend_layout,backend_layout_next_level,tsconfig_includes,categories -,19999,0,1644840191,1644840051,1,0,0,0,0,,764,,0,0,0,0,0,a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;},0,0,0,0,1,0,31,27,0,DLF Testing Site,,254,,1,0,,0,0,,0,,0,0,,0,,0,,0,1644840191,,,0,,,,0,0,0,0,0,0,,,,0 -,20000,19999,1644840191,1644840051,1,0,0,0,0,,764,,0,0,0,0,0,a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;},0,0,0,0,1,0,31,27,0,Data,/data,254,,0,0,,0,0,,0,,0,0,,0,,0,,0,1644840191,,,0,,,,0,0,0,0,0,0,,,,0 +,uid,pid,tstamp,crdate,deleted,hidden,starttime,endtime,fe_group,sorting,rowDescription,editlock,sys_language_uid,l10n_parent,l10n_source,t3_origuid,l10n_diffsource,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,title,slug,doktype,TSconfig,is_siteroot,php_tree_stop,url,shortcut,shortcut_mode,subtitle,layout,target,media,lastUpdated,keywords,cache_timeout,cache_tags,newUntil,description,no_search,SYS_LASTCHANGED,abstract,module,extendToSubpages,author,author_email,nav_title,nav_hide,content_from_pid,mount_pid,mount_pid_ol,l18n_cfg,backend_layout,backend_layout_next_level,tsconfig_includes,categories +,19999,0,1644840191,1644840051,0,0,0,0,,764,,0,0,0,0,0,a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;},1,0,31,27,0,DLF Testing Site,,254,,1,0,,0,0,,0,,0,0,,0,,0,,0,1644840191,,,0,,,,0,0,0,0,0,,,,0 +,20000,19999,1644840191,1644840051,0,0,0,0,,764,,0,0,0,0,0,a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;},1,0,31,27,0,Data,/data,254,,0,0,,0,0,,0,,0,0,,0,,0,,0,1644840191,,,0,,,,0,0,0,0,0,,,,0 diff --git a/Tests/Fixtures/Common/pages.xml b/Tests/Fixtures/Common/pages.xml index fe14749f26..571d0928c1 100644 --- a/Tests/Fixtures/Common/pages.xml +++ b/Tests/Fixtures/Common/pages.xml @@ -6,7 +6,6 @@ 0 1644840191 1644840051 - 1 0 0 0 @@ -20,10 +19,6 @@ 0 0 a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;} - 0 - 0 - 0 - 0 1 0 31 @@ -61,7 +56,6 @@ 0 0 0 - 0 @@ -74,7 +68,6 @@ 19999 1644840191 1644840051 - 1 0 0 0 @@ -88,10 +81,6 @@ 0 0 a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;} - 0 - 0 - 0 - 0 1 0 31 @@ -129,7 +118,6 @@ 0 0 0 - 0 diff --git a/Tests/Fixtures/OaiPmh/pages.xml b/Tests/Fixtures/OaiPmh/pages.xml index f8256066c8..ff5d1661da 100644 --- a/Tests/Fixtures/OaiPmh/pages.xml +++ b/Tests/Fixtures/OaiPmh/pages.xml @@ -6,7 +6,6 @@ 19999 1644840191 1644840051 - 1 0 0 0 @@ -20,10 +19,6 @@ 0 0 a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;} - 0 - 0 - 0 - 0 1 0 31 @@ -61,7 +56,6 @@ 0 0 0 - 0 @@ -73,7 +67,6 @@ 20001 1644856416 1644856388 - 1 0 0 0 @@ -81,10 +74,6 @@ 256 0 - 0 - 0 - 0 - 0 OAI-PMH Template 1 3 @@ -102,7 +91,6 @@ 20001 1644840071 1644840071 - 1 0 0 0 @@ -115,10 +103,6 @@ 0 0 - 0 - 0 - 0 - 0 list
    @@ -208,7 +192,6 @@ 19999 1644840191 1644840051 - 1 0 0 0 @@ -222,10 +205,6 @@ 0 0 a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;} - 0 - 0 - 0 - 0 1 0 31 @@ -263,7 +242,6 @@ 0 0 0 - 0 @@ -275,7 +253,6 @@ 20002 1644856416 1644856388 - 1 0 0 0 @@ -283,10 +260,6 @@ 256 0 - 0 - 0 - 0 - 0 OAI-PMH Template (missing storagePid) 1 3 @@ -304,7 +277,6 @@ 20002 1644840071 1644840071 - 1 0 0 0 @@ -317,10 +289,6 @@ 0 0 - 0 - 0 - 0 - 0 list
    diff --git a/Tests/Functional/Api/OaiPmhTest.php b/Tests/Functional/Api/OaiPmhTest.php index 4e8e2294d3..1295d5f01e 100644 --- a/Tests/Functional/Api/OaiPmhTest.php +++ b/Tests/Functional/Api/OaiPmhTest.php @@ -25,7 +25,7 @@ class OaiPmhTest extends FunctionalTestCase { protected $disableJsonWrappedResponse = true; - protected $coreExtensionsToLoad = [ + protected array $coreExtensionsToLoad = [ 'fluid', 'fluid_styled_content', ]; diff --git a/Tests/Functional/FunctionalTestCase.php b/Tests/Functional/FunctionalTestCase.php index c5631ed418..2a818f1b51 100644 --- a/Tests/Functional/FunctionalTestCase.php +++ b/Tests/Functional/FunctionalTestCase.php @@ -19,9 +19,9 @@ use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; /** * Base class for functional test cases. This provides some common configuration @@ -29,11 +29,11 @@ */ class FunctionalTestCase extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase { - protected $testExtensionsToLoad = [ + protected array $testExtensionsToLoad = [ 'typo3conf/ext/dlf', ]; - protected $configurationToUseInTestInstance = [ + protected array $configurationToUseInTestInstance = [ 'SYS' => [ 'caching' => [ 'cacheConfigurations' => [ @@ -74,11 +74,6 @@ class FunctionalTestCase extends \TYPO3\TestingFramework\Core\Functional\Functio */ protected $disableJsonWrappedResponse = false; - /** - * @var ObjectManager - */ - protected $objectManager; - /** * @var PersistenceManager */ @@ -111,7 +106,6 @@ public function setUp(): void { parent::setUp(); - $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class); $this->baseUrl = 'http://web:8000/public/typo3temp/var/tests/functional-' . $this->identifier . '/'; @@ -182,13 +176,16 @@ protected function addSiteConfig($identifier) $siteConfigPath = $this->instancePath . '/typo3conf/sites/' . $identifier; @mkdir($siteConfigPath, 0775, true); file_put_contents($siteConfigPath . '/config.yaml', Yaml::dump($siteConfig)); + + // refresh site cache (otherwise site config is not found) + $finder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Site\SiteFinder::class); + $finder->getAllSites(false); // useCache = false } protected function initializeRepository(string $className, int $storagePid) { - $repository = $this->objectManager->get($className); - - $querySettings = $this->objectManager->get(Typo3QuerySettings::class); + $repository = GeneralUtility::makeInstance($className); + $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); $querySettings->setStoragePageIds([$storagePid]); $repository->setDefaultQuerySettings($querySettings); @@ -217,7 +214,11 @@ protected function importSolrDocuments(Solr $solr, string $path) protected function initLanguageService(string $locale) { - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create($locale); + // create mock backend user and set language + // which is loaded by LanguageServiceFactory as default value in backend mode + $backendUser = GeneralUtility::makeInstance(BackendUserAuthentication::class); + $backendUser->user["lang"] = $locale; + $GLOBALS['BE_USER'] = $backendUser; } /** diff --git a/Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php b/Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php index e6989c54ea..365b92ec2e 100644 --- a/Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/JsFooterViewHelperTest.php @@ -25,14 +25,14 @@ class JsFooterViewHelperTest extends FunctionalTestCase /** * @var bool Speed up this test case, it needs no database */ - protected $initializeDatabase = false; + protected bool $initializeDatabase = false; /** * @test */ public function pageRendererCallsAddJsFooterInlineCode(): void { - $pageRendererProphecy = $this->getMockBuilder(PageRenderer::class)->getMock(); + $pageRendererProphecy = $this->getMockBuilder(PageRenderer::class)->disableOriginalConstructor()->getMock(); $pageRendererProphecy->expects(self::once())->method('addJsFooterInlineCode')->with( 'js-dlf-inline-footer', '$(document).ready(function() {});' diff --git a/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php b/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php index 335aac5d43..714720032b 100644 --- a/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/MetadataWrapVariableViewHelperTest.php @@ -23,7 +23,7 @@ class MetadataWrapVariableViewHelperTest extends FunctionalTestCase /** * @var bool Speed up this test case, it needs no database */ - protected $initializeDatabase = false; + protected bool $initializeDatabase = false; /** * @test diff --git a/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php b/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php index 498cf79963..434cf0d0fe 100644 --- a/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/StdWrapViewHelperTest.php @@ -23,7 +23,7 @@ class StdWrapViewHelperTest extends FunctionalTestCase /** * @var bool Speed up this test case, it needs no database */ - protected $initializeDatabase = false; + protected bool $initializeDatabase = false; /** * @test diff --git a/composer.json b/composer.json index 4753296349..d24ef46f83 100644 --- a/composer.json +++ b/composer.json @@ -32,24 +32,25 @@ "ext-libxml": "*", "ext-openssl": "*", "ext-simplexml": "*", - "typo3/cms-core": "^10.4.37|^11.5.40", - "typo3/cms-extbase": "^10.4.37|^11.5.40", - "typo3/cms-scheduler" : "^10.4.37|^11.5.40", - "typo3/cms-tstemplate": "^10.4.37|^11.5.40", + "typo3/cms-core": "^11.5.40|^12.4.21", + "typo3/cms-extbase": "^11.5.40|^12.4.21", + "typo3/cms-scheduler": "^11.5.40|^12.4.21", + "typo3/cms-tstemplate": "^11.5.40|^12.4.21", "caseyamcl/phpoaipmh": "^3.3.1", "slub/php-mods-reader": "^0.4.0", "ubl/php-iiif-prezi-reader": "0.3.0", "solarium/solarium": "5.2 - 6.3", - "symfony/process": "^5.4" + "symfony/process": "^5.4|^6.4" }, "require-dev": { "phpstan/phpstan": "^1.12", + "phpunit/phpunit": "^9.6.20", "spatie/phpunit-watcher": "^1.23", - "typo3/cms-backend": "^10.4.37|^11.5.40", - "typo3/cms-fluid": "^10.4.37|^11.5.40", - "typo3/cms-fluid-styled-content": "^10.4.37|^11.5.40", - "typo3/cms-frontend": "^10.4.37|^11.5.40", - "typo3/testing-framework": "^6.16.10", + "typo3/cms-backend": "^11.5.40|^12.4.21", + "typo3/cms-fluid": "^11.5.40|^12.4.21", + "typo3/cms-fluid-styled-content": "^11.5.40|^12.4.21", + "typo3/cms-frontend": "^11.5.40|^12.4.21", + "typo3/testing-framework": "^7.1.0", "vlucas/phpdotenv": "^5.6.1" }, "replace": { diff --git a/ext_emconf.php b/ext_emconf.php index 7d363b8bb7..e721940ec2 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -18,7 +18,7 @@ 'constraints' => [ 'depends' => [ 'php' => '7.4.0-8.3.99', - 'typo3' => '10.4.0-11.5.99' + 'typo3' => '11.5.0-12.4.99' ], 'conflicts' => [], 'suggests' => [] diff --git a/ext_localconf.php b/ext_localconf.php index 44f1fca793..d79f6abe9b 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -10,7 +10,7 @@ * LICENSE.txt file that was distributed with this source code. */ -if (!defined('TYPO3_MODE')) { +if (!defined('TYPO3')) { die('Access denied.'); } // Define constants. diff --git a/ext_tables.php b/ext_tables.php index 8f73e0509e..8a6c8d3062 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -10,21 +10,24 @@ * LICENSE.txt file that was distributed with this source code. */ -// Register backend module. -if (\TYPO3_MODE === 'BE') { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( - 'Dlf', - 'tools', // Main area - 'newTenantModule', // Name of the module - 'bottom', // Position of the module - [// Allowed controller action combinations - \Kitodo\Dlf\Controller\Backend\NewTenantController::class => 'index,error,addFormat,addMetadata,addSolrCore,addStructure', - ], - [// Additional configuration - 'access' => 'admin', - 'icon' => 'EXT:dlf/Resources/Public/Icons/Extension.svg', - 'labels' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_mod_newtenant.xlf', - 'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement' - ], - ); +if (!defined('TYPO3')) { + die('Access denied.'); } + +// Register backend module for Typo3 v11. + +\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'Dlf', + 'tools', // Main area + 'newTenantModule', // Name of the module + 'bottom', // Position of the module + [// Allowed controller action combinations + \Kitodo\Dlf\Controller\Backend\NewTenantController::class => 'index,error,addFormat,addMetadata,addSolrCore,addStructure', + ], + [// Additional configuration + 'access' => 'admin', + 'icon' => 'EXT:dlf/Resources/Public/Icons/Extension.svg', + 'labels' => 'LLL:EXT:dlf/Resources/Private/Language/locallang_mod_newtenant.xlf', + 'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement' + ], +); diff --git a/ext_tables.sql b/ext_tables.sql index f7ea4de2f1..0fa87693a0 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -320,7 +320,7 @@ CREATE TABLE tx_dlf_basket ( l18n_diffsource mediumblob NOT NULL, l10n_state text COLLATE utf8_unicode_ci DEFAULT NULL, label varchar(255) DEFAULT '' NOT NULL, - session_id varchar(32) DEFAULT '' NOT NULL, + session_id varchar(190) DEFAULT '' NOT NULL, doc_ids varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (uid),