slub / dfg-viewer

The DFG Viewer is a free web service for browsing digitized books from remote library repositories in a rich and dynamic environment.
https://dfg-viewer.de
GNU General Public License v3.0
29 stars 25 forks source link

Error in Administration Log of typo3 "Call to a member function getConfiguration" #259

Closed BFallert closed 1 month ago

BFallert commented 10 months ago

In my installation, I use the DFG viewer for the page view, but currently I do not get a calendar view for newspapers. However, the following messages appear in the error log:

Fri, 17 Nov 2023 13:46:19 +0100 [ERROR] request="68bf29cc8b02b" component="TYPO3.CMS.Frontend.Configuration.TypoScript.ConditionMatching.ConditionMatcher": Call to a member function getConfiguration() on null - {"expression":"getDocumentType(3) == 'ephemera' or getDocumentType(3) == 'newspaper'","exception":{}}
Fri, 17 Nov 2023 13:46:19 +0100 [ERROR] request="68bf29cc8b02b" component="TYPO3.CMS.Frontend.Configuration.TypoScript.ConditionMatching.ConditionMatcher": Call to a member function getConfiguration() on null - {"expression":"getDocumentType(3) == 'year'","exception":{}}
Fri, 17 Nov 2023 13:46:19 +0100 [ERROR] request="68bf29cc8b02b" component="TYPO3.CMS.Frontend.Configuration.TypoScript.ConditionMatching.ConditionMatcher": Call to a member function getConfiguration() on null - {"expression":"getDocumentType(3) == 'issue'","exception":{}}
Fri, 17 Nov 2023 13:46:19 +0100 [ERROR] request="68bf29cc8b02b" component="TYPO3.CMS.Frontend.Configuration.TypoScript.ConditionMatching.ConditionMatcher": Call to a member function getConfiguration() on null - {"expression":"getDocumentType(3) == 'object'","exception":{}}
Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 
Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 

I have entered the settings in dfg-viewer/Configuration/TypoScript/Plugins/kitodo.typoscript

#------------------------------------------------------------------------------
# newspaper navigation
# -------------------------------------------------------------------------------

[getDocumentType({$config.storagePid}) == 'ephemera' or getDocumentType({$config.storagePid}) == 'newspaper']
page.10.variables {
  isNewspaper = TEXT
  isNewspaper.value = newspaper_anchor
}
[END]

[getDocumentType({$config.storagePid}) == 'year']
page.10.variables {
  isNewspaper = TEXT
  isNewspaper.value = newspaper_year
}
[END]

[getDocumentType({$config.storagePid}) == 'issue']
page.10.variables {
  isNewspaper = TEXT
  isNewspaper.value = newspaper_issue
}
[END]

[getDocumentType({$config.storagePid}) == 'object']
page.10.variables {
  isObject3D = TEXT
  isObject3D.value = object
}
[END]

The error only occurs when I call up a DFG viewer page of a newspaper. This error message does not occur on pages that are called up in the Presentation Viewer environment.

Instead of a calendar display (as desired), only a normal DFG Viewer page is displayed.

beatrycze-volk commented 10 months ago

Thanks for you report!

I will investigate the problem and write you back.

beatrycze-volk commented 10 months ago

I have made research and found out that error comes from Kitodo.Presentation (https://github.com/kitodo/kitodo-presentation/blob/63df5ebf49754a0bf9d4a0926f9398e573033b04/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php#L94).

Variable $this->configurationManager is null and this is the reason for the error. There must be a problem with DI in this class as this parameter should be set by the function injectConfigurationManager (https://github.com/kitodo/kitodo-presentation/blob/63df5ebf49754a0bf9d4a0926f9398e573033b04/Classes/ExpressionLanguage/DocumentTypeFunctionProvider.php#L66).

BFallert commented 10 months ago

If I add the following code before line 94, part of the error message is gone and I can at least see the annual overview:

$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\Extbase\\Object\\ObjectManager');
$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
$this->injectConfigurationManager($configurationManager);

Only the following error messages remain:

Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 
Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 

When i click on a year, i get a new error message, but i open a new issue for it. (https://github.com/kitodo/kitodo-presentation/issues/1105)

The new error message is:

Fatal error: Uncaught TypeError: Argument 1 passed to Kitodo\Dlf\Controller\CalendarController::getIssuesFromDocuments() must be of the type array, object given, called in /var/www/typo3/packages/bfallert/presentation/Classes/Controller/CalendarController.php on line 439 and defined in /var/www/typo3/packages/bfallert/presentation/Classes/Controller/CalendarController.php:489 Stack trace: #0 /var/www/typo3/packages/bfallert/presentation/Classes/Controller/CalendarController.php(439): Kitodo\Dlf\Controller\CalendarController->getIssuesFromDocuments() #1 /var/www/typo3/packages/bfallert/presentation/Classes/Controller/CalendarController.php(400): Kitodo\Dlf\Controller\CalendarController->getIssues() #2 /var/www/typo3/packages/bfallert/presentation/Classes/Controller/CalendarController.php(362): Kitodo\Dlf\Controller\CalendarController->getIssuesByYear() #3 /var/www/typo3/packages/bfallert/presentation/Classes/Controller/CalendarController.php(115): Kitodo\Dlf\Controller\CalendarController->buildCalendar() #4 /var/www/typo3/ in /var/www/typo3/packages/bfallert/presentation/Classes/Controller/CalendarController.php on line 489

csidirop commented 10 months ago

I have now tried this too. I have the same errors in the log except for the MathExpressionNode, which must come from somewhere else.

After adding the workaround lines and removing the type from the attribute the calendar works again.

cal

I think we should open a issue in presentation.

beatrycze-volk commented 10 months ago

Thank you both very much for this work!

I have now opened https://github.com/kitodo/kitodo-presentation/pull/1109 basing on the suggestions found here and in https://github.com/kitodo/kitodo-presentation/issues/1105.

BFallert commented 8 months ago

@beatrycze-volk Some of the messages are still available. Should I open a new issue for this?

Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 
Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 

Unfortunately, you cannot see which code is causing this message

beatrycze-volk commented 8 months ago

@beatrycze-volk Some of the messages are still available. Should I open a new issue for this?

Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 
Fri, 17 Nov 2023 13:46:19 +0100 [WARNING] request="68bf29cc8b02b" component="TYPO3.CMS.Core.Error.ErrorHandler": Core: Error handler (FE): PHP Warning: A non-numeric value encountered in /var/www/typo3/vendor/typo3fluid/fluid/src/Core/Parser/SyntaxTree/Expression/MathExpressionNode.php line 80 

Unfortunately, you cannot see which code is causing this message

Yes, as this is different error message than the one which was described in this issue.

beatrycze-volk commented 8 months ago

@BFallert we have found the reason for those errors in two places:

https://github.com/kitodo/kitodo-presentation/pull/1143 https://github.com/kitodo/kitodo-presentation/pull/1148

Hopefully it also fixes the problem for you :)

BFallert commented 8 months ago

Unfortunately, I still have the error in my error log

beatrycze-volk commented 8 months ago

Could you show me URL with which you are getting this error?

BFallert commented 7 months ago

At first I was unable to reproduce this error message exactly. After several tests, I have now found the pattern with which I can reliably cause the error message. When I call a url for a document for the first time, or the page is reloaded hard, i.e. shift reload, then I get the message. This is independent of whether the page is called up or hard reloaded in single page or double page view, with full text switched on or in GridView. https://playground.bib.uni-mannheim.de/werksansicht/daa/1539/2/double-0/pagegrid-0 (This URL is currently not working externally, so I could limit the error messages to my calls only. If necessary, I can open it again. The URL is also not yet stable as I am still working on the "route enhancers".)

image

beatrycze-volk commented 1 month ago

Could you check if this problem still exists for you? I have tested this functionality on my instance this week and the error was solved.

BFallert commented 1 month ago

I updated my installation this morning and the problem has disappeared. So we can close the issue.