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

Call to undefined method Roots\Acorn\Bootloader::getApplication() #1

Closed
braco opened this issue Mar 4, 2023 · 17 comments
Closed

Call to undefined method Roots\Acorn\Bootloader::getApplication() #1

braco opened this issue Mar 4, 2023 · 17 comments

Comments

@braco
Copy link

braco commented Mar 4, 2023

Hey, just tried your theme out, it errors for me on this line:

https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-hook.php#L308

and

/app/wordpress/vendor/roots/acorn/src/Roots/helpers.php:57

\Roots\add_actions(['after_setup_theme', 'rest_api_init'], function () use ($bootloader) {
 $app = $bootloader->getApplication();
  if ($app->hasBeenBootstrapped()) {            return;        }
@strarsis
Copy link
Owner

strarsis commented Mar 4, 2023

@braco: For reproducing the error you submitted, I just cloned this theme repository without any changes and put into a WordPress/Bedrock development environment, and everything works fine out of the box.

Are you just using this sample theme without any changes?

  1. What PHP version are you using?
    (It should currently work with 7.4; 8.0 and 8.1 (slightly older upstream version that still has PHP 7.4 support)).
  2. Have you used composer update instead of composer install on the theme?
    Although this should not happen (in an ideal world...), this may cause incompatible package versions to be installed,
    especially after the recent new acorn release (and breaking changes to older Sage 10 files).
  3. What WordPress version is used with the theme, the latest one?
  4. Is the Gutenberg plugin used (not necessary, but helps with troubleshooting)?
  5. Was composer install invoked in the theme directory?
  6. What additional plugins are used?
  7. Does it work when you disable all plugins (except the Gutenberg, if used)?

@braco
Copy link
Author

braco commented Mar 13, 2023

Hey @strarsis, thanks for the reply. This is the base theme with no modifications. Notably, the core Sage theme doesn't throw any errors.

  1. PHP 8.1
  2. I don't think so, but what would be the fix for this, or how is it diagnosed?
  3. WP 6.1.1
  4. No
  5. did this again, "Nothing to install, update or remove"
  6. disabled all plugins
  7. no

@strarsis
Copy link
Owner

strarsis commented Mar 13, 2023

@braco: You can check out the original files:
git checkout composer.json; git checkout composer.lock and then composer install.

Is your PHP CLI also version 8.1?

@braco
Copy link
Author

braco commented Mar 13, 2023

I wiped everything and did a checkout again, same problem.

PHP CLI is the same version yes.

Just re-verified that Sage 10.5.1 works, looks like you're a few versions behind?

Any other ideas?

@strarsis
Copy link
Owner

strarsis commented Mar 13, 2023

Just re-verified that Sage 10.5.1 works, looks like you're a few versions behind?

Yes, this version is slightly older, still supporting PHP 7.x.
Hm, I would have to update it and then it should work.

@braco
Copy link
Author

braco commented Mar 13, 2023

Just out of curiosity: I haven't used PHP in a decade, and this is my first Sage project – why does it seem like these Sage extension projects have to copy the entire repo instead of providing a plugin?

@strarsis
Copy link
Owner

@braco: In this case this is not a plugin, but a modified Sage theme. It also requires an acorn package as dependency that was slightly modified, so that it is compatible with Gutenberg Full Site Editing template loading. It also ships with concrete examples for block templates, patterns, parts and so on.

So you could just create a new Sage 10 theme and then apply the FSE-specific modifications on top of it.
I have to do the same for this sample repository, I have to update it to the latest Sage and merge/apply the modifications for FSE.

@braco
Copy link
Author

braco commented Mar 13, 2023

got it, and it's hard to modularly extend Sage (sage plugins?) in a way that's durable between updates? I'm just starting to wade in to the development and surprised by the lack of full examples in the ecosystem.

@strarsis
Copy link
Owner

@braco: When this PR is integrated and merged, the loading of Gutenberg Full Site Editing files should work correctly in upstream (unmodified) Sage 10.
This repository contains some minimal working examples for FSE features, as this can be tricky sometimes.

@strarsis
Copy link
Owner

@braco: I updated the underlying Sage 10 to latest version, also an updated acorn patch is used for proper loading of the FSE templates. It should also work now in your case with PHP 8.1.

@strarsis
Copy link
Owner

strarsis commented Mar 16, 2023

@braco: When you got time to test this, let me know whether your issue still persists.

@r-chrzan
Copy link

Hi! @strarsis Is there a chance to use sage 10 hybrid with FSE? I'm trying to get the effect that FSE templates are overwritten by blade template.

@r-chrzan
Copy link

r-chrzan commented Mar 22, 2023

I think I figured out if we can use instead:
public function filterTemplateHierarchy($files) { return $files + [$this->sageFinder->locate($files)]; }

to this:

public function filterTemplateHierarchy($files) { return array_merge($this->sageFinder->locate($files), $files); }

on acorn FiltersTemplates.php

@strarsis
Copy link
Owner

@r-chrzan: When this preserves the existing FSE-compatibility, I would replace that line in the acorn patch.
Blade-PHP hybrid theme support would be nice of course.

@r-chrzan
Copy link

@strarsis I'm currently setting up an e-commerce + FSE project, so it's a good time to test it out. I'll let you know if all the templates work properly. And if I run into problems, I'll share it here.

@strarsis
Copy link
Owner

@r-chrzan: You may find this example interesting for WooCommerce Gutenberg blocks:
woocommerce/woocommerce-blocks#891 (comment)

@r-chrzan
Copy link

@strarsis thanks! very helpful!

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

No branches or pull requests

3 participants