From 32f9eeabbf8bcf7f4e9c8224ff3d31b30aa3ed41 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 10 May 2017 12:26:29 +0200 Subject: [statistics] Compat to old DB in conftgz hook --- .../statistics/hooks/config-tgz.inc.php | 40 ++++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/modules-available/statistics/hooks/config-tgz.inc.php b/modules-available/statistics/hooks/config-tgz.inc.php index 1272a94f..8dffbff6 100644 --- a/modules-available/statistics/hooks/config-tgz.inc.php +++ b/modules-available/statistics/hooks/config-tgz.inc.php @@ -7,26 +7,28 @@ $res = Database::simpleQuery('SELECT h.hwname FROM statistic_hw h' 'screen' => DeviceType::SCREEN, )); -$content = ''; -while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - $content .= $row['hwname'] . "=beamer\n"; -} +if ($res !== false) { // CHeck this in case we're running on old DB during update + $content = ''; + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $content .= $row['hwname'] . "=beamer\n"; + } -if (!empty($content)) { - $tmpfile = '/tmp/bwlp-' . md5($content) . '.tar'; - if (!is_file($tmpfile) || !is_readable($tmpfile) || filemtime($tmpfile) + 86400 < time()) { - if (file_exists($tmpfile)) { - unlink($tmpfile); - } - try { - $a = new PharData($tmpfile); - $a->addFromString("/opt/openslx/beamergui/beamer.conf", $content); + if (!empty($content)) { + $tmpfile = '/tmp/bwlp-' . md5($content) . '.tar'; + if (!is_file($tmpfile) || !is_readable($tmpfile) || filemtime($tmpfile) + 86400 < time()) { + if (file_exists($tmpfile)) { + unlink($tmpfile); + } + try { + $a = new PharData($tmpfile); + $a->addFromString("/opt/openslx/beamergui/beamer.conf", $content); + $file = $tmpfile; + } catch (Exception $e) { + EventLog::failure('Could not include beamer.conf in config.tgz', (string)$e); + unlink($tmpfile); + } + } elseif (is_file($tmpfile) && is_readable($tmpfile)) { $file = $tmpfile; - } catch (Exception $e) { - EventLog::failure('Could not include beamer.conf in config.tgz', (string)$e); - unlink($tmpfile); } - } elseif (is_file($tmpfile) && is_readable($tmpfile)) { - $file = $tmpfile; } -} +} \ No newline at end of file -- cgit v1.2.3-55-g7522