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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ext/oauth-client/Civi/Api4/Action/OAuthSysToken/Refresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.

private $providers = [];

public function __construct($entityName, $actionName) {
parent::__construct($entityName, $actionName, '*');
parent::__construct($entityName, $actionName);
}

protected function getSelect() {
return $this->selectFields;
}

protected function doTask($row) {
Expand Down