Page MenuHomePhabricator

Parsoid extension page endpoints should not redirect to latest revision
Closed, ResolvedPublic

Description

Context:
The Parsoid extension implements a REST endpoints for retrieving page content. This API is not exposed publically on WMF sites, but only used internally by RESTbase. It is not considered a stable API.

Current situation:
If the request only specifies the page, the endpoint will respond with a redirect to a URL that also specifies the latest revision. E.g.

https://mywiki.example/w/rest.php/test.wikipedia.org/v3/page/pagebundle/Dog

will redirect to

https://mywiki.example/w/rest.php/test.wikipedia.org/v3/page/pagebundle/Dog/12345

This is good for caceability, but bad for the performance of individual requests, since it requires two round trips instead of one.

Problem:
This is getting in the way of running parsoid restbase code in proxy mode (i.e. storage disabled, T344945): when serving a request for e.g. /test.wikipedia.org/v3/page/html/Dog, restbase has to make two calls to the backend - one based on the title, and the another one to follow the redirect. It would be simpler and more efficient if /w/rest.php/test.wikipedia.org/v3/page/html/Dog would just return the current content.

Proposed solution:
In ParsoidHandler::tryToCreatePageConfig, remove the following code:

	if ( !$html2WtMode && $wikitextOverride === null && !$hasOldId ) {
		// Redirect to the latest revid
		throw new ResponseException(
			$this->createRedirectToOldidResponse( $pageConfig, $attribs )
		);
	}

Event Timeline

Change 971308 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/core@master] Parsoid endpoints should not redirect to latest version

https://gerrit.wikimedia.org/r/971308

Change 971309 had a related patch set uploaded (by Daniel Kinzler; author: Daniel Kinzler):

[mediawiki/services/parsoid@master] Don't expect parsoid endpoints to redirect

https://gerrit.wikimedia.org/r/971309

Change 971308 merged by jenkins-bot:

[mediawiki/core@master] Parsoid API should return latest version instead of redirecting to it

https://gerrit.wikimedia.org/r/971308

Change 971309 merged by jenkins-bot:

[mediawiki/services/parsoid@master] Don't expect parsoid endpoints to redirect

https://gerrit.wikimedia.org/r/971309

Change 972001 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.19.0-a5

https://gerrit.wikimedia.org/r/972001

Change 972001 merged by jenkins-bot:

[mediawiki/vendor@master] Bump wikimedia/parsoid to 0.19.0-a5

https://gerrit.wikimedia.org/r/972001

ABreault-WMF assigned this task to daniel.