Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Using asset() helper causes failures when running WP-CLI commands #263

Closed
retlehs opened this issue Feb 1, 2023 · 6 comments · Fixed by #265
Closed

Bug: Using asset() helper causes failures when running WP-CLI commands #263

retlehs opened this issue Feb 1, 2023 · 6 comments · Fixed by #265
Labels
bug Something isn't working

Comments

@retlehs
Copy link
Member

retlehs commented Feb 1, 2023

Description

The asset function works until a wp command is ran

Steps To Reproduce

  1. Use the asset() helper in a PHP file:
add_action('init', function () {
    $test = asset('editor.css');
});
  1. Run wp

Actual Behavior

Fatal error: Uncaught ReflectionException: Class "assets.manifest" does not exist in /srv/www/example.com/current/web/app/themes/sage/vendor/illuminate/container/Container.php:893

Versions

v3.0.0

@retlehs retlehs added the bug Something isn't working label Feb 1, 2023
@QWp6t
Copy link
Member

QWp6t commented Feb 1, 2023

Hey @retlehs 👋

Thanks for reporting this! 🙏

I'll look into it this weekend and see about getting a fix implemented!

@retlehs
Copy link
Member Author

retlehs commented Feb 1, 2023

Note: Others may also be getting this same error message in a situation that is unrelated to this bug — this is the result of having an outdated config/app.php file in your setup. If you're running into this error and aren't using the asset() helper, see the Upgrade Guide for info

@retlehs retlehs changed the title Bug: asset helper breaks on optimize Bug: Using asset() helper causes fatal error after running wp acorn optimize Feb 1, 2023
@retlehs retlehs changed the title Bug: Using asset() helper causes fatal error after running wp acorn optimize Bug: Using asset() helper can cause fatal error after running wp acorn optimize Feb 1, 2023
@retlehs
Copy link
Member Author

retlehs commented Feb 1, 2023

FWIW, the hook used definitely matters, too:

  • ✅ Using asset() in wp_head
  • ❌ Using asset() in init
  • ❌ Using asset() in after_setup_theme

@Twansparant
Copy link

Twansparant commented Feb 2, 2023

Don't know if it's related, but running wp acorn optimize without the asset() function call, also results in an error:

In ConfigCacheCommand.php line 84:
                                                  
  Your configuration files are not serializable.  
                                                  

In config.php line 336:
                                                   
  Call to undefined method Closure::__set_state()  
                                                   

This also seems to slow down the wp admin significantly.

@QWp6t
Copy link
Member

QWp6t commented Feb 2, 2023

@Twansparant

That looks to me like there are some closures getting into your config somewhere, which aren't serializable out of the box and should be avoided in your configs.

It's also possible that we missed a dependency from Laravel 9 that we need to get in there, such as laravel/serializable-closure.

I'll dig into these issues tomorrow.

@retlehs retlehs changed the title Bug: Using asset() helper can cause fatal error after running wp acorn optimize Bug: Using asset() helper causes failures when running WP-CLI commands Feb 3, 2023
@QWp6t QWp6t closed this as completed in #265 Feb 3, 2023
@Twansparant
Copy link

Twansparant commented Feb 6, 2023

That looks to me like there are some closures getting into your config somewhere, which aren't serializable out of the box and should be avoided in your configs.

This error was caused by my log1x/poet config file.
I was using the Extended CPTs Admin Columns Custom Function in a few of my CPT's.

I moved my function to a class like suggested here, and the error is gone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants