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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobocoder <anthon.pang@gmail.com>2010-12-22 21:04:51 +0300
committerrobocoder <anthon.pang@gmail.com>2010-12-22 21:04:51 +0300
commitc06b5c99a1e32cf281c8a3d25745e6f3156e0d83 (patch)
tree5830e4b95710823a7cca9fa1be8d758a21bc7695 /libs/upgradephp
parent05916cc8c77cb5a6002d9de6050bdc97e5b2c981 (diff)
add error handling; parse_ini_file() emits warning if .ini file doesn't exist
git-svn-id: http://dev.piwik.org/svn/trunk@3513 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/upgradephp')
-rw-r--r--libs/upgradephp/upgrade.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/libs/upgradephp/upgrade.php b/libs/upgradephp/upgrade.php
index 287fbef9fe..f04524994e 100644
--- a/libs/upgradephp/upgrade.php
+++ b/libs/upgradephp/upgrade.php
@@ -463,24 +463,36 @@ if (in_array('mysqli', @get_loaded_extensions()) && !function_exists('mysqli_set
if(function_exists('parse_ini_file')) {
// provide a wrapper
function _parse_ini_file($filename, $process_sections = false) {
- return parse_ini_file($filename, $process_sections);
+ return file_exists($filename) ? parse_ini_file($filename, $process_sections) : false;
}
} else {
// we can't redefine parse_ini_file() if it has been disabled
function _parse_ini_file($filename, $process_sections = false)
{
+ if(!file_exists($filename)) {
+ return false;
+ }
+
if(function_exists('file_get_contents')) {
$ini = file_get_contents($filename);
- } else if(function_exists('file') && version_compare(phpversion(), '6') >= 0) {
- $ini = implode(file($filename), FILE_TEXT);
+ } else if(function_exists('file')) {
+ if($ini = file($filename)) {
+ $ini = implode("\n", $ini);
+ }
} else if(function_exists('fopen') && function_exists('fread')) {
$handle = fopen($filename, 'r');
+ if(!$handle) {
+ return false;
+ }
$ini = fread($handle, filesize($filename));
fclose($handle);
} else {
return false;
}
+ if($ini === false) {
+ return false;
+ }
if(is_string($ini)) { $ini = explode("\n", str_replace("\r", "\n", $ini)); }
if (count($ini) == 0) { return array(); }