Improve removal of h-card if it doesn't match page URL
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 54/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- php
- Domain
- backend-api-design
Research direction
Start with the filtering logic in lib/XRay/Formats/Mf2.php at the linked lines and compare its behavior with the supplied example. Add a regression test for an h-card with no url property, then verify that such a card is removed while non-h-cards and h-cards whose url matches the page URL remain.
Written by the indexing model from the issue text.
Description
This bit of code is intended to remove h-cards from implicit feeds of h-* when parsing:
It appears the logic doesn't work quite right if the h-card has no url property. In this example, the parsed mf2 is (snipped out parts not needed for this example):
"items": [
{
"type": [
"h-entry"
],
"properties": {
"url": [],
"published": [],
"author": [],
"like-of": []
},
"lang": "en"
},
{
"type": [
"h-card"
],
"properties": {
"name": [
"RSS \u00b7 Webmentions"
]
},
"lang": "en"
}
],
This is a bit more verbose in part to make it easier to follow, but I think the array_filter should be something like:
$tmpmf2 = array_filter($items, function($item) use($url) {
if (!in_array('h-card', $item['type'])) {
// not an h-card; keep it in the result array
return true;
}
if (
isset($item['properties']['url'][0])
&& $item['properties']['url'][0] == $url
) {
// h-card's u-url matches page URL; keep it in the result array
return true;
}
// h-card u-url does *not* match page URL (or it has no u-url); remove it from result array
return false;
});
I haven't written a unit test for this yet, otherwise I would make it a PR. It did work in my local testing with the specific example link above.
I might be able to make a PR in the near future, or if someone else wants to take it on, feel free!
- Dominant language
- PHP
- Stars
- 96
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aaronpk/XRay
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
bug-report bug-report-triage customer report
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Codeinwp/tweet-old-post#1177 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 60/100
sonata-project/dev-kit#3119 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
🧠 Admin
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day