Skip to content

Commit

Permalink
Merge pull request #1364 from ChristianMayer/robustnes_for_environmen…
Browse files Browse the repository at this point in the history
…t_php

More robusness for failing environment PHP request
  • Loading branch information
peuter committed Aug 13, 2023
2 parents 6a84ed4 + 1671263 commit 4b8f1cb
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 19 deletions.
35 changes: 26 additions & 9 deletions source/class/cv/Application.js
Expand Up @@ -1071,18 +1071,32 @@ qx.Class.define('cv.Application', {
method: 'GET',
accept: 'application/json'
});
const failedCheck = (errorText, disableReason) => {
this.setServerHasPhpSupport(false);
this.error(errorText);

this.setManagerDisabled(true);
this.setManagerDisabledReason(disableReason);
this.setManagerChecked(true);
};

xhr.addListenerOnce('success', e => {
const req = e.getTarget();
const env = req.getResponse();
if (typeof env === 'string' && env.startsWith('<?php')) {
// no php support
this.setServerHasPhpSupport(false);
this.error('Disabling manager due to missing PHP support.');

this.setManagerDisabled(true);
this.setManagerDisabledReason(qx.locale.Manager.tr('Your server does not support PHP'));
this.setManagerChecked(true);
if (typeof env !== 'object') {
if (typeof env === 'string' && env.startsWith('<?php')) {
// no php support
failedCheck(
qx.locale.Manager.tr('Disabling manager due to missing PHP support.'),
qx.locale.Manager.tr('Your server does not support PHP.')
);
} else {
// generic php error
failedCheck(
qx.locale.Manager.tr('Disabling manager due to failed PHP request querying the environment.'),
qx.locale.Manager.tr('Failed PHP request querying the environment.')
);
}
} else {
// is this is served by native openHAB server, we do not have native PHP support, only the basic
// rest api is available, but nothing else that needs PHP (like some plugin backend code)
Expand Down Expand Up @@ -1143,7 +1157,10 @@ qx.Class.define('cv.Application', {
}
});
xhr.addListener('statusError', e => {
this.setManagerChecked(true);
failedCheck(
qx.locale.Manager.tr('Disabling manager due to failed PHP request querying the environment.'),
qx.locale.Manager.tr('Failed PHP request querying the environment.')
);
});
xhr.send();
}
Expand Down
24 changes: 20 additions & 4 deletions source/translation/de.po
Expand Up @@ -1156,10 +1156,6 @@ msgstr "Datei \"%1\" wurde umbenannt in \"%2\""
msgid "Folder \"%1\" has been renamed to \"%2\""
msgstr "Ordner \"%1\" wurde umbenannt in \"%2\""

#: cv/Application.js
msgid "Your server does not support PHP"
msgstr "Ihr Server unterstützt kein PHP"

#: cv/ui/manager/Main.js
msgid "Server"
msgstr "Server"
Expand Down Expand Up @@ -1224,3 +1220,23 @@ msgstr "Jahr"
#: cv/ui/structure/tile/widgets/Tile.js
msgid "Last update: %1"
msgstr "Letzte Aktualisierung: %1"

#: cv/Application.js
msgid "Disabling manager due to missing PHP support."
msgstr "Manager ist deaktiviert aufgrund von fehlender Unterstützung von PHP."

#: cv/Application.js
msgid "Your server does not support PHP."
msgstr "Ihr Server unterstützt kein PHP."

#: cv/Application.js
msgid "Disabling manager due to failed PHP request querying the environment."
msgstr "Manager ist deaktiviert aufgrund eines fehlerhaften PHP Aufrufs während der 'environment'-Abfrage."

#: cv/Application.js
msgid "Failed PHP request querying the environment."
msgstr "PHP Abfrage des 'environment' fehlgeschlagen."

#: cv/ui/structure/tile/widgets/Tile.js
msgid "Last update: unknown"
msgstr "Letzte Aktualisierung: unbekannt"
28 changes: 22 additions & 6 deletions source/translation/en.po
Expand Up @@ -198,7 +198,7 @@ msgstr ""
msgid "Save as..."
msgstr ""

#: cv/ui/manager/contextmenu/FileItem.js
#: cv/ui/manager/contextmenu/ConfigElement.js
msgid "Delete"
msgstr ""

Expand Down Expand Up @@ -1020,7 +1020,7 @@ msgstr ""
msgid "Edit text content"
msgstr ""

#: cv/ui/manager/MenuBar.js
#: cv/ui/manager/Main.js
msgid "About"
msgstr ""

Expand Down Expand Up @@ -1248,10 +1248,6 @@ msgstr ""
msgid "Folder \"%1\" has been renamed to \"%2\""
msgstr ""

#: cv/Application.js
msgid "Your server does not support PHP"
msgstr ""

#: cv/ui/manager/Main.js
msgid "Server"
msgstr ""
Expand Down Expand Up @@ -1344,3 +1340,23 @@ msgstr ""
#: cv/ui/structure/tile/widgets/Tile.js
msgid "Last update: %1"
msgstr ""

#: cv/Application.js
msgid "Disabling manager due to missing PHP support."
msgstr ""

#: cv/Application.js
msgid "Your server does not support PHP."
msgstr ""

#: cv/Application.js
msgid "Disabling manager due to failed PHP request querying the environment."
msgstr ""

#: cv/Application.js
msgid "Failed PHP request querying the environment."
msgstr ""

#: cv/ui/structure/tile/widgets/Tile.js
msgid "Last update: unknown"
msgstr ""

0 comments on commit 4b8f1cb

Please sign in to comment.