Skip to content

Commit

Permalink
fixing strict errors and installer
Browse files Browse the repository at this point in the history
  • Loading branch information
ceeram committed May 6, 2013
1 parent e209283 commit 57b64a1
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 59 deletions.
5 changes: 3 additions & 2 deletions Core/Installer/Controller/InstallController.php
Expand Up @@ -235,7 +235,8 @@ public function beforeRender() {
* @return void
*/
public function index($step = null) {
if (filesize(APP . 'Config' . DS . 'database.php') > 0 && $this->Session->read('installing') == false) {
$file = APP . 'Config' . DS . 'database.php';
if (file_exists($file) && filesize($file) > 0 && $this->Session->read('installing') == false) {
$this->Session->setFlash(__d('installer', 'Infinitas has already been installed'));
$this->redirect('/');
}
Expand Down Expand Up @@ -363,7 +364,7 @@ public function _prepareInstall() {
public function _processInstall() {
$dbConfig = $this->Session->read('Install.database_config');

return $this->InstallerLib->installPlugins($dbConfig) && $this->InstallerLib->writeDbConfig($dbConfig);
return $this->InstallerLib->writeDbConfig($dbConfig) && $this->InstallerLib->installPlugins($dbConfig);
}

/**
Expand Down
19 changes: 7 additions & 12 deletions Core/Installer/Lib/InstallerEvents.php
Expand Up @@ -31,20 +31,15 @@ public function onSetupRoutes(Event $Event) {
InfinitasRouter::connect('/install/finish/*', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'finish'));
InfinitasRouter::connect('/install/:step', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'index'), array('pass' => array('step')));

if (!file_exists($databaseConfig) || filesize($databaseConfig) == 0) {
if (!file_exists($databaseConfig)) {
$file = fopen($databaseConfig, 'w');
fclose($file);
}

Configure::write('Session.save', 'php');
InfinitasRouter::connect('/', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'index'));
InfinitasRouter::connect('/*', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'index'));

InfinitasTheme::defaultThemeInstall();
if (file_exists($databaseConfig) && filesize($databaseConfig) > 0) {
return true;
}

return true;
Configure::write('Session.save', 'php');
InfinitasRouter::connect('/', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'index'));
InfinitasRouter::connect('/*', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'index'));

InfinitasTheme::defaultThemeInstall();
}

/**
Expand Down
15 changes: 10 additions & 5 deletions Core/Installer/Lib/InstallerLib.php
Expand Up @@ -149,7 +149,7 @@ public function __construct() {
}

$this->__paths = array(
'Config/database.php' => array(
'Config/' => array(
'type' => 'write',
'message' => 'The database configuration (%s) file should be writable during the ' .
'installation process. It should be set to be read-only once Infinitas has been installed.'
Expand Down Expand Up @@ -329,6 +329,8 @@ private function __validDbConfig($connection, $return = false) {
* Test if the details provided to connect to the database are correct
*/
public function testConnection($connection = array()) {
$file = APP . 'Config' . DS . 'database.php';
copy(APP . 'Config' . DS . 'database.php.default', $file);
$connection = $this->__validDbConfig($connection, true);
if (!$connection) {
return false;
Expand All @@ -337,21 +339,24 @@ public function testConnection($connection = array()) {
$adminConnectionDetails = (!isset($connection['Admin'])) ? false : array_merge($connection['Install'], $connection['Admin']);
$InstallerConnection = ConnectionManager::create('installer', $connection['Install']);
if (!is_callable(array($InstallerConnection, 'isConnected')) || !$InstallerConnection->isConnected()) {
unlink($file);
return false;
}

if (isset($connection['Admin']['login']) && trim($connection['Admin']['login']) != '') {
$InstallerRootConnection = ConnectionManager::create('admin', $adminConnectionDetails);
if (!is_callable(array($InstallerRootConnection, 'isConnected')) || !$InstallerRootConnection->isConnected()) {
unlink($file);
return false;
}
}

$version = $this->__databaseVersion($connection['Install']);
if (version_compare($version, $this->__supportedDatabases[$connection['Install']['datasource']]['version']) >= 0) {
unlink($file);
return true;
}

unlink($file);
return array(
'versionError' => $version,
'requiredDb' => $this->__supportedDatabases[$connection['Install']['datasource']]['version']
Expand Down Expand Up @@ -434,10 +439,9 @@ public function installPlugin($Version, $dbConfig, $plugin = 'app') {
* @return type
*/
public function writeDbConfig($dbConfig = array()) {
copy(CakePlugin::path('Installer') . 'Config' . DS . 'database.install', APP . 'Config' . DS . 'database.php');

$File = new File(APP . 'Config' . DS . 'database.php', true);
$File = new File(CakePlugin::path('Installer') . 'Config' . DS . 'database.install');
$content = $File->read();
$File->close();

$find = array(
'{default_datasource}',
Expand All @@ -463,6 +467,7 @@ public function writeDbConfig($dbConfig = array()) {

$content = str_replace($find, $replacements, $content);

$File = new File(APP . 'Config' . DS . 'database.php', true);
if ($File->write($content)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Installer/Lib/ReleaseVersion.php
Expand Up @@ -289,7 +289,7 @@ private function __initMigrations() {
*
* @param string $name File name to be loaded
* @param string $type Can be 'app' or a plugin name
*
*
* @return mixed Throw an exception in case of no file found, array with mapping
*/
private function __loadFile($name, $type) {
Expand Down
58 changes: 21 additions & 37 deletions Core/Newsletter/Config/releases/000092_Newsletter.php
Expand Up @@ -4,7 +4,7 @@
*
* Auto generated database update
*/

class R5103e49e7b444252aac80d7f6318cd70 extends CakeRelease {

/**
Expand All @@ -31,51 +31,35 @@ class R5103e49e7b444252aac80d7f6318cd70 extends CakeRelease {
*/
public $migration = array(
'up' => array(
'create_field' => array(
'newsletter_newsletters' => array(
'plugin' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 50, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'after' => 'id'),
'indexes' => array(
'newsletter_campaign_id' => array('column' => 'newsletter_campaign_id', 'unique' => 0),
'create_field' => array(
'newsletter_newsletters' => array(
'plugin' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 50, 'collate' => 'utf8_general_ci', 'charset' => 'utf8', 'after' => 'id'),
),
),
),
'alter_field' => array(
'newsletter_newsletters' => array(
'from' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'reply_to' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
'newsletter_subscribers' => array(
'active' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 3),
),
),
'drop_field' => array(
'newsletter_newsletters' => array('', 'indexes' => array('campaign_id')),
),
),
'down' => array(
'drop_field' => array(
'newsletter_newsletters' => array('plugin', 'indexes' => array('newsletter_campaign_id')),
),
'alter_field' => array(
'newsletter_newsletters' => array(
'from' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'reply_to' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
'newsletter_subscribers' => array(
'active' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
'alter_field' => array(
'newsletter_newsletters' => array(
'from' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'reply_to' => array('type' => 'string', 'null' => true, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
'newsletter_subscribers' => array(
'active' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 3),
),
),
),
'create_field' => array(
'newsletter_newsletters' => array(
'indexes' => array(
'campaign_id' => array('column' => 'newsletter_campaign_id', 'unique' => 0),
'down' => array(
'alter_field' => array(
'newsletter_newsletters' => array(
'from' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'reply_to' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 150, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
),
'newsletter_subscribers' => array(
'active' => array('type' => 'boolean', 'null' => false, 'default' => '0'),
),
),
),
),
);


/**
* Before migration callback
*
Expand Down
2 changes: 1 addition & 1 deletion Core/Newsletter/Model/NewsletterCampaign.php
Expand Up @@ -141,7 +141,7 @@ protected function _findPaginated($state, $query, $results = array()) {
*
* @return boolean
*/
protected function _findActive($state, array $query, array $results = array()) {
protected function _findActive($state, $query, $results = array()) {
if ($state === 'before') {
$query = self::_findPaginated($state, $query);

Expand Down
2 changes: 1 addition & 1 deletion webroot/.htaccess
Expand Up @@ -2,5 +2,5 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

0 comments on commit 57b64a1

Please sign in to comment.