Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-02-25 20:59:59

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

Updating plugins to use new trace functionality in TXP 4.6

Earlier this week, a change landed in the TXP 4.6 development tree that affects the way the tag trace works. This affects plugins that use the old trace_add() function.

Things you need to know:

1. Add global $trace; to the functions where you use trace functionality.
2. Change all the trace_add() calls to $trace method calls…

If you just want to log an event in the tag trace and it’s only important when it occurs, but not how long it takes, use:

$trace->log('Some informative text');

If you want to measure how long something takes, use:

$trace->start('Describe the event');
...[do stuff here]...
$trace->stop();

TXP uses that to add information about SQL queries and self-closing tags in the tag trace: $trace->start('<txp:tag />'). For container tags, we use $trace->stop('Describe end of event') so the closing tag shows up in the tag trace as well: $trace->stop('</txp:tag >').

PS. if you don’t use trace_add in your plugins, you do NOT have to update your plugin. This only affects plugins that use this specific function.

Offline

#2 2016-02-26 06:53:33

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Updating plugins to use new trace functionality in TXP 4.6

What was the reason to remove trace_add() completely instead of keeping it in v4.6 with a deprecated doc comment, just like it was handled elsewhere?

Offline

#3 2016-02-26 08:07:39

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

Re: Updating plugins to use new trace functionality in TXP 4.6

trace_add isn’t removed. It just gives a deprecated warning.

Offline

#4 2016-02-26 09:06:11

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Updating plugins to use new trace functionality in TXP 4.6

Oops, my bad.

Offline

#5 2016-07-05 18:19:04

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: Updating plugins to use new trace functionality in TXP 4.6

ruud wrote #298017:

trace_add isn’t removed. It just gives a deprecated warning.

I do not see any sense in deprecated warning. Why not leave the possibility to use trace_add() ?
Why create the same difficulties themselves? For example, imagine how it will look the plugin code which will run under the Txp 4.4, 4.5, 4.6 (Support for each version of Textpattern – a separate plugin branch – I’m not ready.)

global $trace;
if ( object exist... ) {
	$trace->log('Some informative text');
}else{
	trace_add();
}

vs

trace_add();

aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#6 2016-07-05 18:48:09

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

Re: Updating plugins to use new trace functionality in TXP 4.6

  1. Trace isn’t an essential part of TXP. It’s used mainly when developing. I would hope that those who are developing their website also keep it up to date.
  2. If you keep old code around just to remain compatible, that makes the code base larger than needed, more difficult to maintain and more susceptible to security risks.
  3. If we didn’t warn about its removal, you’d be faced with an error once the function was actually removed.

Don’t support old TXP versions. Aim for the last officially released version.

Offline

#7 2016-07-07 18:19:06

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: Updating plugins to use new trace functionality in TXP 4.6

ruud wrote #300205:

  1. Trace isn’t an essential part of TXP. It’s used mainly when developing. I would hope that those who are developing their website also keep it up to date.

I know that trace_add used to develop and I tried to make it convenient and more informative.
Pull: 498 , 501
These changes were fully compatible with previous versions of Textpattern.

Usability and backward compatibility – the key factors that attract me in Textpattern. I use and I will continue to use previous versions of Textpattern (it has its own reasons), so I try not to break unless absolutely necessary backward compatibility.

For me, it remains a mystery why it was necessary to transfer the function trace_add in OO. But what’s done is already done. I ask leave only the original functional trace_add() as it is. Those. remove deprecated warning and keep trace_add function in the future.

ps: I hope that no one would ever think to rewrite gps() function in OO… ;-)

Last edited by makss (2016-07-07 18:45:40)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#8 2016-07-07 22:36:07

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

Re: Updating plugins to use new trace functionality in TXP 4.6

ruud wrote #300205:

Don’t support old TXP versions. Aim for the last officially released version.

Yes, it’s not ideal but it’s ultimately a decision for plugin authors.

It’s not practical for me to manage two versions of each plugin, so I’m making them 4.5 and 4.6 compatible. Once all my client websites are migrated to 4.6, subsequent iterations of plugin updates will then be stripped of 4.5 code. This process could take many months and maintenance of two versions is too onerous … dual 4.5/4.6 compatibility is the way I’m going.

Offline

#9 2016-09-05 08:42:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Updating plugins to use new trace functionality in TXP 4.6

I’ve temporarily squashed the deprecation notice, but it will be restored when things have settled down, maybe next version.

I know we could argue that throwing deprecation warnings for things like tag registration is similarly invasive, and I’m with Ruud that we should aim for the latest version with plugin development, but trace_add() is:

  • minor functionality, for debugging / performance
  • can occur in many places in plugin code

Conversely, tag registration is important and is usually caught with a single conditional in code for dual 4.5/4.6 plugins so the pain to developers is not as great.


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

Board footer

Powered by FluxBB