kirby icon indicating copy to clipboard operation
kirby copied to clipboard

Second writer field content is deleted on changing page slug

Open tritos-design opened this issue 2 years ago • 18 comments

Description

Precondition: Two writer fields in a single blueprint (there may be more than these two fields); both fields are filled with some data and saved When changing the page's slug, the content of the second writer field is deleted and the orange save/dismiss bar appears. When saving, the content of the second writer field is written to disk as empty. When dismissing, the original content is restored.

Expected behavior
The content of the second writer field should not be deleted.

To reproduce

  1. Create a blueprint with at least two writer fields.
  2. Save some arbitrary data in the writer fields.
  3. Change the page slug.
  4. See that the content of the second writer field has been deleted.

Your setup

Kirby Version
3.6.2

Console output
No errors logged.

Your system (please complete the following information) Seen across different browsers (Firefox, Chrome) and different systems (Linux, Windows).

tritos-design avatar Feb 26 '22 12:02 tritos-design

@tritos-design I couldn't reproduce the issue.

  1. Do you have the same issue with starterkit or plainkit?
  2. If you are having the same issue in starterkit/plainkit, can you share the content you entered in the fields with us? (maybe it's related to content)

afbora avatar Feb 28 '22 09:02 afbora

@afbora Yes, the same happens with the latest starterkit (3.6.2). I only made one modification in site/blueprints/pages/note.yml from

columns:
  - width: 2/3
    # This columns only has a single field
    fields:
      text:
        type: blocks

to

columns:
  - width: 2/3
    # This columns only has a single field
    fields:
      w1:
        type: writer
      w2:
        type: writer
      text:
        type: blocks

Then I start the php built-in verser via php -S localhost:8000 kirby/router.php, go to http://localhost:8000/panel/pages/notes+exploring-the-universe add the text qwe to w1 and asd to w2 and save the changes. Then I click the page title and change the slug from exploring-the-universe to exploring-the-universe2. Result: The orange change/revert bar appears and the content of the second writer field w2 has disappeared. I can get the content back by clicking revert, but it shouldn't disappear in the first place.

Can you reproduce this?

P.S.: I'm running PHP 8.0.16 locally, if that might be relevant.

tritos-design avatar Feb 28 '22 11:02 tritos-design

Can you reproduce this?

Nope 🤷‍♂️

https://user-images.githubusercontent.com/3393422/155997096-97f49aef-f466-4e7e-9e9a-31fea6660991.mp4

afbora avatar Feb 28 '22 14:02 afbora

OK, this leaves me confused. I have no idea. I just repeated the process and literally grabbed the latest starterkit from github, adjusted note.yml and the result is again the error in Firefox and Chromium.

https://user-images.githubusercontent.com/51099789/156002739-06e35c41-362b-4dfe-be06-b4766fe7b43a.mp4

tritos-design avatar Feb 28 '22 14:02 tritos-design

Thanks for tests. I have no idea either. May be related with browser or local setup configurations.

May I ask you to try one last thing? Can you reproduce the same issue in 3.5.8, 3.6.0 or 3.6.1? Maybe that can give us a clue if we find out which one worked last.

afbora avatar Feb 28 '22 14:02 afbora

I did some more testing and I can confirm that the issue was introduced in 3.6.2. It's working fine in 3.6.1.

Edit: The error also occurs in 3.5.8, but not in 3.6.0 and 3.6.1. Was something introduced in 3.6.0 and removed in 3.6.2?

tritos-design avatar Feb 28 '22 15:02 tritos-design

I just tested this as well with a freshly cloned Starterkit in my environment and can reproduce the issue.

Tested with Kirby 3.6.2, Firefox 97.0.1 (64-Bit), MacBook Pro with MacOS Monterey 12.1, and Valet with PHP 8.0.15 with Opcache extension enabled.

When I disable Opcache, this doesn't happen.

texnixe avatar Feb 28 '22 19:02 texnixe

@texnixe you know better. Could it be because of that? https://getkirby.com/docs/guide/troubleshooting/panel#opcache-server-side-caching-in-general

afbora avatar Feb 28 '22 19:02 afbora

@afbora I don't know. I was just testing and saw that you couldn't reproduce it while I could. So I had a closer look at my settings (didn't even know that Opcache was enabled, because I usually disable it so as not to run into such issues).

texnixe avatar Feb 28 '22 19:02 texnixe

@afbora It might really be due to opcache. Thanks for finding out, @texnixe. Further test results: On a web server (Mittwald) the setting "Performance+" clearly has some influence. When it's turned on, the issue always occurs. When it's turned off, the issue doesn't occur. According to Mittwald "Performance+" activates opcache and apcu (see here https://www.mittwald.de/faq/administration/php/performance-plus; unfortunately only in German). Locally, I tried disabling opcache, but it had no effect there, even though I confirmed that opcache was off via phpinfo(). However, this might be due to my local settings, I wouldn't bother about that too much.

For the time being, I can disable opcache on the server which is fine for now (the customer changes slugs quite frequently during development), but as a long-term solution it would be nice to identify and eliminate the root cause.

tritos-design avatar Feb 28 '22 22:02 tritos-design

It's good that we found clues. So, for a permanent solution, did you apply the solutions in this article? https://getkirby.com/docs/guide/troubleshooting/panel#opcache-server-side-caching-in-general

afbora avatar Mar 01 '22 09:03 afbora

Yes, I tried these suggestions, but they had no effect on the issue. Sounds like this issue will be hard or impossible to solve in he core, if I understand correctly, right?

tritos-design avatar Mar 01 '22 09:03 tritos-design

The @getkirby/kirby-staff should decide how to approach this opcache-related issue.

afbora avatar Mar 02 '22 20:03 afbora

I wonder why this is related to OPcache. It only caches PHP files, but not text files or YAML blueprints...

lukasbestle avatar Mar 13 '22 16:03 lukasbestle

I think this still needs needs: replication and less discussion. I agree with @lukasbestle that I'm not yet sure it's due to opcache.

distantnative avatar Mar 21 '22 11:03 distantnative

@tritos-design The Mittwald docs also say that Performance Plus uses PHP FPM (FastCGI Process Manager). This alone shouldn't cause this issue either, but it suggests to me that the whole server setup might be different with the option enabled. If they say that they use FPM for Performance Plus, what do they use in the non-Performance Plus mode? This makes it quite hard to find a clear difference and source of the issue.

lukasbestle avatar Mar 31 '22 19:03 lukasbestle

@lukasbestle I agree that this is somehow a strange issue, but at least for @texnixe it seems to be triggered by just turning opcache on/off. I'm afraid, I cannot contribute much more at this point. Would a phpinfo() for the cases with/without "Performance Plus" be of any help?

tritos-design avatar Mar 31 '22 20:03 tritos-design

To be honest I'm not an expert in the inner workings of the writer field. I suspect something is going on about the localStorage, but I can't tell for sure. @distantnative @bastianallgeier?

lukasbestle avatar Mar 31 '22 20:03 lukasbestle

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

github-actions[bot] avatar Sep 28 '22 00:09 github-actions[bot]