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

Add v4 pledge api #19297

Merged
merged 2 commits into from
Jan 19, 2021
Merged

Add v4 pledge api #19297

merged 2 commits into from
Jan 19, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Add v4 api for pledge

Before

no api
After

tada

Technical Details

I tried to add this in #19289 to support that change but it seems to be tricksie so trying to add the api first (& work through any test issues)

Comments

@civibot
Copy link

civibot bot commented Dec 31, 2020

(Standard links)

@civibot civibot bot added the master label Dec 31, 2020
@eileenmcnaughton
Copy link
Contributor Author

test this please

1 similar comment
@eileenmcnaughton
Copy link
Contributor Author

test this please

@colemanw
Copy link
Member

colemanw commented Jan 4, 2021

not ok 137 - Error: api\v4\Entity\ConformanceTest::testConformance with data set "Pledge" ('Pledge')
Maybe missing sample data for Pledge?

@eileenmcnaughton
Copy link
Contributor Author

@colemanw maybe - I figured fixing up the schema made sense - #19309 since it's getting as far as a db error

@eileenmcnaughton
Copy link
Contributor Author

test this please

foreach ($fields as $name => $field) {
// If a default value in the api field is different than in core, the api should override it.
if (!isset($params[$name]) && !empty($field['default_value']) && $field['default_value'] != \CRM_Utils_Array::pathGet($coreFields, [$name, 'default'])) {
protected function fillDefaults(&$params): void {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw @totten @seamuslee001 thoughts on this change?

The previous code only added the default to the params if it was not the same as the db default. However, in pledge BAO it really needs those values to be set in params to do calculations. I could make the pledge BAO do the work of looking up the defaults for apiv4 but I couldn't see why it would make sense to not set them here. It seems to have been committed as part of 'add apiv4' which doesn't give too many clues - especially as much of that has since been refactored. I did have to ensure inappropriate-to-php defaults were not added to the php defaults which I did further down

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton It feels wrong to me to pass in db defaults. I think this could lead to bugs or problems because now every BAO would have no way of knowing the difference between an empty param and a param that was passed in explicitly with the default value.
Generally I would think it's not a good idea to impact every Api in this way because of one oddball BAO, and preferable to fix the oddball.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm OK - you arrived at a different conclusion about what makes sense than I did - but I'll switch over

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@colemanw @seamuslee001 it's passing!

@colemanw
Copy link
Member

Awesome!

@colemanw colemanw merged commit 2e9ab61 into civicrm:master Jan 19, 2021
@colemanw colemanw deleted the pledge branch January 19, 2021 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants