themehybrid / hybrid-core

Official repository for the Hybrid Core WordPress development framework.
GNU General Public License v2.0
689 stars 144 forks source link

5.0: some `bootstrap-functions.php` payload may need to be migrated to specific class boot functions #163

Open lkraav opened 5 years ago

lkraav commented 5 years ago

https://themehybrid.slack.com/archives/C8T1S6HDG/p1542551454417900

When I extend Application class and skip registering View provider because I want to replace it with my own, including all these functions depending on View provider unconditionally will cause fatal PHP errors.

https://github.com/justintadlock/hybrid-core/blob/master/src/bootstrap-functions.php is the problematic spot.

[18-Nov-2018 14:25:43 UTC] PHP Fatal error:  Uncaught Error: Call to a member function display() on boolean in /home/warmpress/wp-content/themes/hybrid-core-5.0/src/View/functions-view.php:51
Stack trace:
#0 /home/warmpress/wp-content/themes/cxl-2019/resources/views/index.php(4): Hybrid\View\display('header', Array)

Not all of these functions fit into a service provider. Many are just free-floating functions. For those that require a service like the View-related functions, it might make sense to migrate.

justintadlock commented 5 years ago

Some additional notes:

It would be good to not load functions that aren't actually going to be used. If the service provider for the view system, for example, was not booted, there'd be little point in including the related functions.

What I'd need to do here is to determine which functions files we can do this with. And, I need to make sure there's no back-compat issues. I don't think there should be any because all this code should be loaded before theme authors are actually attempting to use any of the functions. Basically, this should be a load-order check.

Another consideration might be if there are any components that have a dependency from other components. Most are self contained.