Bug: Page template dropdown disappeared after upgrading to Acorn v3.x
Twansparant opened this issue · 8 comments
Terms
- I have read the guidelines for Contributing to Roots Projects
- This request is not a duplicate of an existing issue
- I have read the docs and followed them (if applicable)
- I have seached the Roots Discourse for answers and followed them (if applicable)
- This is not a personal support request that should be posted on the Roots Discourse community
Description
What's wrong?
After upgrading Acorn to the 3.0.0-alpha.3
version (but it also happens on alpha.1 & alpha.2), the Template dropdown in the Page attributes metabox has completely disappeared somehow.
When viewing my template sin the frontend I get a Target class [sage.view] does not exist.
error?
What have you tried?
- I tried installing all 3.0.0-alpha versions and running all of these commands afterwards:
wp acorn acorn:init
wp acorn package:discover
wp acorn vendor:publish
wp acorn config:clear
wp acorn optimize:clear
wp acorn optimize
wp acorn view:cache
All without errors and I can also see my log1x/acf-composer
fields & log1x/poet
types in the backend.
- I disabled all of my plugins.
- I disabled all of my wordpress actions/filters in my theme.
What insights have you gained?
I think Acorn possible is not recognising my template files inside the resources/views
folder even though get_theme_file_path('/resources/views')
is returning the correct path?
Possible solutions
Downgrading to Acorn 2.1, but then I'm bumping into this bug again.
Temporary workarounds
Switch to a default Wordpress theme
Steps To Reproduce
- Install roots/acorn 3.0.0-alpha.3 with composer in your Bedrock folder:
composer require roots/acorn:3.0.0-alpha.3
- Call the bootloader in your functions.php:
\Roots\bootloader()->boot();
- Go to an edit page in your Wordpress backend and have a look at the Page attributes box in the right sidebar.
- Switch to a default Wordpress theme and repeat step 3.
Expected Behavior
The Page attributes box in the right sidebar should have a Template dropdown.
Actual Behavior
The Page attributes box in the right sidebar does not have a Template dropdown anymore.
Relevant Log Output
No php errors whatsoever
Versions
Acorn 3.0.0-alpha.3 PHP 8.0.22 Composer version 2.4.1
I noticed that you updated functions.php
to have \Roots\bootloader()->boot()
, but did you also make sure your ThemeServiceProvider
extends SageServiceProvider
?
Also, did you check your logs? There might not be any by default unless you've run wp acorn vendor:publish --tag=acorn:init
and updated config/logging.php
. But the logs could provide a clue as to what's going on, such as if a provider is failing to register or boot.
but did you also make sure your
ThemeServiceProvider
extendsSageServiceProvider
Yup checked it, and it does extend the SageServiceProvider
.
I updated the published config/logging.php
and set the Log Channel to syslog
:
'default' => env('LOG_CHANNEL', 'syslog')
And am getting this error in the logs:
Aug 26 02:53:30 cms acorn[1030]: [2022-08-26 07:53:30] development.ERROR: Target class [sage.view] does not exist. {"userId":1,"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [sage.view] does not exist. at /srv/www/mydmain.com/current/vendor/illuminate/container/Container.php:877)
Aug 26 02:53:30 cms acorn[1030]: [stacktrace]
Aug 26 02:53:30 cms acorn[1030]: #0 /srv/www/mydmain.com/current/vendor/illuminate/container/Container.php(756): Illuminate\\Container\\Container->build('sage.view')
Aug 26 02:53:30 cms acorn[1030]: #1 /srv/www/mydmain.com/current/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(855): Illuminate\\Container\\Container->resolve('sage.view', Array, true)
Aug 26 02:53:30 cms acorn[1030]: #2 /srv/www/mydmain.com/current/vendor/illuminate/container/Container.php(692): Illuminate\\Foundation\\Application->resolve('sage.view', Array)
Aug 26 02:53:30 cms acorn[1030]: #3 /srv/www/mydmain.com/current/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(840): Illuminate\\Container\\Container->make('sage.view', Array)
Aug 26 02:53:30 cms acorn[1030]: #4 /srv/www/mydmain.com/current/vendor/roots/acorn/src/Illuminate/Foundation/helpers.php(119): Illuminate\\Foundation\\Application->make('sage.view', Array)
Aug 26 02:53:30 cms acorn[1030]: #5 /srv/www/mydmain.com/current/web/app/themes/sage/index.php(12): app('sage.view')
Aug 26 02:53:30 cms acorn[1030]: #6 /srv/www/mydmain.com/current/web/wp/wp-includes/template-loader.php(106): include('/srv/www/cms.cl...')
Aug 26 02:53:30 cms acorn[1030]: #7 /srv/www/mydmain.com/current/web/wp/wp-blog-header.php(19): require_once('/srv/www/cms.cl...')
Aug 26 02:53:30 cms acorn[1030]: #8 /srv/www/mydmain.com/current/web/index.php(6): require('/srv/www/cms.cl...')
Aug 26 02:53:30 cms acorn[1030]: #9 {main}
Aug 26 02:53:30 cms acorn[1030]:
Aug 26 02:53:30 cms acorn[1030]: [previous exception] [object] (ReflectionException(code: -1): Class \"sage.view\" does not exist at /srv/www/mydmain.com/current/vendor/illuminate/container/Container.php:875)
Aug 26 02:53:30 cms acorn[1030]: [stacktrace]
Aug 26 02:53:30 cms acorn[1030]: #0 /srv/www/mydmain.com/current/vendor/illuminate/container/Container.php(875): ReflectionClass->__construct('sage.view')
Aug 26 02:53:30 cms acorn[1030]: #1 /srv/www/mydmain.com/current/vendor/illuminate/container/Container.php(756): Illuminate\\Container\\Container->build('sage.view')
Aug 26 02:53:30 cms acorn[1030]: #2 /srv/www/mydmain.com/current/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(855): Illuminate\\Container\\Container->resolve('sage.view', Array, true)
Aug 26 02:53:30 cms acorn[1030]: #3 /srv/www/mydmain.com/current/vendor/illuminate/container/Container.php(692): Illuminate\\Foundation\\Application->resolve('sage.view', Array)
Aug 26 02:53:30 cms acorn[1030]: #4 /srv/www/mydmain.com/current/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(840): Illuminate\\Container\\Container->make('sage.view', Array)
Aug 26 02:53:30 cms acorn[1030]: #5 /srv/www/mydmain.com/current/vendor/roots/acorn/src/Illuminate/Foundation/helpers.php(119): Illuminate\\Foundation\\Application->make('sage.view', Array)
Aug 26 02:53:30 cms acorn[1030]: #6 /srv/www/mydmain.com/current/web/app/themes/sage/index.php(12): app('sage.view')
Aug 26 02:53:30 cms acorn[1030]: #7 /srv/www/mydmain.com/current/web/wp/wp-includes/template-loader.php(106): include('/srv/www/cms.cl...')
Aug 26 02:53:30 cms acorn[1030]: #8 /srv/www/mydmain.com/current/web/wp/wp-blog-header.php(19): require_once('/srv/www/cms.cl...')
Aug 26 02:53:30 cms acorn[1030]: #9 /srv/www/mydmain.com/current/web/index.php(6): require('/srv/www/cms.cl...')
Aug 26 02:53:30 cms acorn[1030]: #10 {main}
Aug 26 02:53:30 cms acorn[1030]: "}
Aug 26 02:53:30 cms acorn[1030]:
I get this after following these steps:
- Update Acorn to 3.0.0-alpha.3 and run
rm rf vendor && rm composer.lock && composer install
rm -rf /site/web/app/cache
- Adjust my theme functions.php and add
\Roots\bootloader()->boot()
and removeadd_theme_support('sage')
like stated in the docs. - Run these Acorn commands:
wp @development acorn vendor:publish --tag=acorn:init
wp @development acorn acorn:init
wp @development acorn config:clear
wp @development acorn optimize:clear
Am I missing a step?
Thanks!
It's looking to me like the ThemeServiceProvider isn't getting loaded.
Does app/themes/sage/composer.json list ThemeServiceProvider as a provider?
For reference, here is how we do it in the current stable version of Sage: https://github.com/roots/sage/blob/main/composer.json#L63-L69
Does app/themes/sage/composer.json list ThemeServiceProvider as a provider?
Yes it does!
Would you mind submitting a topic on Roots Discourse and possibly provide a repo for someone to try to reproduce? I'm unable to confirm this bug with Acorn v3
Did you notice it moved from page attributes to it’s own separate template panel? i was unable to see the panel in the ui until i finally tracked it down in the codebase 😆
Did you notice it moved from page attributes to it’s own separate template panel?
Yeah I did notice that, but only if you have enabled Gutenberg, which I haven't for this theme.
I had the same Target class [sage.view] does not exist.
error. I forgot to call the parent's register()
/boot()
methods.
Here is my working ThemeServiceProvider
:
<?php
namespace App\Providers;
use Roots\Acorn\Sage\SageServiceProvider;
class ThemeServiceProvider extends SageServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
parent::register();
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
}
}