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 E_WARNING access array offset on null when creating new contribution page #22373

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

demeritcowboy
Copy link
Contributor

Overview

Before

  1. Use php7.4+
  2. Create a new contribution page.
  3. Can just fill out the minimum needed.
  4. Click Continue
  5. Fill out the amounts - again can just do the minimum needed.
  6. Click Save And Next - Warning: Trying to access array offset on value of type null in CRM_Member_Form_MembershipBlock->setDefaultValues() (line 40 of ...\CRM\Member\Form\MembershipBlock.php).

After

Technical Details

Line 38 can return null if there is no membership block yet

Comments

@civibot
Copy link

civibot bot commented Jan 5, 2022

(Standard links)

@eileenmcnaughton
Copy link
Contributor

I'm thinking the issue is defaults isn't an array? If this works for you I'm fine with it but I suspect we should ensure defaults is an array

@demeritcowboy
Copy link
Contributor Author

It isn't an array - it's null. But my thinking was even if it was an empty array it would still give a notice here, so this works either way and then I don't have to look around for who else calls that function expecting null.

@eileenmcnaughton
Copy link
Contributor

Ok - it just feels like we might get more grumpiness in php 8 or something - but we can deal with that when it comes!

@demeritcowboy
Copy link
Contributor Author

Fair point - maybe php 9 since php 8 seems ok with it so that buys at least a month.

Oh by the way php 9 is going back to $x = array('a' => 'b'); syntax.
... Kidding!

@eileenmcnaughton
Copy link
Contributor

lol!

@demeritcowboy
Copy link
Contributor Author

jenkins retest this please

@eileenmcnaughton eileenmcnaughton merged commit f997360 into civicrm:master Jan 5, 2022
@demeritcowboy demeritcowboy deleted the memwarn branch January 5, 2022 14:03
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.

2 participants