mirror of https://gitee.com/bigwinds/arangodb
Merge pull request #1811 from arangodb/kill-the-monkey
Remove monkeypatches
This commit is contained in:
commit
7e2603bdcc
|
@ -905,10 +905,6 @@ void V8ShellFeature::loadModules(ShellFeature::RunMode runMode) {
|
|||
files.push_back(
|
||||
"common/bootstrap/modules.js"); // must come last before patches
|
||||
|
||||
if (runMode != ShellFeature::RunMode::JSLINT) {
|
||||
files.push_back("common/bootstrap/monkeypatches.js");
|
||||
}
|
||||
|
||||
files.push_back("client/client.js"); // needs internal
|
||||
|
||||
for (size_t i = 0; i < files.size(); ++i) {
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
var actions = require("@arangodb/actions");
|
||||
var graph = require("@arangodb/graph-blueprint");
|
||||
var arangodb = require("@arangodb");
|
||||
var shallowCopy = require("@arangodb/util").shallowCopy;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -386,7 +387,7 @@ function update_graph_vertex (req, res, g, isPatch) {
|
|||
waitForSync = true;
|
||||
}
|
||||
|
||||
var shallow = json._shallowCopy;
|
||||
var shallow = shallowCopy(json);
|
||||
|
||||
var id2 = null;
|
||||
if (isPatch) {
|
||||
|
@ -781,7 +782,7 @@ function update_graph_edge (req, res, g, isPatch) {
|
|||
waitForSync = true;
|
||||
}
|
||||
|
||||
var shallow = json._shallowCopy;
|
||||
var shallow = shallowCopy(json);
|
||||
if (json.hasOwnProperty('_from')) {
|
||||
shallow._from = json._from;
|
||||
}
|
||||
|
|
|
@ -270,7 +270,6 @@
|
|||
"frontend/js/bootstrap/errors.js",
|
||||
"frontend/js/bootstrap/modules/console.js",
|
||||
"frontend/js/client/bootstrap/modules/internal.js",
|
||||
"frontend/js/bootstrap/monkeypatches.js",
|
||||
"frontend/js/modules/**/*.js",
|
||||
"frontend/js/client/client.js"
|
||||
],
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
"frontend/js/modules/@arangodb/common.js",
|
||||
"frontend/js/modules/@arangodb/index.js",
|
||||
"frontend/js/bootstrap/errors.js",
|
||||
"frontend/js/bootstrap/monkeypatches.js",
|
||||
"frontend/js/bootstrap/module-internal.js",
|
||||
"frontend/js/client/bootstrap/module-internal.js",
|
||||
"frontend/js/client/client.js",
|
||||
|
|
|
@ -68,7 +68,6 @@ module.exports = function(karma) {
|
|||
'frontend/js/modules/@arangodb/common.js',
|
||||
'frontend/js/modules/@arangodb/index.js',
|
||||
'frontend/js/bootstrap/errors.js',
|
||||
'frontend/js/bootstrap/monkeypatches.js',
|
||||
'frontend/js/bootstrap/module-internal.js',
|
||||
'frontend/js/client/bootstrap/module-internal.js',
|
||||
'frontend/js/client/client.js',
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
<script src="../js/modules/@arangodb/index.js"></script>
|
||||
|
||||
<script src="../js/bootstrap/errors.js"></script>
|
||||
<script src="../js/bootstrap/monkeypatches.js"></script>
|
||||
<script src="../js/bootstrap/module-internal.js"></script>
|
||||
<script src="../js/client/bootstrap/module-internal.js"></script>
|
||||
|
||||
|
|
|
@ -1726,11 +1726,6 @@ if (typeof SYS_OPTIONS !== 'undefined') {
|
|||
delete global.SYS_OPTIONS;
|
||||
}
|
||||
|
||||
exports.propertyKeys = (obj) => Object.keys(obj).filter((key) => {
|
||||
return (key.charAt(0) !== '_' && key.charAt(0) !== '$');
|
||||
});
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief print
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/*eslint no-extend-native:0 */
|
||||
/*eslint-disable */
|
||||
(function () {
|
||||
'use strict';
|
||||
/*eslint-enable */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief monkey-patches to built-in prototypes
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Lucas Dohmen
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief shallow copies properties
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Object.defineProperty(Object.prototype, '_shallowCopy', {
|
||||
get() {
|
||||
return require('internal').propertyKeys(this).reduce((previous, key) => {
|
||||
previous[key] = this[key];
|
||||
return previous;
|
||||
}, {});
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
@ -28,7 +28,8 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var is = require("@arangodb/is"),
|
||||
internal = require("internal"),
|
||||
propertyKeys = require("@arangodb/util").propertyKeys,
|
||||
shallowCopy = require("@arangodb/util").shallowCopy,
|
||||
Edge,
|
||||
Graph,
|
||||
Vertex,
|
||||
|
@ -245,7 +246,7 @@ Edge.prototype.getProperty = function (name) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Edge.prototype.getPropertyKeys = function () {
|
||||
return internal.propertyKeys(this._properties);
|
||||
return propertyKeys(this._properties);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -253,7 +254,7 @@ Edge.prototype.getPropertyKeys = function () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Edge.prototype.properties = function () {
|
||||
return this._properties._shallowCopy;
|
||||
return shallowCopy(this._properties);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -432,7 +433,7 @@ Vertex.prototype.getProperty = function (name) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vertex.prototype.getPropertyKeys = function () {
|
||||
return internal.propertyKeys(this._properties);
|
||||
return propertyKeys(this._properties);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -450,7 +451,7 @@ Vertex.prototype.getPropertyKeys = function () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vertex.prototype.properties = function () {
|
||||
return this._properties._shallowCopy;
|
||||
return shallowCopy(this._properties);
|
||||
};
|
||||
|
||||
|
||||
|
@ -496,7 +497,7 @@ Graph.prototype._prepareEdgeData = function (data, label) {
|
|||
if (is.notExisty(data) || is.noObject(data)) {
|
||||
edgeData = {};
|
||||
} else {
|
||||
edgeData = data._shallowCopy || {};
|
||||
edgeData = shallowCopy(data) || {};
|
||||
}
|
||||
|
||||
edgeData.$label = label;
|
||||
|
@ -510,7 +511,7 @@ Graph.prototype._prepareVertexData = function (data) {
|
|||
if (is.notExisty(data) || is.noObject(data)) {
|
||||
vertexData = {};
|
||||
} else {
|
||||
vertexData = data._shallowCopy || {};
|
||||
vertexData = shallowCopy(data) || {};
|
||||
}
|
||||
|
||||
return vertexData;
|
||||
|
|
|
@ -85,3 +85,20 @@ exports.inline = function (strs) {
|
|||
}
|
||||
return str.replace(/\s*\n\s*/g, ' ').replace(/(^\s|\s$)/g, '');
|
||||
};
|
||||
|
||||
exports.propertyKeys = function (obj) {
|
||||
return Object.keys(obj).filter((key) => (
|
||||
key.charAt(0) !== '_' && key.charAt(0) !== '$'
|
||||
));
|
||||
};
|
||||
|
||||
exports.shallowCopy = function (src) {
|
||||
const dest = {};
|
||||
if (src === undefined || src === null) {
|
||||
return dest;
|
||||
}
|
||||
for (const key of exports.propertyKeys(src)) {
|
||||
dest[key] = src[key];
|
||||
}
|
||||
return dest;
|
||||
};
|
||||
|
|
|
@ -487,7 +487,7 @@ var JSHINT = (function() {
|
|||
.substr(1, m.length - 2)
|
||||
.replace("\\\"", "\"");
|
||||
}
|
||||
if (m === '_shallowCopy') return;
|
||||
|
||||
membersOnly[m] = false;
|
||||
});
|
||||
}
|
||||
|
@ -1882,7 +1882,6 @@ var JSHINT = (function() {
|
|||
|
||||
|
||||
function countMember(m) {
|
||||
if (m === '_shallowCopy') return;
|
||||
if (membersOnly && typeof membersOnly[m] !== "boolean") {
|
||||
warning("W036", state.tokens.curr, m);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
load(`${startupPath}/server/bootstrap/modules/internal.js`); // deps: internal, fs, console
|
||||
load(`${startupPath}/common/bootstrap/modules/vm.js`); // deps: internal
|
||||
load(`${startupPath}/common/bootstrap/modules.js`); // must come last before patches
|
||||
load(`${startupPath}/common/bootstrap/monkeypatches.js`);
|
||||
}());
|
||||
|
||||
// common globals
|
||||
|
|
|
@ -43,6 +43,7 @@ var console = require("console");
|
|||
|
||||
var arangodb = require("@arangodb");
|
||||
var foxxManager = require("@arangodb/foxx/manager");
|
||||
var shallowCopy = require("@arangodb/util").shallowCopy;
|
||||
var ErrorStackParser = require("error-stack-parser");
|
||||
|
||||
const MIME_DEFAULT = 'text/plain; charset=utf-8';
|
||||
|
@ -970,7 +971,7 @@ function flattenRouting (routes, path, rexpr, urlParameters, depth, prefix) {
|
|||
routes.prefix,
|
||||
path + "/*",
|
||||
rexpr + "(/[^/]+)*/?",
|
||||
urlParameters._shallowCopy,
|
||||
shallowCopy(urlParameters),
|
||||
depth + 1,
|
||||
true));
|
||||
}
|
||||
|
@ -1672,7 +1673,7 @@ function handleRedirect (req, res, options, headers) {
|
|||
+ "</a>.</p></body></html>";
|
||||
|
||||
if (headers !== undefined) {
|
||||
res.headers = headers._shallowCopy;
|
||||
res.headers = shallowCopy(headers);
|
||||
}
|
||||
else {
|
||||
res.headers = {};
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
var db = require("@arangodb").db;
|
||||
var internal = require("internal");
|
||||
var shallowCopy = require("@arangodb/util").shallowCopy;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief the frontend collection
|
||||
|
@ -67,7 +68,7 @@ exports.notifications.versions = function () {
|
|||
}
|
||||
}
|
||||
|
||||
d = d._shallowCopy;
|
||||
d = shallowCopy(d);
|
||||
|
||||
if (! d.hasOwnProperty(v)) {
|
||||
d.versions = {};
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
var arangodb = require("@arangodb"),
|
||||
is = require("@arangodb/is"),
|
||||
shallowCopy = require("@arangodb/util").shallowCopy,
|
||||
db = arangodb.db,
|
||||
ArangoCollection = arangodb.ArangoCollection,
|
||||
common = require("@arangodb/graph-common"),
|
||||
|
@ -88,7 +89,7 @@ var findOrCreateEdgeCollectionByName = function (name) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Edge.prototype.setProperty = function (name, value) {
|
||||
var shallow = this._properties._shallowCopy;
|
||||
var shallow = shallowCopy(this._properties);
|
||||
var id;
|
||||
|
||||
// Could potentially change the weight of edges
|
||||
|
@ -244,7 +245,7 @@ Vertex.prototype.outbound = function () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vertex.prototype.setProperty = function (name, value) {
|
||||
var shallow = this._properties._shallowCopy;
|
||||
var shallow = shallowCopy(this._properties);
|
||||
var id;
|
||||
|
||||
shallow[name] = value;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
var internal = require("internal"); // OK: reloadAuth
|
||||
var arangodb = require("@arangodb");
|
||||
var shallowCopy = require("@arangodb/util").shallowCopy;
|
||||
var crypto = require("@arangodb/crypto");
|
||||
|
||||
var db = arangodb.db;
|
||||
|
@ -240,7 +241,7 @@ exports.update = function (username, password, active, userData, changePassword)
|
|||
throw err;
|
||||
}
|
||||
|
||||
var data = user._shallowCopy;
|
||||
var data = shallowCopy(user);
|
||||
|
||||
if (password !== undefined) {
|
||||
data.authData.simple = hashPassword(password);
|
||||
|
@ -419,7 +420,7 @@ exports.changePassword = function (token, password) {
|
|||
|
||||
password = validatePassword(password);
|
||||
|
||||
var authData = user._shallowCopy.authData;
|
||||
var authData = shallowCopy(user).authData;
|
||||
|
||||
delete authData.passwordToken;
|
||||
authData.simple = hashPassword(password);
|
||||
|
|
|
@ -28,7 +28,6 @@ JAVASCRIPT_BROWSER="\
|
|||
bootstrap/modules/internal.js \
|
||||
bootstrap/modules/console.js \
|
||||
bootstrap/errors.js \
|
||||
bootstrap/monkeypatches.js \
|
||||
\
|
||||
client/client.js \
|
||||
client/bootstrap/modules/internal.js \
|
||||
|
|
Loading…
Reference in New Issue