kitodo-presentation icon indicating copy to clipboard operation
kitodo-presentation copied to clipboard

Silent fail to download METS from URI depending on TYPO3 configuration

Open claussni opened this issue 6 years ago • 3 comments

Kitodo.Presentation might silently fail to download METS document when given a URL via the id query parameter. The problem arises from the use of \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl().

https://api.typo3.org/typo3cms/7/html/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_utility_1_1_general_utility.html#ae1e248cb7ee687542a49328d24591de6

From the documentation:

Reads the file or url $url and returns the content If you are having trouble with proxys when reading URLs you can configure your way out of that with settings like $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] etc.

Offending lines

  • https://github.com/kitodo/kitodo-presentation/blob/2.x/common/class.tx_dlf_document.php#L1260
  • https://github.com/kitodo/kitodo-presentation/blob/2.x/common/class.tx_dlf_document.php#L1036

claussni avatar Mar 28 '19 07:03 claussni

I don't see an issue here. If loading of the METS file fails, a message in devlog is thrown indicating the problem. What would you expect to happen alternatively?

sebastian-meyer avatar Mar 28 '19 08:03 sebastian-meyer

I see, you're right. The devlog is filled with "severe" errors. It also contains a message about this problem. However, I might have overlooked it because of its label: [tx_dlf_document->load(http://localhost:8000/index... It's not easy to spot an error here.

Two suggestions:

  1. Shorter and more concise message text
  2. Include the error report in Extra Data section.

claussni avatar Mar 28 '19 09:03 claussni

There are even more places, where more detailed error reporting could be used:

$ grep -R 'GeneralUtility::getUrl('
plugins/pageview/class.tx_dlf_geturl_eid.php:        $fetchedHeader = GeneralUtility::getUrl($url, 2);
plugins/pageview/class.tx_dlf_geturl_eid.php:            $fetchedData = GeneralUtility::getUrl($url, $includeHeader);
plugins/pageview/class.tx_dlf_geturl_eid.php:        $fetchedHeader = explode("\n", GeneralUtility::getUrl($url, 2));
common/class.tx_dlf_indexing.php:                $xml = simplexml_load_string(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($file));
common/class.tx_dlf_document.php:                $rawTextXml = simplexml_load_string(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($file));
common/class.tx_dlf_document.php:            $xml = simplexml_load_string(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($location));

claussni avatar Mar 28 '19 09:03 claussni