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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Possible bug in CRM/Contact/Form/Search.php ?
Pages: [1]

Author Topic: Possible bug in CRM/Contact/Form/Search.php ?  (Read 1108 times)

axlroach

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
Possible bug in CRM/Contact/Form/Search.php ?
September 28, 2009, 11:53:58 am
Hi all,

I'm running a *somewhat* customized 2.2.8 branch for a project I'm working on.  In the Search.php file at around 242 there's this code:

Code: [Select]
    function buildQuickForm( )
    {
        $permission = CRM_Core_Permission::getPermission( );

        // some tasks.. what do we want to do with the selected contacts ?
        $tasks = array( '' => ts('- more actions -') ) + CRM_Contact_Task::permissionedTaskTitles( $permission );

In our system, there are times when $permission comes back as null.  When this happens, you get a fatal error (unsupported operand types).  The fix seems pretty simple.  Just add a conditional:

Code: [Select]
    function buildQuickForm( )
    {
        $permission = CRM_Core_Permission::getPermission( );

        // some tasks.. what do we want to do with the selected contacts ?
        if ($permission != NULL) {
          $tasks = array( '' => ts('- more actions -') ) + CRM_Contact_Task::permissionedTaskTitles( $permission );
        }

The problem is that I can't tell if this is a civicrm bug or if there's something within this particular project that's causing this issue.  The Search.php file in both our slightly customized branch and the standard civicrm 2.2.8 branch seem to be the same, so this could be a bug that exists outside of our custom branch.  I just wanted to get a second opinion on it before posting it as an issue.

Thanks,
aj

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: Possible bug in CRM/Contact/Form/Search.php ?
September 28, 2009, 02:33:58 pm

can you recreate the same issue on the demo sandbox?

under what conditions do u get the error? and can u replicate it on a non-tweaked install (to isolate the issue)

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

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: Possible bug in CRM/Contact/Form/Search.php ?
October 09, 2009, 12:58:15 am
Quote from: axlroach on September 28, 2009, 11:53:58 am
The problem is that I can't tell if this is a civicrm bug or if there's something within this particular project that's causing this issue.  The Search.php file in both our slightly customized branch and the standard civicrm 2.2.8 branch seem to be the same, so this could be a bug that exists outside of our custom branch.  I just wanted to get a second opinion on it before posting it as an issue.


Been there, done that.

The key thing is knowing what code is generating the bad behavior, which if you're getting this problem rarely -- and therefore don't know how to make the problem happen reproducibly -- can be very hard to find out.

You do know where you're getting the fatal, which is a major start.  I'd recommend that you add a bit of code in your custom "fix" to do something like this, so you can let your server run for a while until you've gotten a few people encountering the code path in question:
Code: [Select]
//first, get something put into your error logs so you know who was doing something, when they were doing it, and what link they were accessing
error_log('WEIRD ERROR -- permission looks wrong');

//Then, make sure you can get the trace
$fh = fopen('path-to-your-log-file', "a");
if ($fh) {
  ob_start();
  debug_back_trace();
  $trace = ob_get_clean();
  fwrite($fh, "A little context about your bug, maybe including time or the URL requested...\n");
  fwrite($fh, $trace);
  fwrite($fh, "\n");
  fclose($fh);
}

Now you'll know how you're failing, and hopefully, you can do the needed action in the UI to make CiviCRM hit this point consistently.

Once you can do that, you can possibly figure out the problem directly, or you can use a source-code debugger to trace back and see where things are going wrong.  You can also determine if plain vanilla CiviCRM of the same version is subject to this problem.
 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Possible bug in CRM/Contact/Form/Search.php ?

This forum was archived on 2017-11-26.