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

Urlencode branch name #1275

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Urlencode branch name #1275

merged 1 commit into from
Apr 18, 2024

Conversation

bgrgicak
Copy link
Collaborator

@bgrgicak bgrgicak commented Apr 18, 2024

Fixes #1260

What is this PR doing?

It ensures that the WordPress pull request test page can fetch the correct PR data.

What problem is it solving?

When a branch name has special characters like #, GitHub API requests may not work as intended.

How is the problem addressed?

By encoding the branch name.

Testing Instructions

  • Checkout this branch
  • Start a local PHP server
cd packages/playground/website/public
docker run -d -p 8787:80 -v "$PWD":/var/www/html php:8.0-apache

@adamziel
Copy link
Collaborator

Great find @bgrgicak, thank you!

@adamziel adamziel merged commit 6067c01 into trunk Apr 18, 2024
5 checks passed
@adamziel adamziel deleted the fix/1260-url-encode-branch-name branch April 18, 2024 13:08
@@ -50,7 +50,7 @@ public function streamFromGithubPR($organization, $repo, $pr, $workflow_name, $a
if (!$prDetails) {
throw new ApiException('invalid_pr_number');
}
$branchName = $prDetails->head->ref;
$branchName = urlencode($prDetails->head->ref);
$ciRuns = $this->gitHubRequest("https://api.github.com/repos/$organization/$repo/actions/runs?branch=$branchName")['body'];
Copy link
Collaborator

@dmsnell dmsnell Apr 19, 2024

Choose a reason for hiding this comment

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

we can also rely on http_build_query() to handle this for us.

$query = http_build_query( [ 'branch' => $prDetais->head->ref ], '', null,  PHP_QUERY_RFC3986 );
$url   = "https://...?{$query}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] GitHub integration [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP: artifact_not_found error
3 participants