future adaptations to plugins

Creating and modifying plugins.
Post Reply
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

future adaptations to plugins

Post by Timbalu »

Dear plugin authors

Since we will make use of Smarty3 in future hopefully, which is rewritten in OOP, PHP5 and getting better and better, there are some things to know.

Normally Serendipity plugins take the fetch method to display and parse templates via

Code: Select all

        $content = $serendipity['smarty']->fetch('file:'. $tfile, null, null, false);
which orientated itself on the old Smarty2 API. And we got used to it.

But with Smarty3 they have changed the parameter order in the fetch method and added a new 4th parameter, to now have 5 of them. Using our code now would need a serendipity wrapper to keep this thing as it used to be. This isn't really a performance runner.

I started to rewrite my plugins to perform in both worlds without using a possible wrapper.
Now it looks like

Code: Select all

        $content = $serendipity['smarty']->fetch('file:'. $tfile, null, null);
and we could even go to

Code: Select all

        $content = $serendipity['smarty']->fetch('file:'. $tfile);
without problems, because nobody is really using the 2cd, 3td, 4th or 5th parameter, I assume.

I haven't discussed this with Garvin, but I think this is a way to go for us all and to avoid wrappers and old behaviour as much as possible for maximum efficiency. With this we don't loose compatibility between Smarty 2 and 3 users, at least in the plugins.

If this is ok for you Garvin, we could make this thread sticky and add some more of these in future.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: future adaptations to plugins

Post by garvinhicking »

Hi!

You're completely right. I just patched all spartacus plugins for this.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: future adaptations to plugins

Post by Timbalu »

Gun boy! No discussion? No sleep over? No hearing? :roll:

For me its ok. Simplicity in Serendipity at his best! ;-)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: future adaptations to plugins

Post by garvinhicking »

Hi!

I don't see anything that could have a negative impact on that, so I didn't think any discussion would be necessary.

If someone thinks otherwise, let's start it. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: future adaptations to plugins

Post by Timbalu »

Dear Plugin Authors

I have another idea to optimize plugin usage to get better bundled with upcoming Smarty 3.
Some of us use log files or other temorary stuff in our Smarty template compile dir named 'templates_c'.
This can look like the one from Maltes dbclean plugin:

Code: Select all

277 	$this->debug_fp = @fopen ( $serendipity ['serendipityPath'] . 'templates_c/dbclean.log', 'a' );
As of thinking to pluginize some sort of Serendipity free cache function (maybe with future dashboard, which is actually what I am trying to do) with Smartys own function like clearCompiledTemplate() and clearCache(), I realized Smarty 2 will delete all files, but Smarty 3 has the improvement not to delete files starting with '.' from cache and template_c folders on clearCompiledTemplate() and clearCache().

So: everybody using 'templates_c' as an temporary archive for plugin files could rewrite them to be a .filename.ext, to be independend from clearing cache automatically or by accident.

When I reworked the Downloadmanger Plugin I decided to store temporary files into /archives/, by the way, which is more likely a better place to store files created by serendipity plugins. But if this is the prefered option for all other plugins, I can't say, until Garvin will uprise his thumb.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: future adaptations to plugins

Post by garvinhicking »

Hi!

Hm, I think this could be problematic, as "." files are by default hidden in FTP clients and this will lead to confusion... I would leave it as normal files. IMHO cachefiles should always be stored in templates_c, if the plugin regenerates those files when they are missing.

Any file that is required to exist or that is externally linked to (like generated .pdf files or feeds or whatever) should be stored in archives/ though.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: future adaptations to plugins

Post by Timbalu »

Hi Garvin

I don't think this ftp feature is problematic or confusing.
Why should you want to download files like this via ftp?
There is a better way doing this via plugin, having a log file download option, which is recommended to have (well maybe not if your spamblock logfile is > 10MB ;-) ) everywhere.

About caching: Smarty normally makes differences having a compile dir (templates_c) and a cache dir (cache).
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: future adaptations to plugins

Post by garvinhicking »

Hi!

For backups, or when things are misbheaving and we tell people to check out those files. :-)

Let's put it the other way around, what's the real benefit of "." files? Everything in templates_c should be removeable at best...if you know of plugins that don't behave like that, please tell so I'll try to put such files in archives/ instead.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply