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

Is cacheManager->generateResource work correct? It does not cache TVs... #14718

Open
iWatchYouFromAfar opened this issue Sep 5, 2019 · 1 comment

Comments

@iWatchYouFromAfar
Copy link

commented Sep 5, 2019

Summary

I'm trying to create a resource cache through a script, for this I use:
cacheManager->generateResource

Step to reproduce

Just execute this simple code:

$q = $modx->newQuery('modResource');
$q->sortby('id');
$q->where(array(
    'published' => true,
    'deleted' => false,
    'cacheable' => true,
    'searchable' => true,
    'class_key' => 'modDocument',
));
$q->limit(100);
$resources = $modx->getCollection('modResource', $q);
$modx->getCacheManager();
foreach ($resources as $page) {
    $page->process();
    $page->_contextKey = $page->get('context_key');
    $modx->cacheManager->generateResource($page);
}

Observed behavior

You get a resources cache without TVs.

Expected behavior

I expect to get a full cached resource with TVs.

Environment

MODX 2.7.1
PHP 7.2

@iWatchYouFromAfar iWatchYouFromAfar changed the title Is cacheManager->generateResource work correct? Is cacheManager->generateResource work correct? It does not cache TVs... Sep 5, 2019

@Mark-H

This comment has been minimized.

Copy link
Collaborator

commented Sep 6, 2019

I don't think that method was meant to be used outside of the regular resource rendering flow. It relies on the in-memory element and source cache, as well as registered scripts, so is not a completely self-contained way of generating the resource cache.

While that means the bug report is technically correct, calling it like you're doing now results in an incomplete cache, I don't think it's something we necessarily have to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.