WordPress / WordPress/create-block-theme

file_put_contents function does not report write/permissions error properly

Open
#770 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
417
Forks
66
PR merge metrics
No merged PRs in 30d

Description

When saving changes to a theme to which it does not have write permissions, the file_put_contents function will output an error in debug.log.
But the plugin will still say it succeeded in the editor. This leads to the destruction of user changes, without them being saved to the files

The error:

[24-Apr-2025 17:46:58 UTC] PHP Warning:  file_put_contents(/var/www/html/wp-content/themes/qip-wp-themes/merryclaude2025/theme.json): Failed to open stream: Permission denied in /var/www/html/wp-content/plugins/create-block-theme/includes/create-theme/theme-json.php on line 6

After fixing the permissions, the plugin saved perfectly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with includes/create-theme/theme-json.php, where the reported file_put_contents warning occurs, then trace the editor save flow that reports success. Reproduce with a theme file lacking write permissions and verify that the permission failure is surfaced instead of claiming the changes were saved.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.