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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • backporting {crm_api}
Pages: [1]

Author Topic: backporting {crm_api}  (Read 2802 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
backporting {crm_api}
August 24, 2009, 06:19:34 am
Hello, I tried backporting new smarty function:

http://civicrm.org/blog/2065

I hit two - issues:
1) It doesn't seem to read this file is it is in the custom_php location rather than the main install (not the end of the world - I'll just need to get Chris to do it for me)
2) Once that is fixed it works (in terms of getting the right data on the page) but I get a warning:


    * user warning: invalid error callback (16 Array) in C:\xampp\htdocs\circus25\sites\all\modules\civicrm\packages\PEAR.php on line 362.
    * user warning: invalid error callback (16 Array) in C:\xampp\htdocs\circus25\sites\all\modules\civicrm\packages\PEAR.php on line 362.

(the (16 Array)) is because I changed line 362 to have a couple more variables to look at:
 trigger_error("invalid error callback $mode $options" ,  E_USER_WARNING);

And from print_r($options);

I get:


      Array (
  • => CRM_Utils_REST [1] => fatal )


      Array (
  • => CRM_Utils_REST [1] => fatal )



Are there some other changed file in 3.0 that I need?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: backporting {crm_api}
August 24, 2009, 12:52:15 pm
AH - this is an issue for 3.0 too - will log. Guess my php version might affect it.

The error is because it doesn't pass

if_callable($options)

where options is the above array.


PHP Version 5.2.6
« Last Edit: August 24, 2009, 12:54:55 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: backporting {crm_api}
August 24, 2009, 01:29:33 pm
      Array
      (
         
  • => CRM_Utils_REST
  • [1] => fatal
          )

          Array (
  • => CRM_Utils_REST [1] => fatal )


      Array
      (
         
  • => CRM_Core_Error
  • [1] => handle
          )

          Array
          (
             
  • => CRM_Utils_REST
  • [1] => fatal
          )

          Array (
  • => CRM_Utils_REST [1] => fatal )


      Array
      (
         
  • => CRM_Core_Error
  • [1] => handle
          )
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: backporting {crm_api}
August 24, 2009, 01:37:18 pm

TPL file



{* Displays participant listing for an event. *}
{if $rows}
    {include file="CRM/common/pager.tpl" location="top"}
       <table cellpadding="0" cellspacing="0" border="0">
         <tr class="columnheader">
        {foreach from=$headers item=header}
        <th scope="col">
        {if $header.sort}
          {assign var='key' value=$header.sort}
          {$sort->_response.$key.link}
        {else}
          {$header.name}
        {/if}
        </th>
      {/foreach}
     <th>Team
     </th>
         </tr>
      {foreach from=$rows item=row}
      <ul>

      {crmAPI entity="contact" action="get" var="contacts" contact_id=$row.id}
     
     
         <tr class="{cycle values="odd-row,even-row"}">
            <td>{$row.name}</td>   
            <td>{$row.status}</td>
            <td>{$row.date}</td>
            <td>{foreach from=$contacts item=contact}{if $contact.current_employer} {$contact.current_employer}{/if}{/foreach}
       </td>
           
         </tr>
      {/foreach}
      </table>
    {include file="CRM/common/pager.tpl" location="bottom"}
{else}
    <div class='spacer'></div>
    <div class="messages status">
      <dl>
        <dt><img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}" /></dt>     
        <dd>{ts}There are currently no participants registered for this event.{/ts}</dd>
      </dl>
    </div>
{/if}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: backporting {crm_api}
August 24, 2009, 01:59:29 pm

could not reproduce this issue on the 3.0 sandbox

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: backporting {crm_api}
August 24, 2009, 02:25:43 pm
Hi,

What version are you backporting to ?

Otherwise, might be better to create a new api participants_full that does directly the join between the participants and the contacts, cause doing an additional request per participant is going to be dead slow as soon as you got a handful of participants.

Otherwise, I never used the same variable as a result for the crm api. Could it possible that's the problem ?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: backporting {crm_api}
August 24, 2009, 02:45:54 pm
No, I've got it happening on 3.0 too but it's the is_callable

I can't figure it out. is_callable is failing for functions in the REST.php file
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: backporting {crm_api}
August 24, 2009, 03:34:45 pm
OK - am deeply confused. I tried a bunch of functions on the is_callable function and I don't understand the results:

Here's my output:
Code: [Select]
it called CRM_Core_Error::fatal

it called CRM_Utils_File::isAscii

it called CRM_Utils_File::isHtml

it didn't call CRM_Utils_Hook::links

it didn't call CRM_Utils_REST::fatal

it didn't call CRM_Utils_Hook::post

it called CRM_Utils_Array::value

it didn't call CRM_Utils_REST::buildParamList

it didn't call CRM_Utils_Sort::orderBy

it didn't call CRM_Utils_Sort::sortIDValue

And here is the snippet I added into packages/PEAR.php to get it: (approx line 359)

Code: [Select]
$evar[] = array('CRM_Core_Error', 'fatal');
$evar[] = array('CRM_Utils_File', 'isAscii');
$evar[] = array('CRM_Utils_File', 'isHtml');//works
$evar[] = array('CRM_Utils_Hook', 'links');
$evar[] = array('CRM_Utils_REST', 'fatal');
$evar[] = array('CRM_Utils_Hook', 'post');//works
$evar[] = array('CRM_Utils_Array', 'value');
$evar[] = array('CRM_Utils_REST', 'buildParamList');
$evar[] = array('CRM_Utils_Sort', 'orderBy');
$evar[] = array('CRM_Utils_Sort', 'sortIDValue');


foreach ($evar as $evars){
if (is_callable($evars, false,$iscall)){
CRM_Core_Error::debug( "it called $iscall");  // bool(true)
}else{
CRM_Core_Error::debug( "it didn't call $iscall");  // bool(true)
}
}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: backporting {crm_api}
August 24, 2009, 06:31:53 pm

this depends on if the file has been included in the code. We try to keep a minimal set of files included, add this to the top of the file:

require_once 'CRM/Utils/Hook.php';
require_once 'CRM/Utils/REST.php';
require_once 'CRM/Utils/Sort.php';

and all the functions should be callable :)

I suspect in 3.0, CRM/Utils/REST.php is being included in some core files

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • backporting {crm_api}

This forum was archived on 2017-11-26.