diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-07-17 08:53:44 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-07-17 08:53:44 +0400 |
commit | 80dd44b3f918516d64c2a257480d194b1c89c291 (patch) | |
tree | 347739055346b8cf3b16b50e2d201b0158c1b6ac | |
parent | 1d3a048bd81703d132f5cf9d7d7b2a5e31d37bf3 (diff) |
Fixes #4046 Not checking for config/config.ini.php in the system check since it's not required (and we display warning on other screens that need config writable)
Also fixing install process regression and removing config.ini.sample.php
-rw-r--r-- | config/config.ini.sample.php | 20 | ||||
-rw-r--r-- | core/Access.php | 7 | ||||
-rw-r--r-- | core/Common.php | 6 | ||||
-rw-r--r-- | core/FrontController.php | 19 | ||||
-rw-r--r-- | core/Piwik.php | 24 | ||||
-rw-r--r-- | core/testMinimumPhpVersion.php | 4 | ||||
-rw-r--r-- | plugins/CoreUpdater/Controller.php | 2 | ||||
-rw-r--r-- | plugins/Installation/Controller.php | 22 | ||||
-rw-r--r-- | plugins/Installation/FormDatabaseSetup.php | 4 | ||||
-rwxr-xr-x | plugins/Installation/templates/_systemCheckSection.twig | 35 | ||||
-rw-r--r-- | plugins/SitesManager/API.php | 7 |
11 files changed, 72 insertions, 78 deletions
diff --git a/config/config.ini.sample.php b/config/config.ini.sample.php deleted file mode 100644 index 9edbf5889c..0000000000 --- a/config/config.ini.sample.php +++ /dev/null @@ -1,20 +0,0 @@ -; <?php exit; ?> DO NOT REMOVE THIS LINE -; this file for documentation purposes; DO NOT COPY this file to config.ini.php; -; the config.ini.php is normally created during the installation process -; (see http://piwik.org/docs/installation) -; when this file is absent it triggers the Installation process to create -; config.ini.php; that file will contain the superuser and database access info - -[superuser] -login = yourSuperUserLogin -password = yourSuperUserPasswordHash -email = hello@example.org - -[database] -host = localhost -username = databaseLogin -password = datatabasePassword -dbname = databaseName -adapter = PDO_MYSQL ; PDO_MYSQL, MYSQLI, or PDO_PGSQL -tables_prefix = piwik_ -;charset = utf8 diff --git a/core/Access.php b/core/Access.php index e9d3a65d85..9045e5bcb7 100644 --- a/core/Access.php +++ b/core/Access.php @@ -206,7 +206,12 @@ class Piwik_Access protected function reloadAccessSuperUser() { $this->isSuperUser = true; - $this->idsitesByAccess['superuser'] = Piwik_SitesManager_API::getInstance()->getAllSitesId(); + try { + $allSitesId = Piwik_SitesManager_API::getInstance()->getAllSitesId(); + } catch(Exception $e) { + $allSitesId = array(); + } + $this->idsitesByAccess['superuser'] = $allSitesId; $this->login = Piwik_Config::getInstance()->superuser['login']; return true; } diff --git a/core/Common.php b/core/Common.php index 5eeb94ffaf..b3f3560344 100644 --- a/core/Common.php +++ b/core/Common.php @@ -62,10 +62,8 @@ class Piwik_Common */ public static function prefixTable($table) { - if (is_null(self::$cachedTablePrefix)) { - self::$cachedTablePrefix = Piwik_Config::getInstance()->database['tables_prefix']; - } - return self::$cachedTablePrefix . $table; + $prefix = Piwik_Config::getInstance()->database['tables_prefix']; + return $prefix . $table; } /** diff --git a/core/FrontController.php b/core/FrontController.php index 6fb08f158d..22dde1dae4 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -197,11 +197,6 @@ class Piwik_FrontController return $exceptionToThrow; } - protected function createAccessObject() - { - Piwik_Access::getInstance(); - } - /** * Must be called before dispatch() * - checks that directories are writable, @@ -233,7 +228,7 @@ class Piwik_FrontController '/tmp/tcpdf/' ); - Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); + Piwik::dieIfDirectoriesNotWritable($directoriesToCheck); Piwik_Common::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); @@ -255,6 +250,7 @@ class Piwik_FrontController throw $exceptionToThrow; } + try { Piwik::createDatabaseObject(); } catch (Exception $e) { @@ -267,15 +263,13 @@ class Piwik_FrontController Piwik::createLogObject(); - // creating the access object, so that core/Updates/* can enforce Super User and use some APIs - $this->createAccessObject(); + // Init the Access object, so that eg. core/Updates/* can enforce Super User and use some APIs + Piwik_Access::getInstance(); + Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); Piwik_PluginsManager::getInstance()->installLoadedPlugins(); - -// Piwik_Common::mkdir(PIWIK_USER_PATH . '/' . Piwik_Config::getInstance()->smarty['compile_dir']); - // ensure the current Piwik URL is known for later use if (method_exists('Piwik', 'getPiwikUrl')) { $host = Piwik::getPiwikUrl(); @@ -309,7 +303,8 @@ class Piwik_FrontController throw $e; } - Piwik_ExitWithMessage($e->getMessage(), false, true); + $trace = $e->getTraceAsString(); + Piwik_ExitWithMessage($e->getMessage(), false /* $debugTrace */, true); } } diff --git a/core/Piwik.php b/core/Piwik.php index 340f071b3b..b37d8cf95b 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -390,7 +390,7 @@ class Piwik * * @param array $directoriesToCheck Array of directory names to check */ - static public function checkDirectoriesWritableOrDie($directoriesToCheck = null) + static public function dieIfDirectoriesNotWritable($directoriesToCheck = null) { $resultCheck = Piwik::checkDirectoriesWritable($directoriesToCheck); if (array_search(false, $resultCheck) === false) { @@ -428,28 +428,17 @@ class Piwik * @param array $directoriesToCheck array of directories to check - if not given default Piwik directories that needs write permission are checked * @return array directory name => true|false (is writable) */ - static public function checkDirectoriesWritable($directoriesToCheck = null) + static public function checkDirectoriesWritable($directoriesToCheck) { - if ($directoriesToCheck == null) { - $directoriesToCheck = array( - '/config/', - '/tmp/', - '/tmp/templates_c/', - '/tmp/cache/', - '/tmp/assets/', - '/tmp/latest/', - '/tmp/tcpdf/', - '/tmp/sessions/', - ); - } - $resultCheck = array(); foreach ($directoriesToCheck as $directoryToCheck) { if (!preg_match('/^' . preg_quote(PIWIK_USER_PATH, '/') . '/', $directoryToCheck)) { $directoryToCheck = PIWIK_USER_PATH . $directoryToCheck; } - if (!file_exists($directoryToCheck)) { + // Create an empty directory + $isFile = strpos($directoryToCheck, '.') !== false; + if (!$isFile && !file_exists($directoryToCheck)) { Piwik_Common::mkdir($directoryToCheck); } @@ -626,7 +615,8 @@ class Piwik $manifest = PIWIK_INCLUDE_PATH . '/config/manifest.inc.php'; if (!file_exists($manifest)) { - $messages[] = Piwik_Translate('General_WarningFileIntegrityNoManifest'); + $suffix = " If you are deploying Piwik from Git, this message is normal."; + $messages[] = Piwik_Translate('General_WarningFileIntegrityNoManifest') . $suffix; return $messages; } diff --git a/core/testMinimumPhpVersion.php b/core/testMinimumPhpVersion.php index 909208a355..0f9b8b0529 100644 --- a/core/testMinimumPhpVersion.php +++ b/core/testMinimumPhpVersion.php @@ -58,8 +58,8 @@ if ($minimumPhpInvalid) { if(!file_exists($autoloader)) { $piwik_errorMessage .= "<p>It appears the <a href='https://getcomposer.org/' target='_blank'>composer</a> tool is not yet installed. You can install Composer in a few easy steps. In the piwik directory, run in the command line the following (eg. via ssh): - <pre>$ curl -sS https://getcomposer.org/installer | php". - "\n$ php composer.phar install</pre> </p><p>This will download and install composer, and initialize composer for Piwik (eg. download the twig library in vendor/twig). + <pre>curl -sS https://getcomposer.org/installer | php". + "\nphp composer.phar install</pre> </p><p>This will download and install composer, and initialize composer for Piwik (eg. download the twig library in vendor/twig). <br/>Then reload this page to access your analytics reports.</p>"; } } diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index 7aa65bc2b4..f60e2041a8 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -107,7 +107,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller private function oneClick_Download() { $this->pathPiwikZip = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION . 'latest.zip'; - Piwik::checkDirectoriesWritableOrDie(array(self::PATH_TO_EXTRACT_LATEST_VERSION)); + Piwik::dieIfDirectoriesNotWritable(array(self::PATH_TO_EXTRACT_LATEST_VERSION)); // we catch exceptions in the caller (i.e., oneClickUpdate) $url = self::getLatestZipUrl($this->newVersion) . '?cb=' . $this->newVersion; diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index e257d47635..33760871fb 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -495,7 +495,6 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin // connect to the database using the DB infos currently in the session $this->createDbFromSessionInformation(); - Piwik::createAccessObject(); Piwik::setUserIsSuperUser(); Piwik::createLogObject(); } @@ -675,7 +674,26 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $infos = array(); $infos['general_infos'] = array(); - $infos['directories'] = Piwik::checkDirectoriesWritable(); + + $directoriesToCheck = array(); + + if(!Piwik::isInstalled()) { + // at install, need /config to be writable (so we can create config.ini.php) + $directoriesToCheck[] = '/config/'; + } + + $directoriesToCheck = array_merge($directoriesToCheck, array( + '/tmp/', + '/tmp/templates_c/', + '/tmp/cache/', + '/tmp/assets/', + '/tmp/latest/', + '/tmp/tcpdf/', + '/tmp/sessions/', + )); + + $infos['directories'] = Piwik::checkDirectoriesWritable($directoriesToCheck); + $infos['can_auto_update'] = Piwik::canAutoUpdate(); if (Piwik_Common::isIIS()) { diff --git a/plugins/Installation/FormDatabaseSetup.php b/plugins/Installation/FormDatabaseSetup.php index 936aa9ad86..05462d5f8e 100644 --- a/plugins/Installation/FormDatabaseSetup.php +++ b/plugins/Installation/FormDatabaseSetup.php @@ -296,7 +296,9 @@ class Piwik_Installation_FormDatabaseSetup_Rule_checkValidFilename extends HTML_ { function validateOwner() { - return Piwik_Common::isValidFilename($this->owner->getValue()); + $prefix = $this->owner->getValue(); + return empty($prefix) + || Piwik_Common::isValidFilename($prefix); } } diff --git a/plugins/Installation/templates/_systemCheckSection.twig b/plugins/Installation/templates/_systemCheckSection.twig index 260dbeda06..454f19579d 100755 --- a/plugins/Installation/templates/_systemCheckSection.twig +++ b/plugins/Installation/templates/_systemCheckSection.twig @@ -274,6 +274,23 @@ {% endfor %} </td> </tr> + <tr> + <td class="label">{{ 'Installation_Filesystem'|translate }}</td> + <td> + {% if not infos.is_nfs %} + {{ ok }} {{ 'General_Ok'|translate }} + <br/> + {% else %} + {{ warning }} + <span class="warn">{{ 'Installation_NfsFilesystemWarning'|translate }}</span> + {% if duringInstall is not empty %} + <p>{{ 'Installation_NfsFilesystemWarningSuffixInstall'|translate }}</p> + {% else %} + <p>{{ 'Installation_NfsFilesystemWarningSuffixAdmin'|translate }}</p> + {% endif %} + {% endif %} + </td> + </tr> {% if infos.general_infos.assume_secure_protocol is defined %} <tr> <td class="label">{{ 'Installation_SystemCheckSecureProtocol'|translate }}</td> @@ -308,23 +325,7 @@ </td> </tr> {% endif %} - <tr> - <td class="label">{{ 'Installation_Filesystem'|translate }}</td> - <td> - {% if not infos.is_nfs %} - {{ ok }} {{ 'General_Ok'|translate }} - <br/> - {% else %} - {{ warning }} - <span class="warn">{{ 'Installation_NfsFilesystemWarning'|translate }}</span> - {% if duringInstall is not empty %} - <p>{{ 'Installation_NfsFilesystemWarningSuffixInstall'|translate }}</p> - {% else %} - <p>{{ 'Installation_NfsFilesystemWarningSuffixAdmin'|translate }}</p> - {% endif %} - {% endif %} - </td> - </tr> + </table> {% include "@Installation/_integrityDetails.twig" %}
\ No newline at end of file diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index d5d26a627d..c69f468b36 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -198,7 +198,12 @@ class Piwik_SitesManager_API public function getAllSitesId() { Piwik::checkUserIsSuperUser(); - return Piwik_SitesManager_API::getInstance()->getSitesId(); + try { + return Piwik_SitesManager_API::getInstance()->getSitesId(); + } catch(Exception $e) { + // can be called before Piwik tables are created so return empty + return array(); + } } /** |