Media path `{n}` token queries the posts collection and matches the wrong field
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
Research direction
Read endpoint-media/lib/utils.js:39, index.js:36, and media-type-count.js:19,34 to trace the collection and field used for media counts. Start by adding a regression case in test/unit/media-type-count.js with a media-type property and a media document; also check the promise handling and self-exclusion behavior described in the issue. Done means the count returns the expected result for media without matching unrelated posts, with tests covering both reported faults.
Written by the indexing model from the issue text.
Description
endpoint-media/lib/utils.js:39 passes collections.get("posts") to mediaTypeCount.get(),
though index.js:36 registers media. And media-type-count.js:19 reads
properties["media-type"] while line 34 matches properties.post-type, which media
documents don't have.
Measured with one photo in media and the properties getMediaProperties() produces: 0 via
both collections, expected 1 — the two faults are independent, so neither fix works alone.
It isn't always 0, though: where a post-type shares the uploaded media-type's name the
count is that post count (18 photo posts, on my site). A plausible wrong number rather than
an obvious zero.
Two smaller things in the same file: line 9's !postsCollection.count() is an unawaited
promise, always truthy — what you removed from the posts copy in a3544343 — and there's no
uid/url self-exclusion (cf. 2634ac0b, #746).
test/unit/media-type-count.js doesn't catch any of it: it passes no media-type, so the
$match is null and matches the fixture's missing field. It stays green after fixing the
field name too.
No design question here — I can PR this whenever you want it.
- Dominant language
- JavaScript
- Stars
- 392
- Forks
- 39
- Avg merge
- 22h 29m
- Merged PRs (30d)
- 25
Getting set up
- Ships a 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 getindiekit/indiekit
-
Docs: no path for someone who just wants to try IndiekitPossibly taken @rmdes claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
getindiekit/indiekit#1028 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
getindiekit/indiekit#1030 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
getindiekit/indiekit#1026 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 1-2 days Newbie friendliness 48/100
getindiekit/indiekit#1025 ·
Maintainers usually reply within 1 day
-
plugin-syndicator
Difficulty 4/5 3-5 days Newbie friendliness 48/100
getindiekit/indiekit#1022 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in getindiekit/indiekit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
scratchfoundation/scratch-editor#754 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 96/100
google/site-kit-wp#14102 ·
Maintainers usually reply within 2 days
-
area:growth priority:P1 type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
tecnologiasantos/bogoboom#66 ·
Maintainers usually reply within 1 day
-
desktop docs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
npm/write-file-atomic#245 ·