Page->update removes all fields

is there any case, where the page update removes all field informations?

e.g. i am using it to update a price

foreach($products as $product){
  // calculate $newprice
  $product->update([
    'price' => number_format($newprice,2);
  ],'de'); // DE is default and only lang
}

and sometimes, this will delete all content/field of said page e.g. title changes into uid, all other fields are emtpy, including images/files-fields. (files are untouched)

in this example loop, after days, or weeks, maybe one out of 20 pages are being reset.

looking at error logs, it seems there is no error.

  • what if the calculation results in “null”, or the calculation throws an unexpected error?
  • is there any scenario where it would remove all fields?
  • what if the page would have a “lock” file and the update will happen?
  • what if the page update runs twice within a second? (more like, the script is not finished with processing the loop but another loop is being started)

trying to pinpoint the problem, is there any other way to make sure it’s only possible to update the one field without being being possible to touch the rest?

Where are you using this loop?

in a route

Do you have any page update hooks in place?

If you suspect any errors, you should catch and log them

there is one hook,
the hook however checks if the new/old page is a certain template before doing anything… the hook basically only triggers sending an email. no page->update

basically i am wondering, since there is no error (logged) and the content of 1 / 20 pages from that loop gets all fields reset.

If I were you I’d wrap the code in Try/ catch statements and log any errors that occur

thanks, i have done that, i’ll wait and see if any error is being reported with try/catch.