Hi,
I use a namespaced class to output wordpress (for cache hooks etc). Using a namespaced class to output wordpress _fails_ if Types is active?
It fails on the included common wp-compatibility.com/installer-plugin (wp-content/plugins/types/embedded/common/installer/loader.php).
Undefined index: bootfile in /var/www/html/wp-content/plugins/types/embedded/common/installer/loader.php on line 47
The following works:
// this works (direct output within a namespace)
namespace Test\Ok {
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
exit;
}
The following fails due to key $wp_installer_instances ~ $instance value "bootfile" not being available. Debug can see it initially being set; though then after it is not available.
// this fails ; conceptually the same as previous; though now called within a namespaced class.. not just a namespace...
namespace Test\Fail {
class Test {
public function test() {
define( 'WP_USE_THEMES', true );
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
exit;
}
}
(new Test)->test();
}
used: (docker container) php 5.6, wp 4.1, types 1.6.4
How to solve this problem? It must be the namespaced class that is breaking the code? though why does it work when only namespaced and not within a namespaced class? Other plugins are fine.
Thanks,
Aubrey
Since it is custom PHP codes problem, Could you describe detail steps to duplicate same problem?
I need duplicate and debug it in my localhost, thanks
Lol really luoy? ok.. I will repeat myself; and try to describe how my types problem is so "custom".
So will now explicitly say it is index.php that is changed. Maybe try it out and actually be more informative. Thanks.
1) rewrite index.php
// this works (direct output within a namespace)
namespace Test\Ok {
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
exit;
}
2) rewrite index.php
// this fails ; conceptually the same as previous; though now called within a namespaced class.. not just a namespace...
namespace Test\Fail {
class Test {
public function test() {
define( 'WP_USE_THEMES', true );
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
exit;
}
}
(new Test)->test();
}
omg I repeated myself. I just posted the same as before.
Oh sorry Types plugin breaks the above.. is that what is missing?
Thanks for the details, I have been able to duplicate same problem in my localhost, and put it into our to-do list, our developers will take care of it.
Cool! thanks Luoy for checking this out! I appreciate it. Will look forward to any updates.
It is not a major issue:
I have a redis page wrapper that contains itself within a namespace (to reduce contamination). Using the wrapper within a wp instance using Types fails.
Current/quickfix is that the redis page wrapper functionality is global (due to breaking Types).. so can still possibly infect/contaminate used theme/plugin functions/classes... had to make global class using internal functions.. still works (though the namespaced functions are now class methods which is ugly)..
x, Aubrey
I forward your question to our developers, will update this thread if there is any news.
Sorry for the delay answer, I just checked it in our to-do list, there isn't any news for it. and If you need more assistance for it, please open another thread for it, thanks