Skip to content

Commit

Permalink
Remove public endpoints for editing pages (#1326)
Browse files Browse the repository at this point in the history
* Removes the editing capability that is not used

Bug: T336851
Change-Id: I0b6af8dd1c6944c755e1df0df79bb1bdb017305d
  • Loading branch information
brightbyte committed Sep 19, 2023
1 parent 86b3011 commit eac1d08
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 880 deletions.
3 changes: 0 additions & 3 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ services:
apiUriTemplate: http://localhost/w/api.php
# XXX Check the base RESTBase URI
baseUriTemplate: "{{'http://{domain}:7231/{domain}/v1'}}"
/page_save:
x-modules:
- path: sys/page_save.js
/parsoid:
x-modules:
- path: sys/parsoid.js
Expand Down
32 changes: 1 addition & 31 deletions doc/MediaWikiPageContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,7 @@ Get tid range for revid from revision table
- save the revision info to the rev table
- return the requested property
- else: return error

# Saving modified page content

## `POST /{name}`
Regular save API.

**Vars**:

- `html` & `data-mw`, or `wikitext`.
- oldid the edit is based on

### Short-term implementation
- For HTML: convert to wikitext using Parsoid
- Try to save wikitext through the PHP API, forward cookies
- on success:
- save back new revision with returned oldid
- kick off request for new revision
- else: return failure message

### Longer term implementation
- Validate HTML & data-mw using separate service
- HTTP transaction:
- CAS on revision table -- need this to be structured per-page
- using tid, doesn't necessarily need to fill in oldid yet (but
simpler if it does)
- *then*: save individual properties (idempotent as all versioned)


## Simple save API: `PUT /{name}/{html|wikitext}`
Touching only HTML or wikitext. Flow very similar as above.


## New revision request flow
- edit conflicts *per name/page* can be detected on the page bucket
({name}/mw-revision)
Expand Down
3 changes: 0 additions & 3 deletions projects/sys/default.wmf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ paths:
/post_data:
x-modules:
- path: sys/post_data.js
/page_save:
x-modules:
- path: sys/page_save.js
/parsoid:
x-modules:
- path: sys/parsoid.js
Expand Down
30 changes: 0 additions & 30 deletions sys/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,6 @@ function buildQueryResponse(apiReq, res) {
}
}

function buildEditResponse(apiReq, res) {
if (res.status !== 200) {
throw apiError({
info: `Unexpected response status (${res.status}) from the PHP action API.`
});
} else if (!res.body || res.body.error) {
throw apiError((res.body || {}).error);
}
res.body = res.body.edit;
if (res.body && !res.body.nochange) {
res.status = 201;
}
return res;
}

function findSharedRepoDomain(siteInfoRes) {
const sharedRepo = (siteInfoRes.body.query.repos || []).find((repo) => repo.name === 'shared');
if (sharedRepo) {
Expand Down Expand Up @@ -269,15 +254,6 @@ class ActionService {
.tapCatch(logError.bind(null, hyper));
}

edit(hyper, req) {
return this._doRequest(hyper, req, {
action: 'edit',
format: 'json',
formatversion: 2
}, buildEditResponse)
.tapCatch(logError.bind(null, hyper));
}

/**
* Fetch the site info for this project's domain.
*
Expand Down Expand Up @@ -380,18 +356,12 @@ module.exports = (options) => {
all: {
operationId: 'mwApiSiteInfo'
}
},
'/edit': {
post: {
operationId: 'mwApiEdit'
}
}
}
},
operations: {
mwApiQuery: actionService.query.bind(actionService),
mwRawApiQuery: actionService.rawQuery.bind(actionService),
mwApiEdit: actionService.edit.bind(actionService),
mwApiSiteInfo: actionService.siteinfo.bind(actionService)
}
};
Expand Down
180 changes: 0 additions & 180 deletions sys/page_save.js

This file was deleted.

Loading

0 comments on commit eac1d08

Please sign in to comment.