Site editor duplicates templates/template-parts on editing them #43

Closed
opened 2024-05-11 16:09:30 +00:00 by aadil · 5 comments
Owner

Copied from https://github.com/WordPress/gutenberg/issues/50816. I'm posting this here because I've only experienced this bug on wordpress sites running on co-op cloud (specifically, aadils.computer and autonomic.zone). When I imported the same site into Local, the issue disappeared. It seems to happen independent of what version of WordPress/Gutenberg I'm running.

Description

I've been experiencing this bug for a long time (I think since 6.0?) where editing any template or template part in the site editor causes WordPress to create a new template/template-part of the same name instead of updating the existing one.

image

This new template (or template-part), containing all modifications, is created under the current WordPress user, and the default one which is actually being used by theme is cleared of all customizations and is what shows up on the front-end.

(See screen recording for context)

Step-by-step reproduction instructions

  1. Go to site editor
  2. Open a template or template part
  3. Make any modification (e.g. add a new block or customize an existing block in the template)
  4. Save your changes
  5. Refresh the front-end - the template or template-part you were editing should be restored to its default state instead of being updated with your edits.

Screenshots, screen recording, code snippet

Video of me breaking the site with a simple edit to the home template:

gutenberg-template-editing-bug.webm

Video of me restoring the home template:

Kooha-2023-05-20-19-04-56.webm

Copied from https://github.com/WordPress/gutenberg/issues/50816. I'm posting this here because I've only experienced this bug on wordpress sites running on co-op cloud (specifically, aadils.computer and autonomic.zone). When I imported the same site into [Local](https://localwp.com), the issue disappeared. It seems to happen independent of what version of WordPress/Gutenberg I'm running. ### Description I've been experiencing this bug for a long time (I think since 6.0?) where editing any template or template part in the site editor causes WordPress to create a new template/template-part of the same name instead of updating the existing one. ![image](https://github.com/WordPress/gutenberg/assets/31581044/cc1829e7-cf11-4fea-80b0-7295bfdf3c28) This new template (or template-part), containing all modifications, is created under the current WordPress user, and the default one which is actually being used by theme is cleared of all customizations and is what shows up on the front-end. (See screen recording for context) ### Step-by-step reproduction instructions 1. Go to site editor 2. Open a template or template part 3. Make any modification (e.g. add a new block or customize an existing block in the template) 4. Save your changes 5. Refresh the front-end - the template or template-part you were editing should be restored to its default state instead of being updated with your edits. ### Screenshots, screen recording, code snippet Video of me breaking the site with a simple edit to the home template: [gutenberg-template-editing-bug.webm](https://github.com/WordPress/gutenberg/assets/31581044/5347c51b-b6a0-4db3-b84a-8a50c8d7e554) Video of me restoring the home template: [Kooha-2023-05-20-19-04-56.webm](https://github.com/WordPress/gutenberg/assets/31581044/0ac983aa-4e78-4da8-a6d2-7a8cb0a4f2cc)
Owner

Anyone else seeing this?

Here is the upstream Gutenberg bug @aadil posted https://github.com/WordPress/gutenberg/issues/50816 which they closed due to not being able to replicate.

Anyone else seeing this? Here is the upstream Gutenberg bug @aadil posted https://github.com/WordPress/gutenberg/issues/50816 which they closed due to not being able to replicate.
Owner

I found the issues

root@f03862c99ae1:/var/www/html/wp-content/themes# ls -la
total 20
drwxr-xr-x  4 www-data www-data 4096 Jun  2 13:23 .
drwxr-xr-x 10 www-data www-data 4096 Jun  2 13:23 ..
drwxr-xr-x  8 root     root     4096 Jul 30  2025 autonomic-block-theme
-rw-r--r--  1 www-data www-data   28 Jun  5  2014 index.php
drwxr-xr-x  3 www-data www-data 4096 Jan 27  2023 twentytwentyone

Look at the permissions on our theme @aadil

I found the issues ``` root@f03862c99ae1:/var/www/html/wp-content/themes# ls -la total 20 drwxr-xr-x 4 www-data www-data 4096 Jun 2 13:23 . drwxr-xr-x 10 www-data www-data 4096 Jun 2 13:23 .. drwxr-xr-x 8 root root 4096 Jul 30 2025 autonomic-block-theme -rw-r--r-- 1 www-data www-data 28 Jun 5 2014 index.php drwxr-xr-x 3 www-data www-data 4096 Jan 27 2023 twentytwentyone ``` Look at the permissions on our theme @aadil
Owner

Ok I tested it and it fixed it with a chown:

chown -R www-data:www-data /var/www/html/wp-content/themes/autonomic-block-theme/

Doesnt' seem to be any issue with our theme repo: https://git.autonomic.zone/autonomic-cooperative/autonomic-block-theme

Could possibly just be something we did. Maybe even keyboard to chair? Unless anyone can recreate, suggest we close @aadil

Ok I tested it and it fixed it with a chown: ``` chown -R www-data:www-data /var/www/html/wp-content/themes/autonomic-block-theme/ ``` Doesnt' seem to be any issue with our theme repo: https://git.autonomic.zone/autonomic-cooperative/autonomic-block-theme Could possibly just be something we did. Maybe even keyboard to chair? Unless anyone can recreate, suggest we close @aadil
Owner

hmm I think we have to do another patch to https://git.coopcloud.tech/coop-cloud/wordpress/src/branch/main/entrypoint.sh.tmpl

And we chown -R www-data:www-data /var/www/html/wp-content/uploads/ to chown -R www-data:www-data /var/www/html/wp-content/ to cover all the files that need to be patched.

hmm I think we have to do another patch to https://git.coopcloud.tech/coop-cloud/wordpress/src/branch/main/entrypoint.sh.tmpl And we `chown -R www-data:www-data /var/www/html/wp-content/uploads/` to `chown -R www-data:www-data /var/www/html/wp-content/` to cover all the files that need to be patched.
Owner

PR: #60

PR: https://git.coopcloud.tech/coop-cloud/wordpress/pulls/60
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coop-cloud/wordpress#43
No description provided.