Permalink
Browse files

quick fixes #1529 - recovers more gracefully if glob() is disabled; i…

…nstaller can be run, and it will provide a warning.

Piwik will continue to run albeit in a crippled state:
- can't change language via selection list
- can't list/activate/deactivate plugins
- can't run updates
  • Loading branch information...
1 parent ac783a6 commit e301de89b1985c8ca12cee39300106ce4e3b200f vipsoft committed Jul 30, 2010
View
@@ -368,9 +368,9 @@ private static function getMergedAssetHash ($type)
{
$mergedFileDirectory = self::getMergedFileDirectory();
- $matchingFiles = glob( $mergedFileDirectory . "*." . $type );
+ $matchingFiles = @glob( $mergedFileDirectory . "*." . $type );
- if($matchingFiles === false)
+ if($matchingFiles == false)
{
return false;
}
View
@@ -229,11 +229,11 @@ static public function unlinkRecursive($dir, $deleteRootToo)
*/
public static function globr($sDir, $sPattern, $nFlags = NULL)
{
- if(($aFiles = glob("$sDir/$sPattern", $nFlags)) == false)
+ if(($aFiles = @glob("$sDir/$sPattern", $nFlags)) == false)
{
$aFiles = array();
}
- if(($aDirs = glob("$sDir/*", GLOB_ONLYDIR)) != false)
+ if(($aDirs = @glob("$sDir/*", GLOB_ONLYDIR)) != false)
{
foreach ($aDirs as $sSubDir)
{
View
@@ -98,8 +98,8 @@ public function isPluginLoaded( $name )
*/
public function readPluginsDirectory()
{
- $pluginsName = glob( PIWIK_INCLUDE_PATH . '/plugins/*', GLOB_ONLYDIR);
- $pluginsName = $pluginsName === false ? array() : array_map('basename', $pluginsName);
+ $pluginsName = @glob( PIWIK_INCLUDE_PATH . '/plugins/*', GLOB_ONLYDIR);
+ $pluginsName = $pluginsName == false ? array() : array_map('basename', $pluginsName);
return $pluginsName;
}
View
@@ -194,8 +194,8 @@ private function loadComponentsWithUpdateFile()
$pathToUpdates = sprintf($this->pathUpdateFilePlugins, $name) . '*.php';
}
- $files = glob( $pathToUpdates );
- if($files === false)
+ $files = @glob( $pathToUpdates );
+ if($files == false)
{
$files = array();
}
View
@@ -546,6 +546,7 @@
'Installation_SystemCheckTimeLimitHelp' => 'On a high traffic website, executing the archiving process may require more time than currently allowed. If necessary, change the max_execution_time directive in your php.ini file.',
'Installation_SystemCheckMailHelp' => 'Feedback and Lost Password messages will not be sent without mail().',
'Installation_SystemCheckParseIniFileHelp' => 'This built-in function has been disabled on your host. Piwik will attempt to emulate this function but may encounter further security restrictions. Tracker performance will also be impacted.',
+ 'Installation_SystemCheckGlobHelp' => 'This built-in function has been disabled on your host. Piwik may work without this function but at reduced functionality/capability.'
'Installation_SystemCheckDebugBacktraceHelp' => 'View::factory won\'t be able to create views for the calling module.',
'Installation_SystemCheckCreateFunctionHelp' => 'Piwik uses anonymous functions for callbacks.',
'Installation_SystemCheckEvalHelp' => 'Required by HTML QuickForm and Smarty templating system.',
@@ -18,7 +18,7 @@
</thead>
<tbody id="plugins">
{foreach from=$pluginsName key=name item=plugin}
- {if !$plugin.alwaysActivated}
+ {if isset($plugin.alwaysActivated) && !$plugin.alwaysActivated}
<tr class={if $plugin.activated}"active"{else}"deactivate"{/if}>
<td class="name">
{if isset($plugin.info.homepage)}<a title="{'CorePluginsAdmin_PluginHomepage'|translate}" href="{$plugin.info.homepage}">{/if}
@@ -112,6 +112,7 @@ function systemCheck()
'set_time_limit' => 'Installation_SystemCheckTimeLimitHelp',
'mail' => 'Installation_SystemCheckMailHelp',
'parse_ini_file' => 'Installation_SystemCheckParseIniFileHelp',
+ 'glob' => 'Installation_SystemCheckGlobHelp',
'debug_backtrace' => 'Installation_SystemCheckDebugBacktraceHelp',
'create_function' => 'Installation_SystemCheckCreateFunctionHelp',
'eval' => 'Installation_SystemCheckEvalHelp',
@@ -744,6 +745,7 @@ public static function getSystemInformation()
'set_time_limit',
'mail',
'parse_ini_file',
+ 'glob',
);
$infos['desired_functions'] = $desired_functions;
$infos['missing_desired_functions'] = array();
@@ -55,12 +55,15 @@ public function getAvailableLanguages()
return $this->languageNames;
}
$path = PIWIK_INCLUDE_PATH . "/lang/";
- $languages = glob($path . "*.php");
+ $languages = @glob($path . "*.php");
$pathLength = strlen($path);
$languageNames = array();
- foreach($languages as $language)
+ if($languages)
{
- $languageNames[] = substr($language, $pathLength, -strlen('.php'));
+ foreach($languages as $language)
+ {
+ $languageNames[] = substr($language, $pathLength, -strlen('.php'));
+ }
}
$this->languageNames = $languageNames;
return $languageNames;

0 comments on commit e301de8

Please sign in to comment.