Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/serverinfo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrik Kernstock <info@pkern.at>2017-05-26 13:30:21 +0300
committerGitHub <noreply@github.com>2017-05-26 13:30:21 +0300
commit0952447cbe8892cc7cc79d1bd8d9bdbae609b9b1 (patch)
treef8c0892857b1b812b7b53cadd4dd55f751a5aa4d /lib
parent1f45054955d9c56db1f68a46b9ba5a64367fbba6 (diff)
Use is_readable() to check if meminfo can be read
IMHO it's a bit more elegant way to check if meminfo can be read using is_readable(), instead of suppressing all warnings and errors for file_get_contents(). (@ is changing the whole error_reporting() temporarly, so it should be avoided) Signed-off-by: Patrik Kernstock <info@pkern.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/SystemStatistics.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/SystemStatistics.php b/lib/SystemStatistics.php
index dd483a5..28966de 100644
--- a/lib/SystemStatistics.php
+++ b/lib/SystemStatistics.php
@@ -68,7 +68,12 @@ class SystemStatistics {
* @return array with the two values 'mem_free' and 'mem_total'
*/
protected function getMemoryUsage() {
- $memoryUsage = @file_get_contents('/proc/meminfo');
+ $memoryUsage = false;
+ if (is_readable('/proc/meminfo')) {
+ // read meminfo from OS
+ $memoryUsage = file_get_contents('/proc/meminfo');
+ }
+ // check if determining memoryUsage failed
if ($memoryUsage === false) {
return ['mem_free' => 'N/A', 'mem_total' => 'N/A'];
}