clear cache and redirect after_new_action

A place for users and developers of the Xataface to discuss and receive support.

clear cache and redirect after_new_action

Postby manifold » Mon Oct 24, 2011 12:16 pm

Hello all,

Typically, upon adding/editing/deleting a record, a confirmation screen is presented, and (apparently) the cache is cleared and the new state of the record is visible (eg, the new value for an edited field has replaced the original value).

I now have a custom action which updates one table after a modification in another, by way of a custom query (thanks to ADobkin). Here's the problem: the record is modified; the record is saved; upon saving, the associated table is modified; BUT the screen simply turns white, not returning a 'record modified' message (or anything, for that matter, not even the execution time). I must manually clear the cache, and .. voila... the record modification is now visible. But this is cumbersome, and frankly inscrutable to the folks I am trying to encourage to use my system.

I've researched the forums here, and I've tried several of the variations of the options potentially available; none has worked. Perhaps I have missed something.

So: If anyone has any insights or suggestions, I'd appreciate them!

TIA,
-manifold
"Heisenberg may have slept here."

"I'm positive I've lost an electron...."
manifold
 
Posts: 31
Joined: Wed Jun 29, 2011 8:49 am

Re: clear cache and redirect after_new_action

Postby shannah » Mon Oct 24, 2011 1:45 pm

If the screen is turning white it looks like you have a fatal error. Check your error logs.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: clear cache and redirect after_new_action

Postby manifold » Mon Oct 24, 2011 2:16 pm

The error log is clear... at least, no error is recorded.

If I manually reload the page with a ' ?-action=clear_cache', and then go back to the table that should have been modified.. .I see that it in fact *has* been modified.

So, the custom query:

Code: Select all
function afterSave(&$record){
      $this->app =& Dataface_Application::getInstance();
   $vin = $record->val('vin'); // refers to value of workorder.vin
      $inservice = $record->val('inservice'); // refers to value of workorder.inservice
      $result = mysql_query("UPDATE apparatus SET status='$inservice' where vin='$vin'", $this->app->db());
}


returns a white screen, even though the table & record had been properly changed. But I have to manually do a
reload of the page with a '-action=clear_cache' suffix.

The custom query does seem to work; I'm just trying to get it to return a standard 'record successfully modified' page...
"Heisenberg may have slept here."

"I'm positive I've lost an electron...."
manifold
 
Posts: 31
Joined: Wed Jun 29, 2011 8:49 am

Re: clear cache and redirect after_new_action

Postby shannah » Mon Oct 24, 2011 2:25 pm

Does it work if you disable the output cache, or do you get the same thing?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: clear cache and redirect after_new_action

Postby manifold » Mon Oct 24, 2011 3:51 pm

Same thing!
"Heisenberg may have slept here."

"I'm positive I've lost an electron...."
manifold
 
Posts: 31
Joined: Wed Jun 29, 2011 8:49 am

Re: clear cache and redirect after_new_action

Postby shannah » Mon Oct 24, 2011 5:02 pm

Sounds like the output cache is a red herring then. It is more likely that there is an error happening some time during the save. Strange that it's not in your error log. Try putting strategic die('here') statements at various places in your afterSave() method to see where it is dying.

Perhaps there is another error log somewhere that it is writing to?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Update:Re: clear cache and redirect after_new_action

Postby manifold » Wed Oct 26, 2011 6:09 am

I had recently included a 'getTitle' function in my apparatus.php class delegate file:

Code: Select all
<?php

class tables_apparatus {

   function getTitle(&$record) {
      return $record->display('recno') . ' - ' . $record->display('designation');
   }
}
?>


By using this file, a white screen is returned upon updating a workorder record (this updates the availability status of a vehicle; the custom query that updates an apparatus record upon saving the workorder is identified above). If I remove the getTitle function... the workorder returns properly with a 'record successfully saved' message, and the apparatus table is successfully updated.

Though for the life of me, I can't understand why!
"Heisenberg may have slept here."

"I'm positive I've lost an electron...."
manifold
 
Posts: 31
Joined: Wed Jun 29, 2011 8:49 am

Re: clear cache and redirect after_new_action

Postby ADobkin » Wed Oct 26, 2011 6:45 am

Maybe there is something in one of those fields that isn't working with the getTitle function. Instead of using the $record->display() functions, try using $record->val() or $record->strval().
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: clear cache and redirect after_new_action

Postby FractalizeR » Wed Oct 26, 2011 6:48 am

You can clear cache from your action by using

Code: Select all
<?php
Dataface_SkinTool::getInstance()->clear_all_cache();
FractalizeR
 
Posts: 19
Joined: Tue Oct 04, 2011 5:26 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 36 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved