roots / acorn

Laravel components for WordPress plugins and themes
https://roots.io/acorn/
MIT License
819 stars 94 forks source link

WordPress not working when upgrading Acorn to v^5.0.0-beta.0 #394

Closed bedirhandev closed 2 months ago

bedirhandev commented 2 months ago

Version

^5.0.0-beta.0

What did you expect to happen?

I expect that Wordpress would load normally without errors.

What actually happens?

An error is displayed: There has been a critical error on this website.

Steps to reproduce

Upgrade Acorn on an existing project to v^5.0.0-beta.0 and it the website returns an error.

System info

Windows 10 Pro, 22H2

Log output

[24-Aug-2024 12:18:11 UTC] PHP Fatal error:  Uncaught Exception: The C:\xampp\htdocs\wordpress\wp-content\plugins\test/src\C:\xampp\htdocs\wordpress\wp-content\plugins\test/src\storage/framework\cache directory must be present and writable. in C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Illuminate\Foundation\PackageManifest.php:178
Stack trace:
#0 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Roots\Acorn\PackageManifest.php(91): Illuminate\Foundation\PackageManifest->write(Array)
#1 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Illuminate\Foundation\PackageManifest.php(107): Roots\Acorn\PackageManifest->build()
#2 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Illuminate\Foundation\PackageManifest.php(90): Illuminate\Foundation\PackageManifest->getManifest()
#3 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Illuminate\Foundation\PackageManifest.php(79): Illuminate\Foundation\PackageManifest->config('aliases')
#4 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Roots\Acorn\Bootstrap\RegisterFacades.php(25): Illuminate\Foundation\PackageManifest->aliases()
#5 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Illuminate\Foundation\Application.php(316): Roots\Acorn\Bootstrap\RegisterFacades->bootstrap(Object(Roots\Acorn\Application))
#6 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Illuminate\Foundation\Http\Kernel.php(186): Illuminate\Foundation\Application->bootstrapWith(Array)
#7 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Roots\Acorn\Application\Concerns\Bootable.php(114): Illuminate\Foundation\Http\Kernel->bootstrap(Object(Illuminate\Http\Request))
#8 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Roots\Acorn\Application\Concerns\Bootable.php(40): Roots\Acorn\Application->bootHttp()
#9 C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Roots\Acorn\Configuration\ApplicationBuilder.php(118): Roots\Acorn\Application->bootAcorn()
#10 C:\xampp\htdocs\wordpress\wp-content\plugins\test\wpcli-demo-plugin.php(73): Roots\Acorn\Configuration\ApplicationBuilder->boot()
#11 C:\xampp\htdocs\wordpress\wp-includes\class-wp-hook.php(324): {closure}('')
#12 C:\xampp\htdocs\wordpress\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#13 C:\xampp\htdocs\wordpress\wp-includes\plugin.php(517): WP_Hook->do_action(Array)
#14 C:\xampp\htdocs\wordpress\wp-settings.php(555): do_action('plugins_loaded')
#15 C:\xampp\htdocs\wordpress\wp-config.php(101): require_once('C:\\xampp\\htdocs...')
#16 C:\xampp\htdocs\wordpress\wp-load.php(50): require_once('C:\\xampp\\htdocs...')
#17 C:\xampp\htdocs\wordpress\wp-blog-header.php(13): require_once('C:\\xampp\\htdocs...')
#18 C:\xampp\htdocs\wordpress\index.php(17): require('C:\\xampp\\htdocs...')
#19 {main}
  thrown in C:\xampp\htdocs\wordpress\wp-content\plugins\test\vendor\roots\acorn\src\Illuminate\Foundation\PackageManifest.php on line 178

Please confirm this isn't a support request.

Yes

bedirhandev commented 2 months ago

I investigated it and noticed in the file: vendor\roots\acorn\src\Roots\Acorn\Application.php on line 139 there is something strange happening in my opinion.

$this->{$supportedPaths[$pathType]} = Str::startsWith($path, $this->absoluteCachePathPrefixes)
                ? $path
                : $this->basePath($path);

It seems that it is prepending the basePath with the given path in the function basePath:

public function basePath($path = '')
{
    return $this->joinPaths($this->basePath, $path);
}

when the path is e.g. C:\xampp\htdocs\wordpress\wp-content\plugins\laravel-wordpress-plugin/src\storage/framework\cache it prepends it with: C:\xampp\htdocs\wordpress\wp-content\plugins\laravel-wordpress-plugin/src\ which becomes: C:\xampp\htdocs\wordpress\wp-content\plugins\laravel-wordpress-plugin/src\C:\xampp\htdocs\wordpress\wp-content\plugins\laravel-wordpress-plugin/src\storage/framework\cache and that path does not exists and fails.

Log1x commented 2 months ago

This is not a bug with Acorn. Please refer to https://github.com/roots/acorn/pull/370 or wait until an official release which will include an upgrade guide.

bedirhandev commented 2 months ago

Update:

Even then it does not work. Can you please test this.


@Log1x Thank you for your suggestion, but it is not working even if I define the paths it is not assigning it as I debug.

E.g.

add_action('plugins_loaded', function () {
  Application::configure()
  ->withProviders([
    WordpressPluginTemplate\App\Providers\PluginServiceProvider::class,
  ])
  ->withPaths('customAppPath', 'customConfigPath', 'etc')
  ->withRouting(
     web: __DIR__.'\src\routes\web.php',
  )
  ->boot();
});
Log1x commented 2 months ago

You need to pass an array of paths as seen here or a base path to Application::configure() as seen here.

Please use Discourse for support.