Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiration date must be an integer, a DateInterval or null, "double" given #2529

Closed
zzzzBov opened this issue May 31, 2019 · 3 comments
Closed
Assignees

Comments

@zzzzBov
Copy link

zzzzBov commented May 31, 2019

I've just updated to latest and now convertTtl is failing with the following error message:

Expiration date must be an integer, a DateInterval or null, "double" given

/system/src/Grav/Framework/Cache/CacheTrait.php

     */
    protected function convertTtl($ttl)
    {
        if ($ttl === null) {
            return $this->getDefaultLifetime();
        }
 
        if (\is_int($ttl)) {
            return $ttl;
        }
 
        if ($ttl instanceof \DateInterval) {
            $ttl = (int) \DateTime::createFromFormat('U', '0')->add($ttl)->format('U');
        }
 
        throw new InvalidArgumentException(
            sprintf(
                'Expiration date must be an integer, a DateInterval or null, "%s" given',
                \is_object($ttl) ? \get_class($ttl) : \gettype($ttl)
            )
        );
    }
}

I believe checking for a double and either converting it to an int or returning it as-is may solve the issue:

if (\is_int($ttl)) {
    return $ttl;
}

if (\is_double($ttl)) {
    return intval($ttl);
}

...but I don't know enough about the rest of the system to verify that that is a safe change.

@rhukster
Copy link
Member

Can you please turn on full Error Logging in system.yaml, and provide a screenshot of the stack trace? I really want to know where this double is coming from. Cheers.

@zzzzBov
Copy link
Author

zzzzBov commented Jun 5, 2019

Here's the stack trace from the logs slightly cleaned up.

[2019-06-05 13:03:57] grav.CRITICAL: Expiration date must be an integer, a DateInterval or null, "double" given - Trace: 
#0 [redacted]/system/src/Grav/Framework/Cache/CacheTrait.php(42): Grav\Framework\Cache\AbstractCache->convertTtl(604800) 
#1 [redacted]/system/src/Grav/Framework/Cache/AbstractCache.php(29): Grav\Framework\Cache\AbstractCache->init('', 604800) 
#2 [redacted]/system/src/Grav/Framework/Cache/Adapter/DoctrineCache.php(38): Grav\Framework\Cache\AbstractCache->__construct('', 604800) 
#3 [redacted]/system/src/Grav/Common/Cache.php(155): Grav\Framework\Cache\Adapter\DoctrineCache->__construct(Object(Doctrine\Common\Cache\FilesystemCache), '', 604800) 
#4 [redacted]/system/src/Grav/Common/Media/Traits/MediaTrait.php(122): Grav\Common\Cache->getSimpleCache() 
#5 [redacted]/system/src/Grav/Common/Media/Traits/MediaTrait.php(71): Grav\Common\Page\Page->getMediaCache() 
#6 [redacted]/system/src/Grav/Common/Page/Page.php(1294): Grav\Common\Page\Page->getMedia() 
#7 [redacted]/system/src/Grav/Common/Page/Page.php(654): Grav\Common\Page\Page->media() 
#8 [redacted]/system/src/Grav/Common/Twig/Twig.php(366): Grav\Common\Page\Page->content() 
#9 [redacted]/system/src/Grav/Common/Service/OutputServiceProvider.php(28): Grav\Common\Twig\Twig->processSite('html') 
#10 [redacted]/vendor/pimple/pimple/src/Pimple/Container.php(118): Grav\Common\Service\OutputServiceProvider->Grav\Common\Service\{closure}(Object(Grav\Common\Grav)) 
#11 [redacted]/system/src/Grav/Common/Processors/RenderProcessor.php(28): Pimple\Container->offsetGet('output') 
#12 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\RenderProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#13 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#14 [redacted]/system/src/Grav/Common/Processors/DebuggerAssetsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#15 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\DebuggerAssetsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#16 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#17 [redacted]/system/src/Grav/Common/Processors/PagesProcessor.php(69): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#18 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\PagesProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#19 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#20 [redacted]/system/src/Grav/Common/Processors/TwigProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#21 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\TwigProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#22 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#23 [redacted]/system/src/Grav/Common/Processors/AssetsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#24 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\AssetsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#25 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#26 [redacted]/system/src/Grav/Common/Processors/SchedulerProcessor.php(29): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#27 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\SchedulerProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#28 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#29 [redacted]/system/src/Grav/Common/Processors/BackupsProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#30 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\BackupsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#31 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#32 [redacted]/system/src/Grav/Common/Processors/TasksProcessor.php(59): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#33 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\TasksProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#34 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#35 [redacted]/system/src/Grav/Common/Processors/RequestProcessor.php(52): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#36 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\RequestProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#37 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#38 [redacted]/system/src/Grav/Common/Processors/ThemesProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#39 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ThemesProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#40 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#41 [redacted]/system/src/Grav/Common/Processors/PluginsProcessor.php(30): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#42 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\PluginsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#43 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#44 [redacted]/system/src/Grav/Common/Processors/InitializeProcessor.php(78): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#45 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\InitializeProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#46 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#47 [redacted]/system/src/Grav/Common/Processors/DebuggerProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#48 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\DebuggerProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#49 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#50 [redacted]/system/src/Grav/Common/Processors/ErrorsProcessor.php(27): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#51 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ErrorsProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#52 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#53 [redacted]/system/src/Grav/Common/Processors/LoggerProcessor.php(48): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#54 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\LoggerProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#55 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#56 [redacted]/system/src/Grav/Common/Processors/ConfigurationProcessor.php(28): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#57 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(45): Grav\Common\Processors\ConfigurationProcessor->process(Object(Nyholm\Psr7\ServerRequest), Object(Grav\Framework\RequestHandler\RequestHandler)) 
#58 [redacted]/system/src/Grav/Framework/RequestHandler/Traits/RequestHandlerTrait.php(57): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#59 [redacted]/system/src/Grav/Common/Grav.php(249): Grav\Framework\RequestHandler\RequestHandler->handle(Object(Nyholm\Psr7\ServerRequest)) 
#60 [redacted]/index.php(53): Grav\Common\Grav->process() 
#61 {main} [] []

@rhukster
Copy link
Member

rhukster commented Jun 5, 2019

Is this Grav install from github where you had to install vendor libraries manually? I suggest running:

$ composer install --no-dev

to ensure your vendor libraries are up to date?

Alternatively, you can try downloading a fresh Grav package from https://getgrav.org/downloads, and then simply copying over your user/ folder from old site to the new site.

@mahagr mahagr self-assigned this Jun 20, 2019
mahagr added a commit that referenced this issue Jul 9, 2019
@mahagr mahagr closed this as completed Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants