Hi,
I am setting up virtual pages using this cookbook recipe:
https://getkirby.com/docs/guide/virtual-content/virtual-pages-image-gallery
I have done this before on other sites but am getting an odd issue with this implementation - it is the first time I have done it with the latest Kirby version, which might be the issue.
Error is:
Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?
The server error log is massive, as it looks to be stuck in a loop, first 30 lines are below:
[02-Apr-2024 23:30:08 Europe/London] Error: Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? in /home/giantcre/rowles/kirby/src/Data/Yaml.php:60
Stack trace:
#0 /home/giantcre/rowles/kirby/src/Data/Yaml.php(47): Kirby\Data\Yaml::handler()
#1 /home/giantcre/rowles/kirby/src/Data/Data.php(81): Kirby\Data\Yaml::decode('- file://7f87is...')
#2 /home/giantcre/rowles/kirby/config/methods.php(104): Kirby\Data\Data::decode('- file://7f87is...', 'yaml')
#3 /home/giantcre/rowles/kirby/src/Content/Field.php(78): Kirby\Cms\Core->{closure}(Object(Kirby\Content\Field), 'yaml')
#4 /home/giantcre/rowles/kirby/config/methods.php(150): Kirby\Content\Field->__call('todata', Array)
#5 /home/giantcre/rowles/kirby/src/Content/Field.php(78): Kirby\Cms\Core->{closure}(Object(Kirby\Content\Field))
#6 /home/giantcre/rowles/kirby/config/methods.php(137): Kirby\Content\Field->__call('tofiles', Array)
#7 /home/giantcre/rowles/kirby/src/Content/Field.php(78): Kirby\Cms\Core->{closure}(Object(Kirby\Content\Field))
#8 /home/giantcre/rowles/site/models/artwork.php(10): Kirby\Content\Field->__call('tofile', Array)
#9 /home/giantcre/rowles/kirby/src/Cms/HasChildren.php(48): ArtworkPage->children()
#10 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(52): Kirby\Cms\Page->childrenAndDrafts()
#11 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(54): Kirby\Uuid\PageUuid::index(Object(ArtworkPage))
#12 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(54): Kirby\Uuid\PageUuid::index(Object(Kirby\Cms\Page))
#13 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(54): Kirby\Uuid\PageUuid::index(Object(Kirby\Cms\Page))
#14 /home/giantcre/rowles/kirby/src/Uuid/FileUuid.php(60): Kirby\Uuid\PageUuid::index()
#15 /home/giantcre/rowles/kirby/src/Uuid/Uuid.php(255): Kirby\Uuid\FileUuid::index()
#16 /home/giantcre/rowles/kirby/src/Uuid/ModelUuid.php(31): Kirby\Uuid\Uuid->indexes()
#17 /home/giantcre/rowles/kirby/src/Uuid/Uuid.php(335): Kirby\Uuid\ModelUuid->findByIndex()
#18 /home/giantcre/rowles/kirby/src/Cms/App.php(623): Kirby\Uuid\Uuid->model()
#19 /home/giantcre/rowles/kirby/config/methods.php(151): Kirby\Cms\App->file('file://7f87isk3...', Object(ArtworkPage))
#20 /home/giantcre/rowles/kirby/src/Content/Field.php(78): Kirby\Cms\Core->{closure}(Object(Kirby\Content\Field))
#21 /home/giantcre/rowles/kirby/config/methods.php(137): Kirby\Content\Field->__call('tofiles', Array)
#22 /home/giantcre/rowles/kirby/src/Content/Field.php(78): Kirby\Cms\Core->{closure}(Object(Kirby\Content\Field))
#23 /home/giantcre/rowles/site/models/artwork.php(10): Kirby\Content\Field->__call('tofile', Array)
#24 /home/giantcre/rowles/kirby/src/Cms/HasChildren.php(48): ArtworkPage->children()
#25 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(52): Kirby\Cms\Page->childrenAndDrafts()
#26 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(54): Kirby\Uuid\PageUuid::index(Object(ArtworkPage))
#27 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(54): Kirby\Uuid\PageUuid::index(Object(Kirby\Cms\Page))
#28 /home/giantcre/rowles/kirby/src/Uuid/PageUuid.php(54): Kirby\Uuid\PageUuid::index(Object(Kirby\Cms\Page))
#29 /home/giantcre/rowles/kirby/src/Uuid/FileUuid.php(60): Kirby\Uuid\PageUuid::index()
#30 /home/giantcre/rowles/kirby/src/Uuid/Uuid.php(255): Kirby\Uuid\FileUuid::index()
The only file mentioned in the log which I have created is /site/models/artwork.php
, which is below:
<?php
class ArtworkPage extends Page
{
public function children(): Kirby\Cms\Pages
{
$images = [];
if($this->mainImage()->isNotEmpty()):
$images[] = [
'slug' => $this->mainImage()->toFile()->name(),
'num' => 0,
'template' => 'lightbox-image',
'model' => 'lightbox-image',
];
endif;
if($this->additionalImages()->isNotEmpty()):
foreach ($this->additionalImages()->toFiles() as $image) {
$images[] = [
'slug' => $image->name(),
'num' => $image->sort()->value(),
'template' => 'lightbox-image',
'model' => 'lightbox-image',
];
}
endif;
return Pages::factory($images, $this);
}
}
Line 10, which is mentioned in the error log, is 'slug' => $this->mainImage()->toFile()->name(),
.
If anyone has any thoughts what might be causing this that would be awesome, I am totally stuck at the moment.