Open main menu

Changes

215 bytes removed ,  10:22, 23 October 2015
remove quotes from sql; remove nowiki tags that are not needed
I used a breakpoint in <code>civicrm/api/V3/Mailing.php</code> at '''line 536''' where $details gets populated from a call to CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens())
At that point, the variable $tokens is an <nowiki>array[3]</nowiki> with keys html, text, subject
<nowiki>$tokens['html'] is an array[4] with keys contact, general, domain, action</nowiki><br /><nowiki>$tokens['html']['contact'] is an array[3] with values 'first_name', 'custom_40' and 'custom_71'</nowiki> <br /><nowiki>$tokens['html']['general'] is an array[2] with values 'wUrl', 'custom_40'</nowiki> <br /><nowiki>$tokens['html']['domain'] is an array[1] with values 'address'</nowiki> <br /><nowiki>$tokens['html']['action'] is an array[1] with values 'optOutUrl'</nowiki> <br />
At this point, $body_html contains the un-evaluated html (meaning the tokens are still present in their literal form).
Interestingly, the $_query is data_select * from $_table civicrm_mailing
<nowiki>$returnProperties is an array[7] with hash, preferred_mail_format, contact_id, display_name, first_name, custom_40, custom_71 all set to (int) 1</nowiki>
Some related constants?
getKeyID is called and for $key "custom_71", it returns "71" since $all is bool 0
<nowiki>Those values populate $cfID and in turn $custom[], so that now $custom is array("40", "71")</nowiki>
We then go through the autoloader mechanism for "CRM_Contact_BAO_Query"
and $argString is "exportableFields All_1_0_1_2"
Cache::getItem() is called and Array::value() is called on list which looks small at array(15) but elements like <nowiki>[CRM_PC_CRM_Core_DAO_StateProvince_1_id_name_is_active] is array(3907)</nowiki>
Then we go through the DataObject class methods to create a dsn and connection
<source lang="sql">
"SELECT *, config_backend, locales, locale_custom_strings FROM civicrm_domain WHERE ( civicrm_domain.id = 1 ) ";" SELECT subtype.*, parent.name as parent, parent.label as parent_label FROM civicrm_contact_type subtype INNER JOIN civicrm_contact_type parent ON subtype.parent_id = parent.id WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL AND subtype.is_active = 1 AND parent.is_active = 1 ORDER BY parent.id";"SELECT * FROM civicrm_mailing_group WHERE ( civicrm_mailing_group.id = 511 )";"SELECT * FROM civicrm_mailing WHERE ( civicrm_mailing.id = 17 ) ";"SELECT * FROM civicrm_domain WHERE ( civicrm_domain.id = 1 ) ";
</source>
{{highlight |text=When stepping through lines of code in NetBeans with the XDebug debugger running, you can mouse over a variable and a tooltip will display it's current value.}}
<nowiki>As CRM_Core_BAO_Cache::getItem() is called, $data gets set, and cached, by unserializing $dao->data. $data is now array[117]</nowiki>
and includes all the 'custom' fields such as
<nowiki>[custom_40] array[10] 'name', 'title', 'headerPattern', 'import', 'custom_filed_id' => (int) 40, 'text_length', 'data_type'=>"String", 'html_type'=>"Text", 'is_search_range'=>"0"
<br /><br />
[custom_71]
<br /><br />
later we get to __construct() in CRM/Contact/BAO/Query.php but $fields is null, so on line 445
</nowiki>
$this->_fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE, TRUE);
NOTICE THE '''5th parameter ($withMultiRecord) is missing''', so the default bool(0) is used. I overrode it and set it to 1
<nowiki>
Later, $this->_fields = array_merge($this->_fields, $fields); array[117], array[122] = array[239]
<br /><br />
<br /><br />
The function name / pattern that they are looking for is eqt_civicrm_queryObjects()
</nowiki>
Somewhere along the line, around here, Symfony\Component\EventDispatcher::dispatch is called and the $event is an Civi\API\Event\RespondEvent object with several properties including the apiRequest with is an array[9] and apiRequest[fields] is array[123] and apiRequests[fields][custom_40] is an array[21] so this is where the API request and response is happening and dispatch gets called.
4,558

edits