Skip to content
This repository
Browse code

BUGFIX Fixed broken installer trying to include i18n thirdparty Zend

libs, which depends on Core.php being included first because include
paths are setup there first. This has the effect of removing redundant
code in the installer like temp path discovery, as Core takes care of
that for us.
  • Loading branch information...
commit dc0031cf26844082652220e645fa602fe587384f 1 parent e6007c2
Sean Harvey authored April 16, 2012
4  _register_database.php
... ...
@@ -1,13 +1,11 @@
1 1
 <?php
2 2
 
3 3
 // Register the SilverStripe provided databases
4  
-$frameworkPath = defined('FRAMEWORK_PATH') ? FRAMEWORK_PATH : FRAMEWORK_NAME;
5  
-
6 4
 DatabaseAdapterRegistry::register(
7 5
 	array(
8 6
 		'class' => 'MySQLDatabase',
9 7
 		'title' => 'MySQL 5.0+',
10  
-		'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php',
  8
+		'helperPath' => FRAMEWORK_PATH . '/dev/install/MySQLDatabaseConfigurationHelper.php',
11 9
 		'supported' => function_exists('mysql_connect'),
12 10
 	)
13 11
 );
72  dev/install/install.php5
@@ -19,9 +19,6 @@ ini_set('mysql.connect_timeout', 5);
19 19
 
20 20
 ini_set('max_execution_time', 0);
21 21
 
22  
-// enable the highest level of error reporting during installation (same as Core.php in framework)
23  
-error_reporting(E_ALL | E_STRICT);
24  
-
25 22
 // Include environment files
26 23
 $usingEnv = false;
27 24
 $envFileExists = false;
@@ -43,11 +40,8 @@ if($envFileExists) {
43 40
 	}
44 41
 }
45 42
 
46  
-include_once(FRAMEWORK_NAME . '/core/Object.php');
47  
-include_once(FRAMEWORK_NAME . '/view/TemplateGlobalProvider.php');
48  
-include_once(FRAMEWORK_NAME . '/i18n/i18n.php');
49  
-include_once(FRAMEWORK_NAME . '/dev/install/DatabaseConfigurationHelper.php');
50  
-include_once(FRAMEWORK_NAME . '/dev/install/DatabaseAdapterRegistry.php');
  43
+// include the core of the framework, we need this for dependencies like i18n, include paths etc
  44
+include_once(FRAMEWORK_NAME . '/core/Core.php');
51 45
 
52 46
 // Set default locale, but try and sniff from the user agent
53 47
 $locales = i18n::$common_locales;
@@ -345,7 +339,7 @@ class InstallRequirements {
345 339
 		}
346 340
 		$this->requireWriteable('assets', array("File permissions", "Is the assets/ directory writeable?", null));
347 341
 
348  
-		$tempFolder = $this->getTempFolder();
  342
+		$tempFolder = getTempFolder();
349 343
 		$this->requireTempFolder(array('File permissions', 'Is a temporary directory available?', null, $tempFolder));
350 344
 		if($tempFolder) {
351 345
 			// in addition to the temp folder being available, check it is writable
@@ -659,50 +653,16 @@ class InstallRequirements {
659 653
 		}
660 654
 	}
661 655
 
662  
-	function getTempFolder() {
663  
-		if (defined('TEMP_FOLDER')) {
664  
-			$sysTmp = TEMP_FOLDER;
665  
-		} elseif(file_exists($this->getBaseDir() . 'silverstripe-cache')) {
666  
-			$sysTmp = $this->getBaseDir();
667  
-		} elseif(function_exists('sys_get_temp_dir')) {
668  
-			$sysTmp = sys_get_temp_dir();
669  
-		} elseif(isset($_ENV['TMP'])) {
670  
-			$sysTmp = $_ENV['TMP'];
671  
-		} else {
672  
-			@$tmpFile = tempnam('adfadsfdas', '');
673  
-			@unlink($tmpFile);
674  
-			$sysTmp = dirname($tmpFile);
675  
-		}
676  
-
677  
-	    $worked = true;
678  
-	    $ssTmp = $sysTmp . DIRECTORY_SEPARATOR . 'silverstripe-cache';
679  
-
680  
-		if(!@file_exists($ssTmp)) {
681  
-			@$worked = mkdir($ssTmp);
682  
-
683  
-			if(!$worked) {
684  
-				$ssTmp = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'silverstripe-cache';
685  
-				$worked = true;
686  
-				if(!@file_exists($ssTmp)) {
687  
-					@$worked = mkdir($ssTmp);
688  
-				}
689  
-			}
690  
-		}
691  
-
692  
-		if($worked) return $ssTmp;
693  
-		else return false;
694  
-	}
695  
-
696 656
 	function requireTempFolder($testDetails) {
697 657
 		$this->testing($testDetails);
698 658
 
699  
-		$tempFolder = $this->getTempFolder();
  659
+		$tempFolder = getTempFolder();
700 660
 		if(!$tempFolder) {
701 661
 			$testDetails[2] = "Permission problem gaining access to a temp directory. " .
702 662
 				"Please create a folder named silverstripe-cache in the base directory " .
703 663
 				"of the installation and ensure it has the adequate permissions";
704 664
 			$this->error($testDetails);
705  
-	    }
  665
+		}
706 666
 	}
707 667
 
708 668
 	function requireApacheModule($moduleName, $testDetails) {
@@ -1002,6 +962,7 @@ class Installer extends InstallRequirements {
1002 962
 		$locale = isset($_POST['locale']) ? $_POST['locale'] : 'en_US';
1003 963
 		$type = $config['db']['type'];
1004 964
 		$dbConfig = $config['db'][$type];
  965
+		if(!isset($dbConfig['path'])) $dbConfig['path'] = '';
1005 966
 		if(!$dbConfig) {
1006 967
 			echo "<p style=\"color: red\">Bad config submitted</p><pre>";
1007 968
 			print_r($config);
@@ -1045,7 +1006,7 @@ PHP
1045 1006
 			$this->writeToFile("mysite/_config.php", <<<PHP
1046 1007
 <?php
1047 1008
 
1048  
-global \$project;
  1009
+Global \$project;
1049 1010
 \$project = 'mysite';
1050 1011
 
1051 1012
 global \$databaseConfig;
@@ -1108,8 +1069,6 @@ PHP
1108 1069
 		// Show errors as if you're in development mode
1109 1070
 		$_SESSION['isDev'] = 1;
1110 1071
 
1111  
-		require_once('core/Core.php');
1112  
-
1113 1072
 		$this->statusMessage("Building database schema...");
1114 1073
 
1115 1074
 		// Build database
@@ -1131,16 +1090,25 @@ PHP
1131 1090
 		$adminMember->Password = $config['admin']['password'];
1132 1091
 		$adminMember->PasswordEncryption = Security::get_password_encryption_algorithm();
1133 1092
 
1134  
-		// @todo Exception thrown if database with admin already exists with same Email
1135 1093
 		try {
1136  
-			$this->statusMessage('Creating default admin account...');
  1094
+			$this->statusMessage('Creating default CMS admin account...');
1137 1095
 			$adminMember->write();
1138 1096
 		} catch(Exception $e) {
1139  
-			$this->statusMessage('Admin account could not be created.');
  1097
+			$this->statusMessage(
  1098
+				sprintf('Warning: Default CMS admin account could not be created (error: %s)', $e->getMessage())
  1099
+			);
1140 1100
 		}
1141 1101
 
1142 1102
 		// Syncing filesystem (so /assets/Uploads is available instantly, see ticket #2266)
1143  
-		Filesystem::sync();
  1103
+		// show a warning if there was a problem doing so
  1104
+		try {
  1105
+			$this->statusMessage('Creating initial filesystem assets...');
  1106
+			Filesystem::sync();
  1107
+		} catch(Exception $e) {
  1108
+			$this->statusMessage(
  1109
+				sprintf('Warning: Creating initial filesystem assets failed (error: %s)', $e->getMessage())
  1110
+			);
  1111
+		}
1144 1112
 
1145 1113
 		$_SESSION['username'] = $config['admin']['username'];
1146 1114
 		$_SESSION['password'] = $config['admin']['password'];

0 notes on commit dc0031c

Please sign in to comment.
Something went wrong with that request. Please try again.