Page 1 of 1

<SOLVED> Modification to the submit script - is it possible...

Posted: Mon Jun 02, 2008 4:57 pm
by jwbassman
Hi guys

First things first - I'm running the latest version of CMSMS 1.2.5 - with PHP5 - and MySql v5

I don't know if this is possible or even desirable but can the submit button on the pages in the admin area also run the script that clears the cache when you go in the global setting and use the clear cache button then...

Reason for asking is my hosting is Servage (clustered) and on reading another post http://forum.cmsmadesimple.org/index.php/topic,19348.0.html it would appear that they were having the same problem - the pages on the site don't update until the clear cache button is pressed - whch clearly makes developing and testing a bit of a pain. As the other user I've tried turning off the PHP Acceleration etc but everything points to a server hosting issue.

I have another identical CMSMS install set up on a friends server and have none of the issues. I'm therefore guessing it's the serevr settings/configuration/cluster that are causing the problems...

Do I have any other option other than changing my host? is it possible mod the submit script to force a clear cache at the same time? can you guys thing of an alternative work around? are there any plans to make a cluster compatible version on CMCMS?

Sorry for all the questions but I have a number of projects in the pipeline and need to try and get this resolved asap - I'm really linking the CMS and found I can do all I've needed to so far so credit where it's due - but i need to know there is anything I can do...

Cheers

John

Re: Modification to the submit script - is it possible...

Posted: Mon Jun 02, 2008 5:07 pm
by calguy1000
You can write a UDT that clears the cache (there's an api function for it, you can see the api call in admin/globalsettings.php)

and then you can add that UDT an event handler in Extensions >> Events on the contenteditpost event (I think, there should be something in there that is obvious).

Re: Modification to the submit script - is it possible...

Posted: Mon Jun 02, 2008 6:18 pm
by jwbassman
Hi calguy1000

thanks for the response - I'm quite new to programming but I'll have a go at what you suggest... if i get stuck I'll be back :)

Re: Modification to the submit script - is it possible...

Posted: Mon Jun 02, 2008 7:40 pm
by jwbassman
Hey guys - not quite sure what I've actually done (see previous note re new to programming - so writing UDT etc was lost on me) but it seems that it works...

i copied the clear cache function from the siteprefs.php

{
global $gCms;
$contentops =& $gCms->GetContentOperations();
$contentops->ClearCache();
$message .= lang('cachecleared');
}

and pasted it at the bottom of the editcontent.php

Should this work? - you guys will know better than me - it appears it does but I've no idea how :)

Re: Modification to the submit script - is it possible...

Posted: Mon Jun 02, 2008 7:43 pm
by Nullig
A better way would be to create a UDT named "clear_cache" (without the quotes).

Contents of the UDT are:

Code: Select all

global $gCms;
$contentops =& $gCms->GetContentOperations();
$contentops->ClearCache();
Go to Admin/Extensions/Events and click on the "ContentEditPost" event.

Add the "clear_cache" UDT from the drop-down menu. The way you're doing it, it won't work if that file ever gets updated.

That should do it.

Nullig

Re: Modification to the submit script - is it possible...

Posted: Mon Jun 02, 2008 7:43 pm
by calguy1000
No, that won't work

the code you pasted should work in a UDT though

so go to Extensions >> User Defined Tags
create a new UDT
paste in that code.

then go to Extensions >> Events
click on the 'ChangeContentPost' event
select the UDT
and click 'add'

Re: <SOLVED> Modification to the submit script - is it possible...

Posted: Mon Jun 02, 2008 8:07 pm
by jwbassman
Cheers guys - you were right, the way I tried it worked once but once the page was updated it just broke everything :(

Following your instructions - User Define Tag additions - perfect - works a charm... many thanks guys - means I'm not looking for a new host :)

Re: <SOLVED> Modification to the submit script - is it possible...

Posted: Wed Jun 04, 2008 7:25 pm
by Pierre M.
Hello,
jwbassman wrote: ...can the submit button on the pages in the admin area also run the script that clears the cache...

Reason for asking is my hosting is Servage (clustered) and...
Thank you Calguy1000 and Nullig for the working event+UDT solution.

Just thinking loudly : couldn't this be a default global setting ? It would make such "clustered" hosting work out of the box and it shoudn't hurt others because all sites are much much much more read than modified. Nostalgia of my first post as guest ;-)

Pierre

Re: <SOLVED> Modification to the submit script - is it possible...

Posted: Wed Jun 04, 2008 7:31 pm
by calguy1000
the cache should be updating by itself whenever a content or page template is changed, so there should be no need on most sites to force it.

Re: <SOLVED> Modification to the submit script - is it possible...

Posted: Mon Jun 23, 2008 6:19 pm
by erniez13
Just thought I'd throw in my 2 cents that I had the EXACT same problem (also hosted on Servage) - The above solution seems to work. I'd really like to know WHY this happens though ....

Ciao

Re: <SOLVED> Modification to the submit script - is it possible...

Posted: Tue Jun 24, 2008 6:59 pm
by Pierre M.
Hello,
erniez13 wrote: I'd really like to know WHY this happens though
This hosting provider seems to replicate sites (actualy copying caches) on several hosts and to "expire" the copies not "fast" enough. Hence if someone hits a copy it may be an obsolete one (not yet obsoleted). And it seems that when the master's cache is cleared the replicating system catches up to clear all copies. Hence when someone hits a cleared copy the page is fresh because generated on the fly.

About this non CMSms specific topic, see Apache's mod_header, mod_expire, mod_cache and things like rsync.

Pierre M.