Skip to content

4.x => 5.x merge - #930

Merged
LordSimal merged 10 commits into
5.xfrom
5.x-merge
Apr 29, 2023
Merged

4.x => 5.x merge#930
LordSimal merged 10 commits into
5.xfrom
5.x-merge

Conversation

@LordSimal

Copy link
Copy Markdown
Member

had to add require_once CAKE . 'functions.php'; to make env() available.
Or should this be handled differently?

@LordSimal LordSimal added this to the 5.x milestone Apr 25, 2023
@garas

garas commented Apr 26, 2023

Copy link
Copy Markdown
Member

had to add require_once CAKE . 'functions.php'; to make env() available. Or should this be handled differently?

You should use namespaced env() instead

@ADmad

ADmad commented Apr 26, 2023

Copy link
Copy Markdown
Member

had to add require_once CAKE . 'functions.php'; to make env() available.

As @garas said you need to use Cake\Core\env(). So add use function Cake\Core\env at the top of the required file.

@LordSimal

LordSimal commented Apr 26, 2023

Copy link
Copy Markdown
Member Author

This would also mean I'd have to add the namespaced function for h() for all the template files which is not really what we want I guess (there are 62 usages of h() in 19 template files) - or am I wrong that we do want to go this way?

Especially since we made the global functions opt-in I'd still like to keep it the way it is right now since we only load those global functions for testing, not when the plugin is in use by an app.

@ADmad

ADmad commented Apr 26, 2023

Copy link
Copy Markdown
Member

Hmm.. Right, having to add use statement to the templates would be annoying.

@LordSimal

Copy link
Copy Markdown
Member Author

How about we automatically load the global functions in the rendering phase if they are not already present?
With that its not that hard of a BC but people can still overwrite/adjust them.

@ADmad

ADmad commented Apr 26, 2023

Copy link
Copy Markdown
Member

For the app the global functions are already loaded by default https://github.com/cakephp/app/blob/5.x/config/bootstrap.php#L52

@LordSimal

Copy link
Copy Markdown
Member Author

Yes, but what is the recommended way for plugin devs who use the global functions and tests which use them?

@ADmad

ADmad commented Apr 27, 2023

Copy link
Copy Markdown
Member

Plugins should ideally use the namespaced functions. But when its not convenient to do so like for templates here, we could include just the Core/functions_global.php file.

@LordSimal

Copy link
Copy Markdown
Member Author

adjusted it now to use the specific global_functions files which are actually used.

@LordSimal
LordSimal merged commit 8953245 into 5.x Apr 29, 2023
@LordSimal
LordSimal deleted the 5.x-merge branch April 29, 2023 09:05
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

Successfully merging this pull request may close these issues.

4 participants