Skip to content

Improve SCSS cache directory creation and error handling#272

Draft
shadoath wants to merge 1 commit intomasterfrom
claude/fix-scss-cache-permissions-mwid3
Draft

Improve SCSS cache directory creation and error handling#272
shadoath wants to merge 1 commit intomasterfrom
claude/fix-scss-cache-permissions-mwid3

Conversation

@shadoath
Copy link
Collaborator

Summary

This PR improves the reliability and user experience of the SCSS compiler's cache directory handling by using WordPress's built-in directory creation function and providing more informative error messages.

Key Changes

  • Replace mkdir() with wp_mkdir_p(): Changed from the basic PHP mkdir() function to WordPress's wp_mkdir_p() function, which creates directories recursively and respects WordPress conventions
  • Enhanced error messaging: Updated error messages to distinguish between two failure scenarios:
    • When the cache directory doesn't exist and cannot be created
    • When the cache directory exists but lacks write permissions
    • This provides clearer guidance to users on how to resolve the issue

Implementation Details

  • The wp_mkdir_p() function is more robust than mkdir() as it creates parent directories if needed and handles edge cases better
  • The error message now conditionally displays based on whether the cache directory exists, helping users understand the root cause of the permission error
  • The cache directory path is included in the error message to help users locate and manually create/fix the directory if needed

https://claude.ai/code/session_01KsZF2sudPbLYyzoWNSjBAG

…755)

mkdir() was called with 0644 (a file permission), which lacks the
execute bit required for directories. This made the cache directory
non-traversable immediately after creation, causing is_writable() to
fail and producing the misleading "permission denied" error.

Replaced with wp_mkdir_p() which creates directories recursively with
correct permissions (0755). Also improved error message to distinguish
between directory creation failure and actual permission issues.

https://claude.ai/code/session_01KsZF2sudPbLYyzoWNSjBAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants