Hi everybody!
There are several global variables which are there to support CMSimple_XH's core back-end (aka. administration) dispatch, namely: $phpinfo, $settings, $sysinfo, $validate, $xh_backups, $xh_change_password, $xh_do_validate, $xh_pagedata and $xh_plugins. These are initialized from a given GET or POST parameter, but in the following only used to set $f to an appropriate value. Of course, the detour of using global variables for this purpose is nonsentical; the respective GET or POST parameters can be checked in ::setBackendF() directly.
Simply changing the respective code (and so removing these globals) might break extensions, though, particularly since some of these globals are not documented at all, and the others are inconspicuously documented as private. Therefore I suggest to add prominent deprecation warnings for XH 1.8.0 and to finally remove them in 2.0.0 without any replacement.
Note that I'm planning to update our developer documentation from master from time to time[1], so deciding on this rather sooner than later would give extension writers more time to become aware of the scheduled change, and to act accordingly.
Thoughts?
Remove globals for core back-end dispatch
Remove globals for core back-end dispatch
Christoph M. Becker – Plugins for CMSimple_XH
Re: Remove globals for core back-end dispatch
Just go for it. A BC break might be easily recognized & fixed.
Re: Remove globals for core back-end dispatch
Well, guess we have to postpone respective changes until https://github.com/cmsimple-xh/cmsimple-xh/issues/340 would be solved.manu wrote:Just go for it. A BC break might be easily recognized & fixed.
Christoph M. Becker – Plugins for CMSimple_XH
Re: Remove globals for core back-end dispatch
Again the same question like in pwf_xh post:cmb wrote:... respective GET or POST parameters can be checked in ::setBackendF() directly... Therefore I suggest to add prominent deprecation warnings for XH 1.8.0 and to finally remove them in 2.0.0 without any replacement...
Can'r a checking wether globals are defined in a plugin solve the transition phase at least?
I mean something like:
Code: Select all
if(...plugin is called...){
if (...globals are defined in plugin...){
echo "deprecation-warning" ignore globals from plugin
}else{
use (...globals from core...)}
}
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.
Re: Remove globals for core back-end dispatch
There is no way to detect any access to a global variable during runtime[1]. That is the main reason why global variables are a bad idea for an API. Even a static analysis is not really possible.Tata wrote:Can'r a checking wether globals are defined in a plugin solve the transition phase at least?
There appears to be a misunderstanding. This is not about global variables which are defined by plugins, but rather about some global variables which are defined by the core, and may be used by plugins.Tata wrote:I mean something like:
[…]
[1] Actually, there are some exceptions, but these do not apply in this case.
Christoph M. Becker – Plugins for CMSimple_XH