Skip to content

Commit 8ca2693

Browse files
authored
Merge pull request #4770 from AllskyTeam/4768-module-manager-failing-due-to-corrupted-module
#4768 Fix for modules with corrupt or missing metadata
2 parents 722f7f2 + fc2105a commit 8ca2693

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

html/includes/moduleutil.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,31 @@ private function readModuleData($moduleDirectory, $type, $event) {
106106
}
107107

108108
$decoded = json_decode($metaData);
109-
if (in_array($event, $decoded->events)) {
110-
if (isset($decoded->experimental)) {
111-
$experimental = strtolower($decoded->experimental) == "true"? true: false;
112-
} else {
113-
$experimental = false;
109+
if ($decoded !== null) {
110+
if (in_array($event, $decoded->events)) {
111+
if (isset($decoded->experimental)) {
112+
$experimental = strtolower($decoded->experimental) == "true"? true: false;
113+
} else {
114+
$experimental = false;
115+
}
116+
117+
$arrFiles[$entry] = [
118+
'module' => $entry,
119+
'metadata' => $decoded,
120+
'type' => $type
121+
];
122+
$arrFiles[$entry]['metadata']->experimental = $experimental;
114123
}
115-
124+
} else {
125+
$decoded = new stdClass();
126+
$decoded->name = "Module " . $entry . " is currupted";
127+
$decoded->description = "The metadata in the module file is invalid. Please contact Allsky support.";
128+
$decoded->events = ["day", "night", "periodic", "daynight", "nightday"];
116129
$arrFiles[$entry] = [
117130
'module' => $entry,
118131
'metadata' => $decoded,
119132
'type' => $type
120-
];
121-
$arrFiles[$entry]['metadata']->experimental = $experimental;
133+
];
122134
}
123135
}
124136
}
@@ -252,7 +264,9 @@ private function readModules() {
252264
$selectedResult = [];
253265
foreach($configData as $selectedName=>$data) {
254266
$moduleName = "allsky_" . $selectedName . ".py";
255-
// TODO: check if $allModules[$moduleName] exists.
267+
if (!isset($allModules[$moduleName])) {
268+
continue;
269+
}
256270
$moduleData = $allModules[$moduleName];
257271

258272
if (isset($data->metadata->arguments)) {
@@ -402,3 +416,4 @@ public function getReset() {
402416

403417
$overlayUtil = new MODULEUTIL();
404418
$overlayUtil->run();
419+

0 commit comments

Comments
 (0)