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

Bug #18469: fix Link::serialize method #20020

Merged
merged 8 commits into from
Nov 23, 2023

Conversation

ggh2e3
Copy link
Contributor

@ggh2e3 ggh2e3 commented Oct 20, 2023

Q A
Is bugfix? ✔️
New feature? ❌
Breaks BC? ❌
Fixed issues #18469

Hi, I applied the fix proposed above with some unit tests. Hope it helps

@samdark samdark added this to the 2.0.50 milestone Oct 20, 2023
@samdark samdark requested review from a team October 20, 2023 13:46
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (01f3983) 48.02% compared to head (ab168e7) 48.02%.

Files Patch % Lines
framework/web/Link.php 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20020      +/-   ##
==========================================
- Coverage   48.02%   48.02%   -0.01%     
==========================================
  Files         445      445              
  Lines       43890    43889       -1     
==========================================
- Hits        21078    21077       -1     
  Misses      22812    22812              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -66,7 +66,11 @@ public static function serialize(array $links)
$link[$i] = $l instanceof self ? array_filter((array) $l) : ['href' => $l];
}
$links[$rel] = $link;
} elseif (!$link instanceof self) {
}
if ($link instanceof self) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's refactor this method to a recursive call instead.

Copy link
Contributor Author

@ggh2e3 ggh2e3 Oct 25, 2023

Choose a reason for hiding this comment

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

Are you referring to line 66(or maybe the whole method)?
I'd replace the second loop with this recursive call $link = self::serialize($link); in order to remove it

@rob006
Copy link
Contributor

rob006 commented Oct 25, 2023

It is only me, or these test do not have sense at all? :P

@bizley
Copy link
Member

bizley commented Oct 25, 2023

Heh, yes, this is what I thought as well, so I had to go through the code again.
@ggh2e3 could you refactor the tests to not confuse? For example this looks like a config for a single object so the expected result is weird.

@ggh2e3
Copy link
Contributor Author

ggh2e3 commented Oct 29, 2023

Yep, I can refactor the tests to avoid confusion.

@ggh2e3 ggh2e3 requested a review from bizley November 3, 2023 09:00
@ggh2e3
Copy link
Contributor Author

ggh2e3 commented Nov 12, 2023

@bizley is it fine now?

framework/web/Link.php Outdated Show resolved Hide resolved
framework/web/Link.php Outdated Show resolved Hide resolved
@samdark samdark merged commit 6fdb805 into yiisoft:master Nov 23, 2023
49 of 50 checks passed
@samdark
Copy link
Member

samdark commented Nov 23, 2023

👍

@ggh2e3 ggh2e3 deleted the 18469-bug-link-fix branch December 19, 2023 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants