CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Unable to find valid value for 'ct'
Pages: [1]

Author Topic: Unable to find valid value for 'ct'  (Read 1536 times)

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Unable to find valid value for 'ct'
October 28, 2008, 12:21:41 pm
We are seeing the error "Unable to find valid value for 'ct'" error appear repeatedly for our site's heavy users when updating core contact data. This is on 2.0-SVN.

The issue is intermittent, though I've had reports that it can become persistent enough that the majority of contact updates fail.

We have had limited success with asking people to repeat the update after seeing the error; specifically
  • Go back and reload the edit screen
  • Make the contact update again, and hit "Save"

When that fails (which it has for one or two staff), I've advised them to log out and log back in, then repeat the update. This appears to have worked when it's been required.

The impression from our staff seems to be that over time it becomes more and more likely that any given update will fail.

I'm not entirely convinced that either of the processes above are reliable workarounds for the issue (it may be just that it reduces the likelihood of it happening).

I activated the civicrm_error module and have collected some info by adding additional debug code to CRM/Utils/Request.php. It's looking in $_REQUEST for a value named 'ct', but this value doesn't exist in that array.

Because of the behaviour (intermittent, but worsening over time), I'm wondering if we're running out of $_SESSION space or something similar. It seems like resetting the session helps, and that sometimes the user exists in a zone where any given update may or may not succeed.

I'd really appreciate some guidance identifying the issue and finding a fix.
@xurizaemon ā— www.fuzion.co.nz

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Unable to find valid value for 'ct'
October 28, 2008, 02:44:59 pm
I've added some code to allow me to see where 'ct' would normally appear. The wierd thing is, it doesn't seem to do so ...

I made the following change to CRM/Utils/Request.php:
Code: [Select]
Index: Utils/Request.php
===================================================================
--- Utils/Request.php (revision 16991)
+++ Utils/Request.php (working copy)
@@ -104,8 +104,20 @@
             $value = $store->get( $name );
         }
 
+  if ( $name == 'ct' ) {
+        $chk = 'Checking: ' . print_r( array($name, $method, $abort),1 ) ;
+        CRM_Core_Error::debug_var( 'CRM_Utils_Request::retrieve()', $chk ) ;
+  }
         if ( ! isset( $value ) && $abort ) {
+            $dbg = "Could not find valid value for $name, looking in $method:\n" .
+                     print_r( array( '_GET' => $_GET,
+                                     '_POST' => $_POST,
+                                     '_REQUEST' => $_REQUEST ), 1 ) ;
+            CRM_Core_Error::debug_var('CRM_Utils_Request::retrieve()', $dbg ) ;
             CRM_Core_Error::fatal( "Could not find valid value for $name" );
+        } elseif ( $name == 'ct' && $abort ) {
+            $dbg = "Successfully found value for $name, looking in $method:\n" .
+                     print_r( array( '_GET' => $_GET,
+                                     '_POST' => $_POST,
+                                     '_REQUEST' => $_REQUEST ), 1 ) ;
+            CRM_Core_Error::debug_var('CRM_Utils_Request::retrieve()', $dbg ) ;
         }
 
         if ( ! isset( $value ) && $default ) {

... so that I could see what "ct" was when it did or didn't appear.

On a save which works, ct is checked but the $abort flag to CRM_Utils_Request::retrieve() was empty. So apparently there are some circumstances where ct is required - but I'm not sure what these are.

I looked for calls to CRM_Utils_Request::retrieve('ct') and found only two:

 * CRM_Core_Invoke::contact()
 * CRM_Contact_Form_Edit::preProcess()

So, I can tell which of these I'm in using the first changed line above.

If the save succeeds, it's because we've obtained the contact type via CRM_Core_Invoke::contact(), where $abort is false. In that case I see,
Code: [Select]
Oct 29 10:32:19  [info] $CRM_Utils_Request::retrieve() = Checking: Array
(
    [0] => ct
    [1] => GET
    [2] =>
)

If the save fails, it's because we've obtained the contact type via CRM_Contact_Form_Edit::preProcess(), where $abort is true. In that case I see,
Code: [Select]
Oct 29 10:32:19  [info] $CRM_Utils_Request::retrieve() = Checking: Array
(
    [0] => ct
    [1] => REQUEST
    [2] => 1
)

In the latter case, we are inside a condition of if ( $this->_action == CRM_Core_Action::ADD ) { ... but we're editing an existing contact. I suspect this may be because the contact's details have changed; this error has only been reported when editing core contact data (esp. email and phone numbers).

Time for a deep breath and a bit of thought.

Lobo has given me some code to debug with, but I haven't seen the error since then to try it out. It's worth noting that it's very hard to reproduce this error; it's only happening regularly for some staff who are using the system all day, and they are several hundred km from where I am based :P
« Last Edit: October 28, 2008, 02:46:48 pm by xurizaemon »
@xurizaemon ā— www.fuzion.co.nz

zagrev

  • Guest
Re: Unable to find valid value for 'ct'
January 07, 2009, 01:42:20 pm
I know this is old, but I have been having this problem frequently since upgrading to 2.1.2/drupal 6.8. It's been bugging the crap out of me and my customers. While researching online, I came across this thread and Lobo's comment about how it was unreproducible on the development servers. And I had an idea. My installation is on an ISP server, and the default table format is MyISAM. This means that about 1/2 my Drupal tables (include Civicrm_*) are MyISAM, and 1/2 are InnoDB. But all the CiviCRM tables are InnoDB. I wonder if the problem might not be:

a) the UTF8 charset has issues on the MyISAM tables, or
b) there are some queries that use tables of both types in a transaction, and the MyISAM tables kill the queries.

Has this been tested on the development servers?  I think most of the tables that were created by plugins are MyISAM (the default)

Zagrev

zagrev

  • Guest
Re: Unable to find valid value for 'ct'
January 07, 2009, 05:51:20 pm
Another possibility is that our Drupal and CiviCRM databases on are different servers.  Maybe something with timing?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Unable to find valid value for 'ct'
January 07, 2009, 05:59:01 pm

1. can u ensure that your session table is utf8. Might help with performance / stability to make it an innodb table (row level locking helps a lot for this table)

2. the session is stored in the drupal database. it is possible that it might have to do with timing, but i doubt it. Also how "frequent" is "frequent"

3. by any chance do you have any ajax widgets on the add/edit contact pages?

4. are all your civicrm table innodb? your message is a bit ambigious with regard to that. We do not have queries across drupal and civicrm tables

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Unable to find valid value for 'ct'
January 07, 2009, 06:52:05 pm
We see this a fair bit still, principally with users whose sessions grow large. Currently I'm suspecting that their sessions are growing over time and exhausting some limit in PHP (possibly the largetext allocated for their session in the Drupal DB?) and for this reason the CT value is not getting stored correctly.

We have our tables in separate DBs on the same DB server.

drupal.sessions is MyISAM currently.
@xurizaemon ā— www.fuzion.co.nz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Unable to find valid value for 'ct'

This forum was archived on 2017-11-26.