Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-09-30 02:39:31

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 997
Website

jpcache without hacking

Every time a new version of TXP comes along, I dutifully test the release candidate on a number of sites. For the majority of sites, it goes something like this:

cd my/document/root
wget http://textpattern.com/file_download/.../textpattern-4.x.tar.gz
tar -zxvf textpattern-4.x.tar.gz
cp -r textpattern-4.x/* .
cp -r textpattern-4.x/.htaccess
rm -r textpattern-4.x

Then, I reload the admin panel and update the language. Bam! It’s the same process when the stable version comes out.

Okay, so maybe it’s not that simple— several sites have custom .htaccess directives that must be merged.

There’s also asy_jpcache, which makes my site go ridiculously fast, but requires a small edit to the site’s index.php file. The main reason I don’t use it on more sites is that it requires that I hack a core file, and I don’t want to leave a client with a project that they cannot safely upgrade.

Tonight as I upgraded my version of slimstat, I saw Robert’s concise description of the same problem — in summary:

That tiny modification might cause headaches in case of upgrades and has to be kept track of. Using a plugin approach it requires no modifcation to any of Textpatterns core code files but works by simply uploading this plugin through the usual plugin administrative interface. No need to edit index.php anymore.

In wet_slimpattern, Robert achieves this with very little code— here’s the main part:

if(txpinterface == 'public' && !preg_grep ($ignore, array($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']))) {
 	@include_once ($_SERVER["DOCUMENT_ROOT"].$statslogger);
}

So, not being “competent” in php, I wonder if the same approach could be used to eliminate the need to edit index.php for asy_jpcache to work:

include './jpcache/jpcache.php'; // <-- This is the hack.
include txpath.'/publish.php';

Can this be rolled into the plugin somehow? Or an auxiliary plugin?

Offline

#2 2010-09-30 14:05:22

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: jpcache without hacking

Hi John,

untested idea for you. I’ve never used asy_jpcache but this might work. On a test site, create a directory (outside the site root would be ideal — but not 100% necessary) and setup your TXP installation’s plugin cache directory to point to it (admin > prefs > advanced.)

Now create a file cache_bootstrap.php (or whatever) in the newly created plugin cache directory and put this code in it…

<?php 
if(txpinterface == 'public')
  include_once 'path/to/your/jpcache/installation/jpcache.php';

That’s it. Just edit the path to your jpcache files as needed.

This bootstrap file should get loaded as part of publish.php’s initialization of the plugins.

Let me know how it goes.

Last edited by net-carver (2010-09-30 14:16:03)


Steve

Offline

#3 2010-09-30 14:15:24

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: jpcache without hacking

net-carver wrote:

Now create the file cache_bootstrap.php in the cache directory and put this code in it…

I should have made that a little clearer — that’s the plugin cache directory I’m talking about putting the bootstrap file in.


Steve

Offline

#4 2010-09-30 15:19:41

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 997
Website

Re: jpcache without hacking

Thanks, Steve!

Here’s what happened: The site fails to load, and no cache files are created. I tried using both a relative and an absolute path to jpcache.php, and I get the same results. As soon as I comment out both lines, the site can be loaded again.

I can’t tell when the cache_bootstrap.php is being loaded: Does includ-ing it like this call it before, during, or after publish.php?

According to the asy_jpcache install instructions, it has to come before publish:

Edit your index.php in the main directory and BEFORE

include $txpcfg['txpath'].'/publish.php';

insert the following line:

include './jpcache/jpcache.php';

Thanks again for your wisdom and guidance! Warm regards.

Offline

#5 2010-09-30 16:03:20

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: jpcache without hacking

Hmmm. Could be a problem with that path in the bootstrap. Guess I’ll have to finally give asy_jpcache a try on an installation!

Anyway, to answer your question — what I’ve outlined should cause jpcache.php to get loaded during the early execution of publish.php, around line 118 (or thereabouts), as the plugins are loaded.


Steve

Offline

#6 2010-09-30 16:11:30

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 997
Website

Re: jpcache without hacking

Thanks again, Steve. I’d love to hear what you learn! Let me know if you’d like me to do any further testing.

Offline

#7 2010-09-30 18:49:12

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: jpcache without hacking

Hi John.

Sorry to say I can only seem to get it to work when it is patched into index.php as per the instructions.


Steve

Offline

#8 2010-09-30 18:55:47

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 997
Website

Re: jpcache without hacking

I guess if it was as easy as what Robert did in wet_slimpattern, someone would have already done it.

It would be great to find an alternative to hacking the core.

Offline

#9 2010-10-01 08:38:07

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: jpcache without hacking

For comfortable using any cachy system we should have to callbacks – one before any output, and one before the latest output function. Could developers say if it’s possible?


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

Board footer

Powered by FluxBB