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

[REF][PHP8.2] Avoid dynamic properties in civicrm_api3 class #25253

Merged
merged 1 commit into from
Jan 2, 2023

Conversation

braders
Copy link
Contributor

@braders braders commented Jan 1, 2023

Overview

Avoid dynamic properties in civicrm_api3 class.

Before

Several properties set and retreived dynamically, which is deprecated in PHP 8.2. See https://lab.civicrm.org/dev/core/-/issues/3833 for context.

After

The properties are defined upfront, and are not dynamic.

Technical Details

  • I made local public. It felt like there could be use-cases for third-party code to be able to see whether an API3 object is local or not. Furthermore, the property needs to be public as it is used in tests.
  • input, lastResult, uri, key, api_key, referer and useragent are also public. Some of these are also used by tests, but I also gathered that given how widely used civicrm_api3 is in the ecosystem there may well be use-cases where these are being read. That said, I'm not sure we really want to be advertisting these as part of the public API, and so I have marked them as @internal.
  • cfg and currentEntity felt very implementation specific and so have been made protected.

I've also changed the initial value of lastResult set in the constructor, to match the type it has elsewhere in the class (once the request has been made)

Happy to hear arguments for why any of these should change.

Comments

Reading through the code I couldn't really understand what $this->input is doing, and I suspect it's a bit buggy. Given everything is moving to APIv4 it probably doesn't warrant too much time spent looking into it, and for this PR I just wanted to get the dynamic properties righted out.

@civibot
Copy link

civibot bot commented Jan 1, 2023

(Standard links)

@civibot civibot bot added the master label Jan 1, 2023
@braders braders force-pushed the api3-properties branch 2 times, most recently from ed52372 to ad66cb2 Compare January 1, 2023 18:56
@braders
Copy link
Contributor Author

braders commented Jan 1, 2023

Test this please

@seamuslee001
Copy link
Contributor

This seems fine

@seamuslee001 seamuslee001 merged commit 4e75e86 into civicrm:master Jan 2, 2023
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