Server dies when searching for UUID that does not exist

i am fetching pages by UUID using the code below. if the UUID does not exist (anymore), the server hangs/crashes. the dump will never happen.

$uuid = "eoc2RzwWMZv45eoh";

// this will succeed
$allQuestions = page('page://3YQpF5O8xgXPO5p9')->children(); 

// this will make the server die if $uuid does not exist
$questionPage = $allQuestions->find('page://' . $uuid); 

// this will never happen :-(
dump($questionPage);

additionally i could not find any infos what $pages->find() will return if the search did not succeed. Empty collection? null/false? Will the following be correct given the server does not crash?

if (!$questionPage) continue;

Thanks for your help!

Do you receive any error (on screen, in the PHP logs) for when the server crashes?

unfortunately not, just :disappointed:

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.


Apache/2.4.54 (Debian) Server at mon-teilhabemodul.ddev.site Port 80

the logs:

[Tue Jun 13 10:00:08.576828 2023] [proxy_fcgi:error] [pid 2078] [client 172.22.0.6:46736] AH01067: Failed to read FastCGI header, referer: https://mon-teilhabemodul.ddev.site/panel/pages/pirmasens?language=de
[Tue Jun 13 10:00:08.577459 2023] [proxy_fcgi:error] [pid 2078] (104)Connection reset by peer: [client 172.22.0.6:46736] AH01075: Error dispatching request to : , referer: https://mon-teilhabemodul.ddev.site/panel/pages/pirmasens?language=de
[13-Jun-2023 10:00:08] WARNING: [pool www] child 23903 exited on signal 11 (SIGSEGV - core dumped) after 951.178861 seconds from start
[13-Jun-2023 10:00:08] NOTICE: [pool www] child 24462 started

What’s your Kirby version?

Kirby 3.9.4, PHP 8.1.8

I tested a similar example with 3.9.5/PHP 8.2.0, and cannot reproduce the issue. If I pass a wrong UUID to find (the example I used was

var_dump($site->index()->find('page://3YQpF5O8xgXPO5p9'));

it simply returns null, as is to be expected.

yeah i just did the same in a startker kit and can’t reproduce either. maybe because i am doing this within a loop. here’s my full code from a page-model (derived from cookbook / virtual pages / mixed content). maybe an experienced eye can spot the issue ;-). thanks for having a look!

public function children()
    {
        if ($this->children instanceof Pages) {
            return $this->children;
        }

        $children = array();
        $questions= page('page://3YQpF5O8xgXPO5p9')->children(); // @todo: remove hardcoded page

        foreach ($this->subpages() as $entry) {
        
            $payload = Json::decode($entry->json()->value());
          
            $content = $entry->content()->toArray();
            
            foreach($payload as $uuid => $answer) {
                
                $questionPage = $questions->find('page://'.$uuid);
                // dump($questionPage);
                if (!$questionPage) continue;

                switch ($questionPage->intendedTemplate()->name()) {
                    case 'question-checkbox':
                        $possibleAnswers = $questionPage->answers()->toStructure();
                        
                        $allAnswers = array_map(function($a) use ($possibleAnswers) {
                                return $possibleAnswers->findBy('id', $a)->answer()->value();
                        }, $answer);
                        
                        $content[$uuid] = implode(', ', $allAnswers);
                        break;
                    
                    case 'question-text':
                        if (isset($answer['name'])) break; // skip files
                        
                        foreach($answer as $id => $value) {
                            $content[$uuid.$id] = $value;
                        }
                        break;
                
                    default:
                        // nada
                        break;
                }
            }

            $children[] = [
                'slug'     => $entry->slug(),
                'template' => 'teilhabemodul-beitrag',
                'model'    => 'teilhabemodul-beitrag',
                'num'      => $entry->num(),
                'content'  => [
                    'json'=> $entry->json()->value(),
                    ...$content
                ]
            ];
        };
        
        
        return $this->children = Pages::factory($children, $this);
    }

the “Payload” looks like this:

{"BEoSysV8nJVZBcRX":["0","2"],"mA1B7bhohRI8hUS2":["2","9","10"],"z0aUORsyzeUauwP2":{"1":"Alles!"},"XLv2Q0QXul6kCLOz":["4","5","6"],"eTbV7kTzAJwOVe2J":{"1":"Honk","2":"Kalk","3":"13"},"eoc2RzwWMZv45eoh":{"name":{"999":"200126_ahk_halle_238a9808-klein.jpg"},"full_path":{"999":"200126_ahk_halle_238a9808-klein.jpg"},"type":{"999":"image/jpeg"},"tmp_name":{"999":"/tmp/phptvpqND"},"error":{"999":0},"size":{"999":430739}}}

you seem to be checking uuid which is reading the content file of a lot of page objects. how many in total do you have?

consider my GitHub - bnomei/kirby3-boost: Boost the speed of Kirby by having content files of pages cached and a fast lookup based on uuids which can put all content in an cache like apcu and has a super fast lookup helper for uuids ($page = boost($uuid)).

Which page are you calling here? The one with the model or a different one?

a different one.

currently there a just a handful pages. we are expecting a total of ~30 ion prod

Could you provide a zip of the project via download link in PM, I think I need to take a closer look at the code?