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) »
  • php lazy copying or lazy coding
Pages: [1]

Author Topic: php lazy copying or lazy coding  (Read 734 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
php lazy copying or lazy coding
February 25, 2011, 04:17:48 am
It looks like there ARE at least some functions that modify $params (the examples files pick up any changes if you have them enabled while running tests).

In this case it looks like some values are being unset & the date format has changed (the actual date changed too but that's because the code uses current date which should be changed)


Code: [Select]
Index: api/v3/examples/ActivityCreate.php
===================================================================
--- api/v3/examples/ActivityCreate.php (revision 32679)
+++ api/v3/examples/ActivityCreate.php (working copy)
@@ -5,16 +5,13 @@
     
                   'source_contact_id' => '17',
                   'subject' => 'Make-it-Happen Meeting',
-                  'activity_date_time' => '20110212000000',
+                  'activity_date_time' => '20110225',
                   'duration' => '120',
                   'location' => 'Pensulvania',
                   'details' => 'a test activity',
                   'status_id' => '1',
                   'activity_name' => 'Test activity type',
                   'version' => '3',
-                  'activity_type_id' => '1',
-                  'activity_status_id' => '1',
-                  'priority_id' => '',
 
   );
   require_once 'api/api.php';
@@ -38,9 +35,9 @@
                       'id' => '1',
                       'source_contact_id' => '17',
                       'source_record_id' => '',
-                      'activity_type_id' => '1',
+                      'activity_type_id' => '',
                       'subject' => 'Make-it-Happen Meeting',
-                      'activity_date_time' => '20110212000000',
+                      'activity_date_time' => '20110225',
                       'duration' => '120',
                       'location' => 'Pensulvania',
                       'phone_id' => '',
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

donquixote

  • I post occasionally
  • **
  • Posts: 42
  • Karma: 3
  • CiviCRM version: none
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5.2
Re: php lazy copying or lazy coding
February 25, 2011, 09:46:12 am
Ok then, this was to be expected.
Maybe in some cases it is intended.
Where it is not intended, it is nevertheless possible that some (external) code exists that expects the values to change, and that will break if we remove the "&".
So if we don't want to break anything, we need to keep the "&" in those functions that actually do a modification. We can provide an alternative that does not have a "&", and mark the existing one as "deprecated".

All of this just general thoughts, without looking at the details.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: php lazy copying or lazy coding
February 25, 2011, 02:23:58 pm
Code: [Select]
it is nevertheless possible that some (external) code exists that expects the values to change
Not for the v3 functions really as v3 has only just hit alpha - ideally we would fix in v3 before it goes BETA
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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • php lazy copying or lazy coding

This forum was archived on 2017-11-26.