jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/396481 )

Change subject: Remove the `bodyOnly` spelling for the API parameter
......................................................................


Remove the `bodyOnly` spelling for the API parameter

This was deprecated in 2015 and replaced with `body_only`.  We don't
want to keep this backwards-compatibility cruft around forever, it's
time to get rid of it.

Change-Id: I5d1048087a7857a4fa000320ae01a36920563e1c
---
M lib/api/apiUtils.js
M lib/api/internal.js
M lib/api/routes.js
M lib/parse.js
M tests/mocha/api.js
5 files changed, 17 insertions(+), 36 deletions(-)

Approvals:
  jenkins-bot: Verified
  Arlolra: Looks good to me, approved



diff --git a/lib/api/apiUtils.js b/lib/api/apiUtils.js
index d2a5b13..2b855e3 100644
--- a/lib/api/apiUtils.js
+++ b/lib/api/apiUtils.js
@@ -444,8 +444,8 @@
        // See the comment in around `DU.applyPageBundle`
        DU.applyPageBundle(doc, { parsoid: { ids: {} }, mw: pb.mw });
        // No need to `DU.extractDpAndSerialize`, it wasn't applied.
-       var html = DU.toXML(res.locals.bodyOnly ? doc.body : doc, {
-               innerXML: res.locals.bodyOnly,
+       var html = DU.toXML(res.locals.body_only ? doc.body : doc, {
+               innerXML: res.locals.body_only,
        });
        apiUtils.wt2htmlRes(env, res, html, pb, contentmodel);
 };
@@ -466,8 +466,8 @@
        return DU.addRedLinks(env, doc)
        .then(function() {
                // No need to `DU.extractDpAndSerialize`, it wasn't applied.
-               var html = DU.toXML(res.locals.bodyOnly ? doc.body : doc, {
-                       innerXML: res.locals.bodyOnly,
+               var html = DU.toXML(res.locals.body_only ? doc.body : doc, {
+                       innerXML: res.locals.body_only,
                });
                apiUtils.wt2htmlRes(env, res, html, pb, contentmodel);
        });
diff --git a/lib/api/internal.js b/lib/api/internal.js
index cef8744..708f189 100644
--- a/lib/api/internal.js
+++ b/lib/api/internal.js
@@ -68,7 +68,7 @@
                res.locals.pageName = req.params.title || '';
                res.locals.oldid = req.body.oldid || req.query.oldid || null;
                // "body" flag to return just the body (instead of the entire 
HTML doc)
-               res.locals.bodyOnly = !!(req.query.body || req.body.body);
+               res.locals.body_only = !!(req.query.body || req.body.body);
                // "subst" flag to perform {{subst:}} template expansion
                res.locals.subst = !!(req.query.subst || req.body.subst);
                res.locals.envOptions = {
diff --git a/lib/api/routes.js b/lib/api/routes.js
index 7540504..a2a5f56 100644
--- a/lib/api/routes.js
+++ b/lib/api/routes.js
@@ -55,11 +55,9 @@
                res.locals.oldid = req.params.revision || null;
 
                // "body_only" flag to return just the body (instead of the 
entire HTML doc)
-               // RESTBase renamed this from 'bodyOnly' to 'body_only' in
-               // 1d9f5c45ec6, 2015-09-09.  Support the old name for 
compatibility.
-               res.locals.bodyOnly = !!(
-                       req.query.body_only || req.body.body_only ||
-                       req.query.bodyOnly || req.body.bodyOnly
+               // We would like to deprecate use of this flag: T181657
+               res.locals.body_only = !!(
+                       req.query.body_only || req.body.body_only
                );
 
                var opts = Object.assign({
@@ -324,9 +322,10 @@
                                discardDataParsoid: doSubst,
                        }, res.locals.envOptions);
 
-                       // VE, the only client using bodyOnly property,
+                       // VE, the only client using body_only property,
                        // doesn't want section tags when this flag is set.
-                       if (res.locals.bodyOnly) {
+                       // (T181226)
+                       if (res.locals.body_only) {
                                envOptions.wrapSections = false;
                        }
 
@@ -373,7 +372,7 @@
                                oldid: oldid,
                                contentmodel: opts.contentmodel,
                                contentVersion: env.contentVersion,
-                               bodyOnly: res.locals.bodyOnly,
+                               body_only: res.locals.body_only,
                                cacheConfig: true,
                                reuseExpansions: reuseExpansions,
                        })
diff --git a/lib/parse.js b/lib/parse.js
index 09cb425..8dd4a6f 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -39,13 +39,13 @@
        .then(function(doc) {
                var out;
                if (env.pageBundle) {
-                       out = DU.extractDpAndSerialize(obj.bodyOnly ? doc.body 
: doc, {
-                               innerXML: obj.bodyOnly,
+                       out = DU.extractDpAndSerialize(obj.body_only ? doc.body 
: doc, {
+                               innerXML: obj.body_only,
                        });
                } else {
                        out = {
-                               html: DU.toXML(obj.bodyOnly ? doc.body : doc, {
-                                       innerXML: obj.bodyOnly,
+                               html: DU.toXML(obj.body_only ? doc.body : doc, {
+                                       innerXML: obj.body_only,
                                }),
                        };
                }
@@ -104,7 +104,7 @@
  * @param {Object} obj.parsoidOptions Will be Object.assign'ed to ParsoidConfig
  * @param {Object} obj.envOptions Will be Object.assign'ed to the env
  * @param {Boolean} [obj.cacheConfig] Cache the constructed ParsoidConfig
- * @param {Boolean} [obj.bodyOnly]
+ * @param {Boolean} [obj.body_only] Only return the <body> children (T181657)
  * @param {Number} [obj.oldid]
  * @param {Object} [obj.selser]
  * @param {Object} [obj.pb]
diff --git a/tests/mocha/api.js b/tests/mocha/api.js
index 46a8df0..c0c3e5b 100644
--- a/tests/mocha/api.js
+++ b/tests/mocha/api.js
@@ -824,24 +824,6 @@
                        .end(done);
                });
 
-               it("should respect body parameter - b/c test for bodyOnly", 
function(done) {
-                       request(api)
-                       .post(mockDomain + '/v3/transform/wikitext/to/html/')
-                       .send({
-                               wikitext: "''foo''",
-                               bodyOnly: 1,
-                       })
-                       .expect(validHtmlResponse())
-                       .expect(function(res) {
-                               // v3 only returns children of <body>
-                               res.text.should.not.match(/<body/);
-                               res.text.should.match(/<p/);
-                               // No section wrapping in body-only mode
-                               res.text.should.not.match(/<section/);
-                       })
-                       .end(done);
-               });
-
                it('should include captured offsets', function(done) {
                        request(api)
                        .get(mockDomain + '/v3/page/pagebundle/Main_Page/1')

-- 
To view, visit https://gerrit.wikimedia.org/r/396481
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5d1048087a7857a4fa000320ae01a36920563e1c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Ppchelko <ppche...@wikimedia.org>
Gerrit-Reviewer: Sbailey <sbai...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to