8000 Documentation and changelog for v5.0.0 by irfan-dahir · Pull Request #670 · jikan-me/jikan · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ to change what they say, change the code or docs that produce them — not the f

Kept deliberately short — do NOT move CONTRIBUTING's branch workflow or API-STANDARD's rules here.

- Work happens on **`master`**, which hosts the v5 line (currently `5.0.0-beta`; the old `5.0.0`
- Work happens on **`master`**, which hosts the v5 line (currently `5.0.0`; the old `5.0.0`
branch name was retired after the v4→v5 migration). **`master` is the base for every PR.**
- `CLAUDE.md` is an `@AGENTS.md` import — keep them in sync by keeping the canonical text here.
- The backend-suite harness files (`.codex/`, `.gemini/`, `.cursor/`, … and the generated AGENTS.md
Expand Down
26 changes: 25 additions & 1 deletion CHANGELOG.md
8000
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ which changes a consumer can see.

---

## v5.0.0 — 2026-10-19

The first stable release of the `^5` line. **The code is identical to `5.0.0-rc.2`.** jikan-rest validated it on its Laravel 13 migration branch (403 tests, a 114-route crawl, and the news and "recently updated" endpoints that rc.1 had broken), and a live check of 14 MyAnimeList pages found no markup drift.

**Upgrading from v4? Read [UPGRADING.md](UPGRADING.md).** It lists every change to your code, and was checked by running v4 and v5 against the same 85 recorded pages. The sections below it record each pre-release in full.

### Breaking (from v4)
- **PHP 8.4.4 or later** — **you must** run it; Composer will not install on older versions. PHP 8.4.0–8.4.3 have an HTML5 parser bug that corrupts some emoji and rare characters.
- **The HTTP layer is Symfony's instead of `fabpot/goutte`** — **you must** run `composer update`. `new MalClient($client)` still takes a `Symfony\Contracts\HttpClient\HttpClientInterface`.
- **Removed:** `AnimeCard::getLicensors()` and `SeasonalAnime::getLicensors()` (read `Anime::getLicensors()`), `Model\Manga\MangaReviewer`, `Parser\Manga\MangaReviewerParser`, `Parser\Manga\MangaReviewScoresParser`, `Jikan\Goutte\GoutteWrapper` (now `Jikan\Http\HttpClientWrapper`), and `NewsListItemParser::getImage()` and `getIntro()`.
- **Many getters can return `null`** where a missing field used to be a `TypeError` — **you must** handle `null`. The list is in `UPGRADING.md` §3.
- **`getNewsList()` returns `Model\News\ResourceNewsList`**; the getters have the same names.
- **`Constants::SEARCH_MANGA_NOVEL` is now `8`** (it was `2`, which MyAnimeList reads as Light Novel); use `SEARCH_MANGA_LIGHT_NOVEL` for `2`.

### Added
- 11 content endpoints: `getArticle`, `getArticleSearch`, `getArticleTags`, `getArticlesByTag`, `getNews`, `getNewsByTag`, `getNewsSearch`, `getNewsTags`, `getPinnedArticles`, `getRecentArticles` and `getRecentNews`, each with its `Jikan\Request\*` class.
- Search constants for the anime types CM, PV and TV Special, the manga type Light Novel, and the manga statuses On Hiatus and Discontinued.
- `Jikan\Helper\Time`: relative and partial dates resolve against a PSR-20 clock (the system clock by default; pin it in tests with `Symfony\Component\Clock\Clock::set()`).

### Fixed
- Over forty parser fixes since v4, most found by running every endpoint against recorded MyAnimeList pages: pagination that never ended, lists that came back empty, dates in the wrong century or timezone, fields that were always `null`. See the pre-release sections below.

---

## v5.0.0-rc.2 — 2026-10-16

Release candidate 2. Bug fixes only since `5.0.0-rc.1`; the API is unchanged. jikan-rest found both problems while validating rc.1: three of its endpoints (`/anime/{id}/news`, `/manga/{id}/news` and `/manga/{id}/userupdates`) came back empty.
Expand Down Expand Up @@ -218,7 +242,7 @@ and Changed before upgrading**: the PHP floor is now 8.4.4, `AnimeCard::getLicen

---

## v5.0.0 — 2026-10-11
## v5.0.0-beta — 2026-10-11

First release on the `^5` line. Every `MalClient` method and `Jikan\Request\*` class from `^4` is still there, and
the v4→v5 diff adds 11 endpoints and replaces the HTTP layer. It also removes a few classes and methods and makes many
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ recordings and any test its requests are missing **fails with a hard error**
`audit_test_network_coupling`).

**Never commit directly to `master`.** Cut a feature branch from it and land
changes through a reviewed PR into `master`. The v5 line is tagged as it ships
(`v5.0.0-beta`); `5.0.0` was the pre-master branch name for that line and is no longer used.
changes through a reviewed PR into `master`. Releases are tagged on `master`
(`v5.0.0`, then the `5.0.x` patches); `5.0.0` was the pre-master branch name for that line and is no longer used.

Also read [`AGENTS.md`](AGENTS.md) before starting: it is the navigation map (what to read in what
order, where things live, the task router) — `CLAUDE.md` is just an `@AGENTS.md` import.
Expand Down
31 changes: 31 additions & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ does not explain on its own.
**Reason:** The endpoint must parse what the site actually serves. The featured pages remain the correct source for `getArticle`; the news index is the correct source for `getNewsList`. `ArticleParser::getViews()` and `News/Article` date getters were also stripping child nodes from the live DOM (`Parser::removeChildNodes` mutates the crawler), which broke any getter called after `getDate()` on the same parser instance — they now parse text without mutating.
**Out of scope, deliberately:** Featured articles that MAL no longer serves a field for — an article page without a view count now resolves `getViews()` to `null` (`ResourceArticle::getViews(): ?int`) rather than a fabricated number. `ArticleListItemParser::getViews()` stays `int` (related-article blocks on featured pages still serve counts; not under endpoint tests). News search/tags parsers and the news *item* page (`news/{id}`) were not re-aligned — `getArticle`'s source is the featured stream, and `news/{id}` blurbs are a separate layout. The eight `NewsListItemParserTest` cases were re-pointed at the recorded `news` index and un-skipped.

**Correction (2026-10-16):** this realignment covered only the main news index. A title's own news page (`/anime/{id}/_/news`, `/manga/{id}/_/news`), which `getNewsList()` also serves for `AnimeNewsRequest` and `MangaNewsRequest`, has a different layout (no `div.news-unit`), so those requests returned an empty list from `v5.0.0-beta` until jikan#661. `ResourceNewsListParser` now reads both layouts, and the corpus has recorded pages for each. A realignment of one layout needs a recorded page for **every** page the method serves.

## Deprecation and release policy

### Deprecated title accessors stay available indefinitely — no removal version
Expand All @@ -158,6 +160,8 @@ does not explain on its own.
**Reason:** jikan's public surface is a compatibility superset — the v4→v5 diff removed nothing. Setting removal dates on these stubs would force a breaking consumer migration at some future major for accessors that cost nothing to keep and that a long tail of ^4-era consumers still call.
**Impact:** `DEPRECATIONS.md` §1 rows keep `not scheduled`; the deprecated accessors remain in code and in the standard. Nothing in the API is scheduled for removal.

**Correction (2026-10-19):** the claim that "the v4→v5 diff removed nothing" is wrong for the API as a whole. Computed from the source of `v4.0.13` and v5, v5 removes 4 classes (`MangaReviewer`, `MangaReviewerParser`, `MangaReviewScoresParser`, `GoutteWrapper`) and 6 methods, and changes 78 return types, most to nullable. What is true, and what this decision rests on: **none of the deprecated title accessors was removed.** The full list is in `UPGRADING.md`.

## Documentation standards

### API-STANDARD.md approved as written; it becomes the review benchmark
Expand Down Expand Up @@ -210,3 +214,30 @@ fixed (`getAnimeSearchAlt` return type).
---

_Last updated: 2026-10-12_< 10BC8 /td>

## Dates and times

### Every date is UTC; a day printed without a time is UTC midnight
**Date:** 2026-10-15
**Source:** internal-decision (maintainer, after jikan-rest#567 and a side-by-side run of v4 and v5)
**Decision:** Every date a model returns is in UTC. A day MyAnimeList prints without a time (an episode's "Aired", an anime card's start date) is UTC midnight of that day, as `Anime::getAired()` already was. Text that carries a broadcast time ("Apr 7, 2013, 01:00 (JST)") is converted from Japan time, because it is a real instant. A "(JST)" marker is stripped, never left for PHP to read as an offset. `ModelInvariants` fails any model date whose offset is not 0.
**Reason:** The same fact had two forms: the episode list and the single-episode page gave `+00:00` and `+09:00` for one air date (jikan-rest#567), and anime-card dates were Japan midnight converted to UTC, so "Oct 2" read as the day before and a year-only "2027" as 31 December 2026. Consumers sort and compare these. Rejected: Japan midnight everywhere, which keeps one wrong form instead of one right one.
**Impact:** `AnimeEpisodeParser::getAired()`, `AnimeCardParser::getAirDates()` (2,049 snapshot dates moved by exactly +9 hours); the `non-utc-date` invariant. Listed under Changed in the changelog. Dates with a time component are unchanged.

## Missing and unreadable data

### A field MyAnimeList leaves out is null; a row that cannot be read is an error
**Date:** 2026-10-16
**Source:** internal-decision (maintainer: `getMembers()` on 2026-10-15; the rest in review of PR #658 and #668)
**Decision:** When a page does not show a value, its getter returns `null` and says so in its return type (31 getters were made nullable). An unknown total printed as `?` is `null`, never `0`. `AnimeCard::getMembers()` returns `null` for a card with no member count. A row or section that is present but cannot be parsed raises an exception, which `MalClient` reports as `ParserException`; parsers do not catch everything and return an empty list.
**Reason:** A getter declared non-null while its parser returns null is a `TypeError` waiting for the right page, and a catch-all that returns `[]` turns a markup change into a silent empty page (jikan#663: a bare `-` cell emptied a whole page, next to a `hasNextPage()` that could be true). Failing loudly is what makes drift visible. Rejected: skipping the bad row, which hides drift the same way; returning `0` for an unknown total, which cannot be told from a real zero.
**Impact:** 31 getters and `getMembers()` nullable (breaking, listed in `UPGRADING.md`); `Parser::parseProgress()`; `getResults()` of the recently-updated parsers no longer catches everything. A page that has no table still has no rows.

## Reviews

### Review scores are the reviewer's overall rating; the helpful count is the total of the reactions
**Date:** 2026-10-15
**Source:** external constraint (MyAnimeList's 2022 review redesign), maintainer decisions on the two options
**Decision:** `getAnimeScores()` and `getMangaScores()` return the reviewer's overall rating (`getOverall()`); the category getters (story, animation, art, sound, character, enjoyment) return `null`. `getHelpfulCount()` returns the review's total reactions (all seven kinds, including "Funny" and "Confusing"); `getReactions()` has the breakdown.
**Reason:** The page shows one "Reviewer's Rating" and reactions; the per-category ratings and the "helpful" votes no longer exist, and these methods had been failing or returning 0. Rejected: removing the methods (a breaking removal for something that can still answer), and counting only approving reactions (a judgement MyAnimeList does not make).
**Impact:** `AnimeReviewScores` and `MangaReviewScores` are built with `fromOverall()`; `MangaReviewScoresParser` was removed. Listed in the changelog and `UPGRADING.md`.
24 changes: 11 additions & 13 deletions PLAN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Jikan v5 — Improvement Plan

Status: draft, agreed 2026-10-13. Constraints decided by the owner:
Status: agreed 2026-10-13 and largely delivered in 5.0.0 (see CHANGELOG.md); the unchecked boxes are the v5.x backlog. Constraints decided by the owner:

- **Stay on Symfony DomCrawler** for parsing. No engine swap.
- **`MalClient` facade stays stable** (methods, `Request\*`, `Model\*` getters, exceptions).
Expand Down Expand Up @@ -56,20 +56,19 @@ Figures marked *estimate* come from reading the code, not from measurement.
## 1. v5.x, no breaking changes

- [x] PHPStan level 6 with a baseline (`composer phpstan`, part of `composer quality`; `phpstan-baseline.neon`
holds 429 pre-existing findings; regenerate with `composer phpstan:baseline` after fixing some).
holds the pre-existing findings and only shrinks; regenerate with `composer phpstan:baseline` after fixing some).
Level 0 alone found real bugs, fixed with regression tests (they fail on the old code):
`MalClient::getNewsList()` read a non-existent `$this->ghoutte` (always failed); both `Jpg::__toString()`
called a method that does not exist; `AnimeCardParser::getMembers()` fell off the end (TypeError that
bypassed `catch (\Exception)`), now throws a RuntimeException so it surfaces as a ParserException.
Unfixed, see "Open decisions" below.
bypassed `catch (\Exception)`), now returns `null` (a card can have no member count; 5.0.0-beta.3).
- [x] Live drift canaries: `scripts/drift_check.php --live` (14 pages: anime x3, manga x2, character, person,
club, producer, genre, seasonal, schedule, search, top; GET only, 3.5 s apart, `--live` required, not part of
`composer test`; `--json` / `--compare` flag a null-rate rise of >10 points). **First live run
(2026-10-13): 14 of 14 parsed, no failures.** Null rates: nearly all 0-8%; producer/1 is 27.7% (probably
normal for that page, but it is the number to watch). Scheduling it (cron/CI) is not done; that needs an
owner decision on where it runs.
normal for that page, but it is the number to watch). It runs weekly in CI (`.github/workflows/drift.yaml`, Mondays
04:00 UTC) and on demand.
Same run answers the `getMembers()` question: the card parser's no-count path did not trigger on live
producer, genre, seasonal or top pages, so a missing count looks rare; it stays a catchable exception.
producer, genre, seasonal or top pages, so a missing count looks rare; `getMembers()` returns `null` for it.
- [x] Live probe (one-off, 8 requests): MAL sends **no ETag or Last-Modified** and `Cache-Control: no-cache`
(it does set MALSESSIONID / mal_cache_key / is_logged_in cookies), so conditional-request revalidation
is not possible. Anime, manga and top-anime parse fine with the cookie jar cleared before every request,
Expand Down Expand Up @@ -109,15 +108,14 @@ Figures marked *estimate* come from reading the code, not from measurement.
- [ ] Opt-in lenient parse mode (`ParseMode`): strict stays default; lenient records diagnostics for
optional fields instead of failing the whole entity.

## Open decisions (need the owner)
## Open decisions (all resolved for 5.0.0)

- ~~Delete the dead `Model\Manga\MangaReviewer` and `Parser\Manga\MangaReviewerParser`~~ **Done** (owner
decision): they extended classes deleted in d8ec60b and nothing referenced them.
- `Parser\Reviews\ReviewerParser::getAnimeScores()` and `AnimeReviewParser::getAnimeScores()` instantiate
`AnimeReviewScoresParser`, which does not exist (so those two methods always fail), and
`Model\Anime\AnimeReviewScores::fromParser()` type-hints it. Restore the class or remove the methods?
- `getMembers()` now throws when no member count is found; should it return 0 / null instead?
- Snapshots add 7 MB to the repo. Acceptable, or keep them out of the repo?
- ~~`getAnimeScores()` called a parser that does not exist~~ **Done**: MyAnimeList shows only the reviewer's overall
rating now, so `getAnimeScores()` and `getMangaScores()` return that and the category getters return `null` (5.0.0-beta.3).
- ~~`getMembers()` throws when no member count is found~~ **Done**: it returns `null` (5.0.0-beta.3).
- ~~Snapshots add 7 MB to the repo~~ **Done**: they live in the jikan-fixtures repo.

## Test suite plan (audit 2026-10-14)

Expand Down
4 changes: 2 additions & 2 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Upgrading from v4 to v5

For code on `jikan-me/jikan ^4`. v5 is currently a release candidate (`5.0.0-rc.2`); this guide is for moving to it and to `5.0.0` when that ships. For the complete list of changes, including fixes that only affected earlier v5 pre-releases, read the [changelog](CHANGELOG.md).
For code on `jikan-me/jikan ^4`. This guide is for moving to v5 (`5.0.0` and later). For the complete list of changes, including fixes that only affected earlier v5 pre-releases, read the [changelog](CHANGELOG.md).

**In short:** `MalClient` and all its existing methods and request classes still work as before. What changes is the PHP version, the HTTP libraries underneath, a handful of removed classes, and many getters that can now return `null` where they used to throw.

Expand All @@ -16,7 +16,7 @@ For code on `jikan-me/jikan ^4`. v5 is currently a release candidate (`5.0.0-rc.
PHP 8.4.0–8.4.3 are refused on purpose. They have a bug in PHP's own HTML5 parser that can corrupt emoji and rare characters, which makes `json_encode()` fail on a model.

```bash
composer require jikan-me/jikan:^5.0@RC # "@RC" until a stable 5.0.0 exists
composer require jikan-me/jikan:^5.0
composer update # also removes fabpot/goutte
```

Expand Down
Loading
0