soflyy / breakdance-bugs

Bug reports from Breakdance users.
38 stars 5 forks source link

2.0.0-beta.2 - Twig auto generated cache directory error after upgrading #1097

Closed mirkoschubert closed 1 week ago

mirkoschubert commented 2 weeks ago

If you upgrade your Breakdance plugin from 2.0.0-beta.1 to 2.0.0-beta.2 you may have a fatal error.

Step-by-step for reproduction:

  1. Have a WordPress Installation with Breakdance 2.0.0-beta.1
  2. Upgrade Breakdance to 2.0.0.-beta.2
  3. Get a fatal error immediately

Error message (debug.log):

[17-Jun-2024 08:00:35 UTC] PHP Fatal error:  Uncaught UnexpectedValueException: RecursiveDirectoryIterator::__construct(/tmp/breakdance-cdb0fc5d/twig-auto-generated-cache): Failed to open directory: Permission denied in /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-content/plugins/breakdance/plugin/filesystem/functions.php:110
Stack trace:
#0 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-content/plugins/breakdance/plugin/filesystem/functions.php(110): RecursiveDirectoryIterator->__construct('/tmp/breakdance...', 4096)
#1 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-content/plugins/breakdance/plugin/setup/activate-and-install.php(99): Breakdance\Filesystem\clear_bucket_contents('BREAKDANCE_FS_B...')
#2 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-includes/class-wp-hook.php(324): Breakdance\Setup\handleVersionChange('')
#3 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#4 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#5 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-content/plugins/breakdance/plugin.php(49): do_action('breakdance_load...')
#6 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-includes/class-wp-hook.php(324): {closure}('')
#7 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#8 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#9 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-settings.php(550): do_action('plugins_loaded')
#10 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-config.php(103): require_once('/www/htdocs/w01...')
#11 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-load.php(50): require_once('/www/htdocs/w01...')
#12 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-blog-header.php(13): require_once('/www/htdocs/w01...')
#13 /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/index.php(17): require('/www/htdocs/w01...')
#14 {main}
  thrown in /www/htdocs/w0185ecb/staging-iea-breakdance.klicklounge.de/wp-content/plugins/breakdance/plugin/filesystem/functions.php on line 110

Possible explanation

It seems that after the upgrade the Twig auto generated cache bucket will be cleared. The RecursiveDirectoryIterator tries to read those directories, but on some shared Webhosters the /tmp/ directory might be restricted. I tried to create the directories myself and checked the permissions which where at 777, but got still the same fatal error.

I figured out that et_bucket_abs_path() uses get_temp_dir(), so it defaults to /tmp/ but can be overwritten with the WP_TEMP_DIR constant.

Preliminary solution

You can define a temp directory with define('WP_TEMP_DIR', '/path/to/tmp/'); and create those sub directories mentioned in the error message. Make sure that the directories have 755 permissions.

Versions

breakdancemoderator commented 1 week ago

Thank you for submitting your report and for helping us improve Breakdance. We have reviewed your submission, but currently, we're unable to reproduce the issue based on the information provided.

To ensure that your issue is addressed as efficiently as possible, we kindly request that you contact our dedicated support team by emailing support@breakdance.com. Our team is well-equipped to dive deeper into specific scenarios and provide personalized assistance.