Hello All,
- I’m testing Silverstripe: 4.10 + Fluent 6 + StaticPublisher 5.2*
It should be a good package, but it doesn’t work. In this thread I will try to bring you closer to the topic - maybe we can do it together
via terminal, via task, after generate all pages (100%) (49 pages) with current selected language, memory leaks and stops – appear. Can’t go for other lang. Need to test without Fluent as I remember – always have a little problems.
See this in action:
Show in action
[2022-07-17 13:42:48][INFO] Building **46** URLS
[2022-07-17 13:42:48][INFO] array (
0 => 'http://localhost/axonnite/pl/?stage=Live',
1 => 'http://localhost/axonnite/pl/zastosowania/kosmetyka/?stage=Live',
...
44 => 'http://localhost/axonnite/pl/page-not-found/?stage=Live',
45 => 'http://localhost/axonnite/pl/server-error/?stage=Live',
)
[2022-07-17 13:44:20][INFO] <br />
<b>Fatal error</b>: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in <b>/Users/.../axonnite/vendor/symfony/var-exporter/Internal/Registry.php</b> on line <b>43</b><br />
After last Page, Queue still running until memory limit stops.
I would not like to quit, it would be good if it worked - as it should! I have always been awesome, it is a must have in every project.
Thanks for any help!
EDIT:
Some tests
// StaticCacheFullBuildJob.php to see all locales
foreach (Locale::getLocales() as $locale) {
$state = FluentState::singleton();
$state->setLocale($locale->getLocale());
$livePages = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE);
foreach ($livePages as $page) {
if ($page->hasExtension(PublishableSiteTree::class) || $page instanceof StaticallyPublishable) {
$urls = array_merge($urls, $page->urlsToCache());
}
}
}
Now /cache has /en and /pl pages – ok, first steep done. Now Handling Requests by SilverStripe, Using .htaccess
EDIT 2:
// /public/.htaccess
# Config for site in a subdirectory
# (remove the following four rules if site is on root of a domain. E.g. test.com rather than test.com/my-site)
# Cached content - sub-pages (site in sub-directory)
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{QUERY_STRING} ^$
#RewriteCond %{REQUEST_URI} /(.*[^/])/(.*[^/])/?$
RewriteCond %{REQUEST_URI} /(.*[^/])/(.*[^/])/?/(.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}/%1/cache/%2/%3.html -f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* cache/%2/%3.html [L]
# Cached content - homepage (site in sub-directory)
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} ^/(.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}/%1/cache/index.html -f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* cache/index.html [L]
Testing… but now fetch good .html
EDIT 3:
Sitll is problem with links ?stage=Live attribute and others but steep by steep.
// PublishableSiteTree.php after add VersionedMode – looks nice, but don’t work.
// Ok, via sake dev/tasks/ProcessJobQueueTask – ‘?stage=Live’ is gone.
public function urlsToCache() {
//return [Director::absoluteURL($this->getOwner()->Link()) => 0];
return Versioned::withVersionedMode(function () {
Versioned::set_reading_mode(Versioned::LIVE);
return [Director::absoluteURL($this->getOwner()->Link()) => 0];
});
}
EDIT 4: For testing, I changed php to 8.1 – and update to 4.11+, some error:
Uncaught Exception TypeError: "Symbiote\QueuedJobs\Services\QueuedJobService::handleBrokenJobException(): Argument #2 ($job) must be of type Symbiote\QueuedJobs\Services\QueuedJob, null given
Fresh install SilverStripe 4.11 + StaticPublisher · Issue #379 · symbiote/silverstripe-queuedjobs · GitHub (