Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-11-07 10:13:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

Apologies to on-the-ball plugin developers

Sorry to anyone who’s already made their plugins “4.6 ready”. A late-breaking change a few days ago has the possibility to break your hard work.

In summary, you can no longer use the backwards-compatibility hack of underscores as pseudo-namespaced class names. You have to use the full namespace:

Txp::get('\Textpattern\Tag\Registry')
   ->register(array('abc_class', 'method'), 'abc_your_tag');

or

Txp::get('\Textpattern\Tag\Registry')
   ->register('abc_function', 'abc_your_tag');

or you can import the namespace first with use so you don’t have to refer to the full path.

Many apologies.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#2 2015-11-07 11:14:20

etc
Developer
Registered: 2010-11-11
Posts: 3,042
Website

Re: Apologies to on-the-ball plugin developers

Thanks for the warning, Stef, and nothing to apologize for – on the ball comme on the ball. Meanwhile, what will happen with the ancient code – will tags just not be registered?

if(class_exists('Textpattern_Tag_Registry'))
	Txp::get('Textpattern_Tag_Registry')->register('abc_plugin');

etc_[ query | search | pagination | date | tree | cache ]

Offline

#3 2015-11-07 11:25:56

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

Re: Apologies to on-the-ball plugin developers

etc wrote #296475:

what will happen with the ancient code – will tags just not be registered?

If you’ve defended against this with a conditional then yes, your tags will remain unregistered and will trigger the warning. Nothing untoward will happen at the moment, everything will still work when production status is Live. It’s only if you haven’t defended against it that the plugin will stop with an unceremonious error.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2015-11-07 17:37:58

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,048
Website

Re: Apologies to on-the-ball plugin developers

Does this mean that all non supported plugins will be rendered useless or will they just through the error in any mode by live?


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#5 2015-11-07 19:37:22

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,129
Website

Re: Apologies to on-the-ball plugin developers

colak wrote #296477:

Does this mean that all non supported plugins will be rendered useless or will they just through the error in any mode by live?

If I understand this correctly, there is no reason why people can’t just edit a plugin right in the Textpattern interface.

Offline

#6 2015-11-07 20:49:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,524
Website

Re: Apologies to on-the-ball plugin developers

colak wrote #296477:

Does this mean that all non supported plugins will be rendered useless

Nope. It’s only a warning. Existing plugins will remain operational, it’s only those people that may have made 4.6-aware plugins already that will need to change the code so their tags are registered.

Live installations are unaffected for the time being, but we’ll be removing unregistered tag support in a version or two. Easy to fix, as michaelkpate says, for those plugins that are orphaned.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2015-11-10 23:55:33

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,224
Website

Re: Apologies to on-the-ball plugin developers

Bloke wrote #296474:

Sorry to anyone who’s already made their plugins “4.6 ready”.

Just when I thought I was organised …!

OK, can someone spell out what the new “4.6 ready” code would be (i.e. to cater for plugins running in 4.5 AND 4.6)?

Offline

#8 2016-02-07 16:58:06

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Apologies to on-the-ball plugin developers

gomedia wrote #296532:

OK, can someone spell out what the new “4.6 ready” code would be (i.e. to cater for plugins running in 4.5 AND 4.6)?

For most plugins, you’ll have to add something like this, assuming the plugin has two tags, abc_foo and abc_bar:

if(class_exists('\Textpattern\Tag\Registry')) {
	Txp::get('\Textpattern\Tag\Registry')
		->register('abc_foo')
		->register('abc_bar');
}

The examples Bloke gives are more advanced, in case you’ve written an plugin with object oriented code or if the taghandler function differs from the tag name.

Offline

Board footer

Powered by FluxBB