在TYPO3 9.5中,我们能够以这种方式从我们的调度程序类中生成Typolink:
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$contentRenderer = $objectManager->get(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
$command = $this->linkCommand($uid, 0);
$uri = $contentRenderer->typoLink_URL($command);
return $uri;对于TYPO3 v10,当通过Cronjob调用时,相同的代码将不再工作。
当从后端手动运行任务时,此代码可以很好地工作,并根据页面uid生成URL。但是当通过Cronjob运行时,会生成以下输出:
The parsedUri "http:///www/sites/webXXXX/html/typo3/sysext/core/bin/typo3" appears to be malformed
我尝试以多种方式生成链接,但它们都以相同的错误消息结束。我不确定Cronjob在这里尝试了什么,因为上面的parsedUri看起来完全错误。
有没有人在使用Cronjob和TYPO3 v10时遇到过类似的问题?这个服务器是相关的,还是我可以通过PHP修复的?我真的不知道这是什么原因。
发布于 2021-04-02 21:32:59
我会试一试(未经测试):
$t3Urn = 't3://page?uid=500#5996';
// LinkService to get typolink configuration from t3://...
$typolinkConfig = GeneralUtility::makeInstance(
\TYPO3\CMS\Core\LinkHandling\LinkService::class
)->$linkService->resolve($t3Urn);
// Absolute (if needed). Make sure that Site config contains a full base for the
// requested page rootline AND that this base is also active in your cron environment.
// If you use application context to resolve bases, add it to the scheduler env:
// TYPO3_CONTEXT=Production/MySubcontext …/vendor/bin/typo3 scheduler:run
$typolinkConfig['forceAbsoluteUrl'] = true;
return GeneralUtility::makeInstance(
\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class
)->typoLink_URL($typolinkConfig);https://stackoverflow.com/questions/66869252
复制相似问题