Skip to content
This repository was archived by the owner on Oct 6, 2022. It is now read-only.
This repository was archived by the owner on Oct 6, 2022. It is now read-only.

Can't programmatically reference a new file in a file field in a new page #86

@JerikoOne

Description

@JerikoOne

What I want to achieve is programmatically update or add new pages, add a file to these pages if it doesn't exist yet and reference it in a files field. Blueprints for the page and the file are correctly set up.

$pageData = [...];

if( $pageDoesNotExist == true ) :
  $page = $parent->createChild([ 'slug' => ..., 'template' => 'template', 'content' => $pageData ]);
  $page = $page->changeStatus('listed');
else:
  $page = $page->update( $pageData );
endif;

if( $fileDoesNotExist == true ) :
  $file = $page->createFile(...) // Array with required properties and such
  $page = $page->update([ 'files_field' => $file->id() ]);
endif;
  • Auto ID is added to the page and file as expected.
  • If the page already exists everything works as expected, the file get's referenced in the files field from that page.
  • If the page is newly created however the file doesn't get referenced in the files field from that page.
  • If I remove the plugin everything works as expected, also with newly created pages.

I can only assume that it's some sort of caching issue with the SQlite database, however I couldn't figure it out myself.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions