Content file of default language gets overwritten with secondary language content

Ran into some strange behavior after updating a multi-lang project to v5. Whenever I save a page in a secondary language it will not only save the changes to the secondary language’s text file but also overwrite the default language’s text file with its content. I think it’s somehow connected to a part of my hook logic which manages to save the modified meta (date + user):


    'hooks' => [

			'page.create:after' => function ($page) {

				$creator  = $this->user()->id();
				$created  = $page->modified('%Y-%m-%d %H:%M');

				try {
					$page->update(array(
						'createdby' => $creator,
						'createdon' => $created
					));
				} catch(Exception $e) {
					echo $e->getMessage();
				}

			},

			'page.update:after' => function ($newPage, $oldPage) {

				$editor   = $this->user()->id();
				$modified = $newPage->modified('%Y-%m-%d %H:%M');

				try {
					$newPage->update(array(
						'lasteditby' => $editor,
						'lastediton' => $modified
					));
				} catch(Exception $e) {
					echo $e->getMessage();
				}

			}
		],

If I drop this from the config.php it all works fine again. Also no issues if I leave it there and go back to v4.8.0. Any idea what I’m doing wrong?

I guess that happens because $page->update() without a language code updates the default language, unless that also happens without the hook, related topic: Content file of default language gets overwritten

Are you using the latest Kirby 5 version (5.0.3)?

Yes, I’m running 5.0.3. BTW: It also happens with a clean Starterkit after applying that hook.

I guess that happens because $page->update() without a language code updates the default language, unless that also happens without the hook

Hm… I don’t think that would be the expected behavior, it could kill a bunch of content. The $lang parameter is optional, isn’t it? I mean it all worked perfectly fine with v4, never had any problems with it.

related topic: Content file of default language gets overwritten

WTF is that? Looks like a failed bot comment trying to copy my topic… :smile:

Haha, yes, deleted that user.