Fix compiled expressions could not be found

This commit is contained in:
nathangray 2020-01-24 02:27:01 -07:00 committed by Hadi Nategh
parent 0945d9e686
commit a9c4919c55
2 changed files with 18 additions and 18 deletions

View File

@ -211,35 +211,34 @@ var et2_arrayMgr = /** @class */ (function () {
// Check whether the expression has already been compiled - if not, // Check whether the expression has already been compiled - if not,
// try to compile it first. If an error occurs, the identifier // try to compile it first. If an error occurs, the identifier
// function is set to null // function is set to null
var proto = this.constructor.prototype; if (typeof et2_arrayMgr.compiledExpressions[_ident] == "undefined") {
if (typeof proto.compiledExpressions[_ident] == "undefined") {
try { try {
if (this.perspectiveData.row == null) { if (this.perspectiveData.row == null) {
// No row, compile for only top level content // No row, compile for only top level content
// @ts-ignore // @ts-ignore
proto.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["cont", "_cont"]); et2_arrayMgr.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["cont", "_cont"]);
} }
else { else {
// @ts-ignore // @ts-ignore
proto.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["row", "cont", "row_cont", "_cont"]); et2_arrayMgr.compiledExpressions[_ident] = et2_compilePHPExpression(_ident, ["row", "cont", "row_cont", "_cont"]);
} }
} }
catch (e) { catch (e) {
proto.compiledExpressions[_ident] = null; et2_arrayMgr.compiledExpressions[_ident] = null;
egw.debug("error", "Error while compiling PHP->JS ", e); egw.debug("error", "Error while compiling PHP->JS ", e);
} }
} }
// Execute the previously compiled expression, if it is not "null" // Execute the previously compiled expression, if it is not "null"
// because compilation failed. The parameters have to be in the same // because compilation failed. The parameters have to be in the same
// order as defined during compilation. // order as defined during compilation.
if (proto.compiledExpressions[_ident]) { if (et2_arrayMgr.compiledExpressions[_ident]) {
try { try {
if (this.perspectiveData.row == null) { if (this.perspectiveData.row == null) {
// No row, exec with only top level content // No row, exec with only top level content
_ident = proto.compiledExpressions[_ident](cont, _cont); _ident = et2_arrayMgr.compiledExpressions[_ident](cont, _cont);
} }
else { else {
_ident = proto.compiledExpressions[_ident](row, cont, row_cont, _cont); _ident = et2_arrayMgr.compiledExpressions[_ident](row, cont, row_cont, _cont);
} }
} }
catch (e) { catch (e) {
@ -314,6 +313,7 @@ var et2_arrayMgr = /** @class */ (function () {
} }
return mgr; return mgr;
}; };
et2_arrayMgr.compiledExpressions = {};
return et2_arrayMgr; return et2_arrayMgr;
}()); }());
exports.et2_arrayMgr = et2_arrayMgr; exports.et2_arrayMgr = et2_arrayMgr;

View File

@ -21,7 +21,8 @@ import {et2_widget} from "./et2_core_widget";
* *
* This manages access to content, modifications and readonlys arrays * This manages access to content, modifications and readonlys arrays
*/ */
export class et2_arrayMgr { export class et2_arrayMgr
{
splitIds: boolean = true; splitIds: boolean = true;
public data: object; public data: object;
// Holds information about the current perspective // Holds information about the current perspective
@ -30,7 +31,7 @@ export class et2_arrayMgr {
"key": null, "key": null,
"row": null "row": null
}; };
compiledExpressions: {}; protected static compiledExpressions: object = {};
private readonly _parentMgr: et2_arrayMgr; private readonly _parentMgr: et2_arrayMgr;
private readOnly: boolean = false; private readOnly: boolean = false;
@ -235,21 +236,20 @@ export class et2_arrayMgr {
// Check whether the expression has already been compiled - if not, // Check whether the expression has already been compiled - if not,
// try to compile it first. If an error occurs, the identifier // try to compile it first. If an error occurs, the identifier
// function is set to null // function is set to null
const proto = this.constructor.prototype; if (typeof et2_arrayMgr.compiledExpressions[_ident] == "undefined") {
if (typeof proto.compiledExpressions[_ident] == "undefined") {
try { try {
if (this.perspectiveData.row == null) { if (this.perspectiveData.row == null) {
// No row, compile for only top level content // No row, compile for only top level content
// @ts-ignore // @ts-ignore
proto.compiledExpressions[_ident] = et2_compilePHPExpression( et2_arrayMgr.compiledExpressions[_ident] = et2_compilePHPExpression(
_ident, ["cont", "_cont"]); _ident, ["cont", "_cont"]);
} else { } else {
// @ts-ignore // @ts-ignore
proto.compiledExpressions[_ident] = et2_compilePHPExpression( et2_arrayMgr.compiledExpressions[_ident] = et2_compilePHPExpression(
_ident, ["row", "cont", "row_cont", "_cont"]); _ident, ["row", "cont", "row_cont", "_cont"]);
} }
} catch (e) { } catch (e) {
proto.compiledExpressions[_ident] = null; et2_arrayMgr.compiledExpressions[_ident] = null;
egw.debug("error", "Error while compiling PHP->JS ", e); egw.debug("error", "Error while compiling PHP->JS ", e);
} }
} }
@ -257,13 +257,13 @@ export class et2_arrayMgr {
// Execute the previously compiled expression, if it is not "null" // Execute the previously compiled expression, if it is not "null"
// because compilation failed. The parameters have to be in the same // because compilation failed. The parameters have to be in the same
// order as defined during compilation. // order as defined during compilation.
if (proto.compiledExpressions[_ident]) { if (et2_arrayMgr.compiledExpressions[_ident]) {
try { try {
if (this.perspectiveData.row == null) { if (this.perspectiveData.row == null) {
// No row, exec with only top level content // No row, exec with only top level content
_ident = proto.compiledExpressions[_ident](cont, _cont); _ident = et2_arrayMgr.compiledExpressions[_ident](cont, _cont);
} else { } else {
_ident = proto.compiledExpressions[_ident](row, cont, row_cont, _cont); _ident = et2_arrayMgr.compiledExpressions[_ident](row, cont, row_cont, _cont);
} }
} catch (e) { } catch (e) {
// only log error, as they are no real errors but missing data // only log error, as they are no real errors but missing data