Skip Navigation

[Closed] Running within namespaced class; Types fails..

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by Luo Yang 9 years ago.

Assisted by: Luo Yang.

Author
Posts
#279475
types-fail .png

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

#279683

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

#280060

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?

#280082

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.

#280416

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

#280818

I forward your question to our developers, will update this thread if there is any news.

#290156

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

The topic ‘[Closed] Running within namespaced class; Types fails..’ is closed to new replies.