Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-19064 Added an API for Personal Campaign Page #7878

Closed
wants to merge 7 commits into from

Conversation

digitlimit
Copy link

@digitlimit digitlimit commented Feb 28, 2016

This API exposes CiviCRM Personal Campaign Page (PCP).


@civicrm-builder
Copy link

Can one of the admins verify this patch?

@totten
Copy link
Member

totten commented Feb 29, 2016

jenkins, ok to test

@digitlimit
Copy link
Author

@totten is there any issue with this PR, been update 5 days since checks commenced.
Why is it taking so long?

@eileenmcnaughton
Copy link
Contributor

test this please

@mlutfy
Copy link
Member

mlutfy commented Mar 8, 2016

@digitlimit Thanks for sending a patch! Do you have a JIRA issue for this pull-request? (c.f. https://wiki.civicrm.org/confluence/display/CRMDOC/Contributing+to+CiviCRM+using+GitHub step 8 : create a JIRA issue on https://issues.civicrm.org).

Also I was wondering why you used "p_c_p" in the function name, instead of "pcp"?

Does the API call need documentation/tests?

@digitlimit
Copy link
Author

@mlutfy thanks for your response.

I followed the naming convention of other APIs.
When I name the api method like you suggested below:

civicrm_api3_pcp_get

_civicrm_api3_get_BAO(__FUNCTION__) returns NULL

This is because this line $dao = CRM_Core_DAO_AllCoreTables::getFullName($name); in sites/all/modules/civicrm/api/v3/utils.php returns NULL which leads to wrong CRM DAO class name and wrong path.

However, the correct class name is returned when I name the api method like so : civicrm_api3_p_c_p_get

$dao = CRM_Core_DAO_AllCoreTables::getFullName($name); then returns CRM_PCP_DAO_PCP which also translates to this path CRM\PCP\DAO\PCP

Please if my explanation is not clear enough I can explain further.

I have created a JIRA issue for this PR here:
https://issues.civicrm.org/jira/browse/CRM-18195

@eileenmcnaughton
Copy link
Contributor

ok to test

@eileenmcnaughton
Copy link
Contributor

Oddly enough AllCoreTables handles IM OK - but not PCP - I wonder why

Fixed the following warnings

1 - EndFileNewline	
1 - LineEndings
3 - ScopeIndent
@digitlimit
Copy link
Author

@eileenmcnaughton Please can you explain what you mean here?

Oddly enough AllCoreTables handles IM OK - but not PCP - I wonder why

Fixed four warnings
@eileenmcnaughton
Copy link
Contributor

I mean that the IM class suffers from the same oddness as PCP - ie. it's all caps rather than camel case - so I thought that whatever meant the im api isn't oddly named would work for pcp too....

Unless people have only actually tested 'Im' not 'IM' in their api calls.

@MegaphoneJon
Copy link
Contributor

@eileenmcnaughton The IM (and ACL) APIs have a special exception in api/v3/util.php. I wrote this PCP API a while ago, but I also hacked util.php to keep the name consistent: http://civicrm.stackexchange.com/questions/3030/incoporating-pcps-in-wordpress/3037#3037

@monishdeb
Copy link
Member

Jenkin, test this please

@monishdeb
Copy link
Member

Please fix the style error as per https://test.civicrm.org/job/CiviCRM-Core-PR/8497/checkstyleResult/new/

@colemanw
Copy link
Member

jenkins, retest this please

1 similar comment
@colemanw
Copy link
Member

jenkins, retest this please

// FIXME: DAO names should follow CamelCase convention
By changing this:
  if ($name == 'Im' || $name == 'Acl') {
    $name = strtoupper($name);
  }

To:
  if ($name == 'Im' || $name == 'Acl' || $name == 'Pcp') {
    $name = strtoupper($name);
  }
Changed p_c_p to pcp which is the right naming convention
@colemanw
Copy link
Member

The current round of test failures look legit - syntax conformance tests are falling over on the Pcp entity.

@digitlimit
Copy link
Author

@colemanw please where can view the syntax errors so I can correct them

@colemanw
Copy link
Member

These are not syntax errors they are test failures. Click the "details" link below (next to "Merged build finished") to see them.

// FIXME: DAO names should follow CamelCase convention
//Reverted:

    if ($name == 'Im' || $name == 'Acl' || $name == 'Pcp') {
        $name = strtoupper($name);
    }

To:

    if ($name == 'Im' || $name == 'Acl') {
        $name = strtoupper($name);
    }
Reverted the naming convention form pcp to p_c_p due to tests failures
@MegaphoneJon
Copy link
Contributor

OK, I've reviewed the code.
PCP entity is unique in that:

  • Its name isn't in camelcase - only one of three entities (ACL, IM, PCP) to not be.
  • Of those entities, PCP is the only one whose id is defined in the XML scheme with a uniqueName of pcp_id.

This causes _civicrm_api_get_entity_name_from_camel in api/api.php to return the incorrect name.

There's a precedent for writing an exception into that function (for entities with "U_F" in their name) so I wrote one here. This gets us from 10 tests failing to 1. I'll submit an update when I've got that test passing.

@digitlimit
Copy link
Author

@PalanteJon I would like to work on this with you.

@MegaphoneJon
Copy link
Contributor

@digitlimit Great!

I've reverted your reversion - "p_c_p" as the entity name will only make the testing suite angrier 😄

When I ran some of the tests manually through the API Explorer (e.g. making a "Get" request with no parameters) I could reload the page and get one or both of these errors:

Notice: Undefined index: p_c_p_id in civicrm_api3_generic_getfields() (line 111 of /home/jon/local/civicrm-buildkit/build/bmaster/modules/civicrm/api/v3/Generic.php).
Notice: Undefined index: p_c_p_id in _civicrm_api3_build_fields_array() (line 962 of /home/jon/local/civicrm-buildkit/build/bmaster/modules/civicrm/api/v3/utils.php).

Note that this was AFTER I reverted the field name.

To fix that, I also added this code (below):

diff --git a/api/api.php b/api/api.php
index e20c451..a7aafad 100644
--- a/api/api.php
+++ b/api/api.php
@@ -180,6 +180,11 @@ function _civicrm_api_get_entity_name_from_camel($entity) {
   if (!$entity || $entity === strtolower($entity)) {
     return $entity;
   }
+  // Handle PCP as a special case:
+  // https://github.com/civicrm/civicrm-core/pull/7878#issuecomment-219061074
+  else if ($entity == 'PCP') {
+    return 'pcp';
+  }
   else {
     $entity = ltrim(strtolower(str_replace('U_F',
           'uf',

Now we're down to one error:

  1. api_v3_SyntaxConformanceTest::testCreateSingleValueAlter with data set fix version #50 ('Pcp')
    api result array comparison failed checking if status_id was correctly updated

Do you have civicrm-buildkit installed? If so, you can run the unit tests on your own. This will let you know if a change you made fixed itself.

Meanwhile, I opened up the file at /tests/phpunit/api/v3/SyntaxConformanceTest.php and looked at the test. It's a long test! If you want to debug and see what's going on, this page will help: https://wiki.civicrm.org/confluence/display/CRMDOC/Testing

@JoeMurray
Copy link
Contributor

Heh Frank, as Release Manager this month, I'm trying to recruit people to help pare down the backlog of almost 100 PRs, some going back to last summer. I'm wondering if you would be able to help QA another PR if I got someone to QA this PR?

@digitlimit
Copy link
Author

Yes I do love to, dough I have been so much occupied lately due to office pressure but I am sure I can squeeze out some time.

On Jun 13, 2016, 5:12 PM, at 5:12 PM, Joe Murray notifications@github.com wrote:

Heh Frank, as Release Manager this month, I'm trying to recruit people
to help pare down the backlog of almost 100 PRs, some going back to
last summer. I'm wondering if you would be able to help QA another PR
if I got someone to QA this PR?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#7878 (comment)

@JoeMurray
Copy link
Contributor

@darrick would you be interested in reviewing this PR, as it combines your API and contribute interests?

@JoeMurray
Copy link
Contributor

@digitlimit we need a JIRA issue that explains the intent of this PR - could you make one? Thanks, Joe

@MegaphoneJon
Copy link
Contributor

@JoeMurray @darrick I've got this PR in my queue, actually. Sorry if
the Google docs don't reflect that! Also, this is more-or-less assigned
to https://issues.civicrm.org/jira/browse/CRM-18191.

@JoeMurray
Copy link
Contributor

Thanks, @PalanteJon - I've updated the Google Release doc with Issue # and assigned to you.

@eileenmcnaughton eileenmcnaughton changed the title Added an API for Personal Campaign Page CRM-19064 Added an API for Personal Campaign Page Jul 12, 2016
@eileenmcnaughton
Copy link
Contributor

test this please

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jul 13, 2016
… fn.

This add function is really wierd & blocking writing an api for pcp - this will get past issues in civicrm#7878
@eileenmcnaughton
Copy link
Contributor

Check the PR I just added (#8697) - that resolves your blocker issue. (NB if someone can QA that PR then it can be merged in advance of this one being completed)

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jul 13, 2016
… fn.

This add function is really wierd & blocking writing an api for pcp - this will get past issues in civicrm#7878
@mickadoo
Copy link
Contributor

mickadoo commented Sep 6, 2016

I'd like to have an API for Personal Campaign Pages and am willing to help getting this merged. I tried checking why the build failed on Jenkins but the link is broken?

Regarding the required changes - I saw this answer on stackexchange and it works for me when I tested it.

@MegaphoneJon
Copy link
Contributor

Jenkins re test this please

@MegaphoneJon
Copy link
Contributor

@mickadoo Unfortunately that post was by me. It "works for me" too - but it definitely fails on some tests it shouldn't. The good news is that we're past the point outlined by that answer.

@eileenmcnaughton
Copy link
Contributor

I think it passes if you merge first the patch in #8697)

seamuslee001 pushed a commit to eileenmcnaughton/civicrm-core that referenced this pull request Sep 15, 2016
… fn.

This add function is really wierd & blocking writing an api for pcp - this will get past issues in civicrm#7878
seamuslee001 pushed a commit to eileenmcnaughton/civicrm-core that referenced this pull request Sep 15, 2016
… fn.

This add function is really wierd & blocking writing an api for pcp - this will get past issues in civicrm#7878
@litespeedmarc
Copy link
Contributor

jenkins, retest this please

@seamuslee001
Copy link
Contributor

@litespeedmarc @colemanw there has already been a PR that has accomplished this #9049

@litespeedmarc
Copy link
Contributor

This is great then. I've went ahead & closed the JIRA. Can anyone close the PR?

@monishdeb
Copy link
Member

Closed in favor of #9049

@monishdeb monishdeb closed this Sep 27, 2016
@civicrm-builder
Copy link

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet