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

dev/core#2779 - Specify row fields to fetch in Api4 OAuthSysToken.Refresh #21224

Merged
merged 1 commit into from
Aug 23, 2021

Conversation

ufundo
Copy link
Contributor

@ufundo ufundo commented Aug 23, 2021

Overview

Fix for https://lab.civicrm.org/dev/core/-/issues/2779

Before

Api4 action implementation was broken by this update to underlying BasicBatchAction class interface https://lab.civicrm.org/dev/core/-/commit/29ab318b684a79f4cdedde2bf0417775d4be5523

After

Previous functionality restored

Technical Details

The required fields from the OAuthSysToken table for the batch action are now explicitly specified using getSelect() method. Previously it fetched all using a wildcard "*" but I don't think this is possible any more. If the method needed additional fields they would need to be added to the selectFields array

@civibot
Copy link

civibot bot commented Aug 23, 2021

(Standard links)

@civibot civibot bot added the master label Aug 23, 2021
@demeritcowboy
Copy link
Contributor

Also if this stopped working in 5.40 then the base branch for this PR should be 5.41 (because that's the standard procedure for backporting to recent breakage). Sorry I forgot to mention that in the lab ticket. It might work to just change that in the PR settings here but it usually breaks it. I'll try it.

@demeritcowboy demeritcowboy changed the base branch from master to 5.41 August 23, 2021 15:23
@civibot civibot bot added 5.41 and removed master labels Aug 23, 2021
@demeritcowboy
Copy link
Contributor

Yep that broke it.
You should be able to do this:

git fetch upstream 5.41      -- assuming you've used "upstream" for https://github.com/civicrm/civicrm-core.git
git reset --hard upstream/5.41
[ Then redo your changes. ]
git commit -a -m "implement-basicbatchaction-getselect"
git push -f

@ufundo ufundo force-pushed the oauth-systoken-refresh-fix branch 2 times, most recently from 671ed43 to afc100a Compare August 23, 2021 16:38
@ufundo
Copy link
Contributor Author

ufundo commented Aug 23, 2021

Thanks @demeritcowboy . I think third-time-lucky I may have just managed that cleanly :)

@demeritcowboy
Copy link
Contributor

Yep looks good - thanks!

@demeritcowboy demeritcowboy added the merge ready PR will be merged after a few days if there are no objections label Aug 23, 2021
@seamuslee001
Copy link
Contributor

Merging based on @demeritcowboy 's review and @totten 's supportive comments in MM https://chat.civicrm.org/civicrm/pl/ie5d7s6is3dmfj5nycd81s6igo

@@ -38,10 +38,15 @@ class Refresh extends BasicBatchAction {

private $syncFields = ['access_token', 'refresh_token', 'expires', 'token_type'];
private $writeFields = ['access_token', 'refresh_token', 'expires', 'token_type', 'raw'];
private $selectFields = ['id', 'client_id', 'access_token', 'refresh_token', 'expires', 'token_type', 'raw'];
Copy link
Member

@totten totten Aug 23, 2021

Choose a reason for hiding this comment

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

I agree this change is good and necessary to address the regression.

Just to note that the select-list is now smaller than it was before.

$ cv api4 OAuthSysToken.getFields -T +s name

+---------------------+
| name                |
+---------------------+
| id                  | yes
| client_id           | yes
| token_type          | yes
| access_token        | yes
| expires             | yes
| refresh_token       | yes
| raw                 | yes
| tag                 | no longer
| grant_type          | no longer
| scopes              | no longer
| resource_owner_name | no longer
| resource_owner      | no longer
| error               | no longer
| created_date        | no longer
| modified_date       | no longer
+---------------------+

(Annotations: "yes" - restored as part of the list; "no longer" - would've matched * but no longer matches the list)

AFAICS, this list does cover the most important fields for a typical refresh. I can't spot/think of any specific problems with the smaller list. Just noting the change in case there are edgey issues later or in case it triggers any thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.41 merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants