“Exception: File not found” after changing Virtual Page status

Hej all!

I am working with Virtual Content (from an API) with merged content sources and all this works well so far, except for one case:

If I upload a file (eg. thumbnail) to a page with “unlisted” status and change the status to “listed,” the image will be transferred and appear in the content folder, BUT will show a missing image placeholder in the Panel. The UUID of the image and in the .txt file of the page do, however, stay the same and should logically be loaded. The console outputs an unexpected 500 Error with no further information.

This is my setup:

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

    $results = [];
    $pages = [];
    $request = Remote::get(); // removed here but exists in actual code

    if ($request->code() === 200) {
      $results = $request->json(false)->data;
    }
    
    foreach ($results as $unit) {
      $slug = Str::slug($unit->title ?? $unit->name);
      $page = $this->subpages()->find($slug);

      $pages[] = [
        'slug' => $slug,
        'template' => 'unit',
        'model' => 'unit',
        'files' => $page ? $page->files()->toArray() : null,
        'content' => [
          'title' => $page ? $page->content()->title()->value() : ($unit->title ?? $unit->name),
          'region' => $unit->region,
          'price' => $unit->price,
          'location' => [
            'lat' => $unit->lat,
            'lng' => $unit->lng
          ],
          'description' => $page ? $page->description()->value() : null,
          'thumbnail' => $page ? $page->thumbnail()->value() : null,
          'uuid' => $unit->id
        ]
      ];
    }

    return $this->children = Pages::factory($pages, $this);
  }

The problem I am trying to solve with this is basically just the import of all items from another system, and perhaps syncing the values if they change at the source. Perhaps a custom route that fetches the data on-demand with the push of a button would make more sense to spare all complications of merging all the content?

Appcreciate any thoughts.

That screenshot is of a files section or a files field?

And does it remain broken after reloading the Panel?

That screenshot is of a files section or a files field?

It is a files field

thumbnail:
  type: files
  multiple: false

and stored correctly in the txt file like so: Thumbnail: - 'file://iMSiqXjxKk3ckXrP'.


And does it remain broken after reloading the Panel?

It does, always with the same 500 Error.

{
    "status": "error",
    "exception": "Exception",
    "code": 1,
    "message": "File not found: ",
    "details": null,
    "file": "\/vendor\/claviska\/simpleimage\/src\/claviska\/SimpleImage.php",
    "line": 236
}

Where does the broken file point to and does this path exist in the media folder? Wondering if it has to do with a missing num prop in the children method, but just guessing.

And just one more question to rule out one pitfall: does the page have unsaved changes right now?

Where does the broken file point to

http://localhost:8000/media/pages/objekte/turmlihus/2cfa667f0d-0/turmlihus-76x.png


Does this path exist in the media folder?

Kind of. There are two folders for that page,

  1. 2cfa667f0d-0
  2. 2cfa667f0d-1728493269

the first only includes the .jobs folder with the different .json files. The second one does include the preview image and the .jobs folder as well. The single 0 at the end does look like something went wrong there.


Does the page have unsaved changes right now?

Nope, it does not.

Curiously though: if, before uploading an image, I adjust the title (only the title, not the slug), then I am not able to change the status at all:

Regarding your point here: If I were to set the num when fetching the pages, it would not be possible to change the status later, would it? Since the num is always set and will override any change I make as

/turmlihus    = unlisted
/0_turmlihus  = listed

Hm, well, but the problem is that the status of the children pages should always reflect the status in the filesystem and that is currently not the case. So you should probably check the status of the subpage and attach the num prop accordingly. As it is, you have a status in the file system, but not in your children pages. But maybe that is unrelated after all.

But the 0 in the media hash does indeed look wrong. The second part should be the file modification date.

Can you elaborate on that? Do you mean something like

'num' => $page ? ($page->status() == 'listed' ? 0 : null) : null

In the filesystem, I currently only see the folders for the pages I have made changes to. The rest is still purely virtual.

Yes, but the syntax is wrong. should be

'num' => $page && ($page->status() === 'listed') ? 0  : null

This now results in the following behaviour:

All pages are unlisted, and when I try to set one to listed, it

  1. shows the select dropdown for the position (which I don’t want because they all should have num: 0, but still respect unlisted or listed stati—which seems to be contradictory here)
  2. does not change the status but instead errors: “The page directory cannot be moved” again—even with neither uploading an image or changing the title