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

Fix signature on BAO_Product::add to make ids optional #12523

Merged
merged 2 commits into from
Jul 21, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jul 20, 2018

Overview

Fix signature on BAO_Product::add to make ids optional

Partial reviewer's commit from #12437 but I went a bit further with removing $ids from the signature

Before

$ids is a required field on Product::add - which is inconsistent with our standards

After

$ids is removed. $params is not passed as reference - this is our preferred signature

Technical Details

Since the BAO_Product::add function is new we don't need to support $ids. The only code place we call this is

  $premium = CRM_Contribute_BAO_Product::add($params);

    CRM_Core_Session::setStatus(
      ts("The Premium '%1' has been saved.", array(1 => $premium->name)),
      ts('Saved'), 'success');
  }

so we don't need the (non-std) behaviour of passing $params as a reference

I also renamed BAO_Product::add to create (which is a bit more standard) so it would not have to have the same signature as ManagePremiums which inherits

Comments

@mattwire can you OK my additional change here

@civibot
Copy link

civibot bot commented Jul 20, 2018

(Standard links)

@eileenmcnaughton eileenmcnaughton force-pushed the product branch 2 times, most recently from bb769f0 to 207d537 Compare July 20, 2018 09:09
@JoeMurray
Copy link
Contributor

I agree in principal with the changes introduced by Eileen.

@colemanw
Copy link
Member

@eileenmcnaughton one style error:

Product.php:92, ParamNameNoMatch, Priority: High
--
Doc comment for parameter $ids does not match actual variable name

…gether

This is actually a new function so we don't need to respect the signature of the deprecated one
@eileenmcnaughton eileenmcnaughton merged commit a89632b into civicrm:master Jul 21, 2018
@eileenmcnaughton eileenmcnaughton deleted the product branch July 21, 2018 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants