diff --git a/core/Core.php b/core/Core.php index 73c2238d3..57632b827 100644 --- a/core/Core.php +++ b/core/Core.php @@ -286,16 +286,8 @@ Debug::loadErrorHandlers(); // HELPER FUNCTIONS function getSysTempDir() { - if(function_exists('sys_get_temp_dir')) { - $sysTmp = sys_get_temp_dir(); - } elseif(isset($_ENV['TMP'])) { - $sysTmp = $_ENV['TMP']; - } else { - $tmpFile = tempnam('adfadsfdas',''); - unlink($tmpFile); - $sysTmp = dirname($tmpFile); - } - return $sysTmp; + Deprecation::notice(3.0, 'Please use PHP function get_sys_temp_dir() instead.'); + return sys_get_temp_dir(); } /** @@ -319,7 +311,7 @@ function getTempFolder($base = null) { return $ssTmp; } - $sysTmp = getSysTempDir(); + $sysTmp = sys_get_temp_dir(); $worked = true; $ssTmp = "$sysTmp/$cachefolder"; @@ -336,9 +328,11 @@ function getTempFolder($base = null) { } if(!$worked) { - user_error("Permission problem gaining access to a temp folder. " . - "Please create a folder named silverstripe-cache in the base folder " . - "of the installation and ensure it has the correct permissions", E_USER_ERROR); + throw new Exception( + 'Permission problem gaining access to a temp folder. ' . + 'Please create a folder named silverstripe-cache in the base folder ' . + 'of the installation and ensure it has the correct permissions' + ); } return $ssTmp; @@ -416,7 +410,7 @@ function increase_memory_limit_to($memoryLimit = -1) { // Increase the memory limit if it's too low if($memoryLimit == -1 || translate_memstring($memoryLimit) > translate_memstring($curLimit)) { ini_set('memory_limit', $memoryLimit); - } + } return true; } diff --git a/dev/install/config-form.html b/dev/install/config-form.html index cd08fe900..3067c4216 100644 --- a/dev/install/config-form.html +++ b/dev/install/config-form.html @@ -45,8 +45,8 @@ hasWarnings()) { ?>
-

There are some issues that we recommend you look at before installing, however, you are still able to install the software. Please see below for details.
- If you are having problems meeting the requirements, see the server requirements.

+

There are some issues that we recommend you look at before installing, however, you are still able to install the software. +
Please see below for details. If you are having problems meeting the requirements, see the server requirements.

hasErrors() && !$adminReq->hasErrors()) { ?>

You're ready to install! Please confirm the configuration options below. Install SilverStripe

diff --git a/dev/install/install.php5 b/dev/install/install.php5 index ea81e6372..5005cd757 100644 --- a/dev/install/install.php5 +++ b/dev/install/install.php5 @@ -19,7 +19,6 @@ ini_set('mysql.connect_timeout', 5); ini_set('max_execution_time', 0); -// enable the highest level of error reporting during installation (same as Core.php in framework) error_reporting(E_ALL | E_STRICT); // Include environment files @@ -43,24 +42,95 @@ if($envFileExists) { } } -include_once(FRAMEWORK_NAME . '/core/Object.php'); -include_once(FRAMEWORK_NAME . '/view/TemplateGlobalProvider.php'); -include_once(FRAMEWORK_NAME . '/i18n/i18n.php'); -include_once(FRAMEWORK_NAME . '/dev/install/DatabaseConfigurationHelper.php'); -include_once(FRAMEWORK_NAME . '/dev/install/DatabaseAdapterRegistry.php'); +require_once FRAMEWORK_NAME . '/dev/install/DatabaseConfigurationHelper.php'; +require_once FRAMEWORK_NAME . '/dev/install/DatabaseAdapterRegistry.php'; // Set default locale, but try and sniff from the user agent -$locales = i18n::$common_locales; -$defaultLocale = i18n::get_locale(); -if(isset($_SERVER['HTTP_USER_AGENT'])) { - foreach($locales as $code => $details) { - $bits = explode('_', $code); - if(preg_match("/{$bits[0]}.{$bits[1]}/", $_SERVER['HTTP_USER_AGENT'])) { - $defaultLocale = $code; - break; - } - } -} +$defaultLocale = 'en_US'; +$locales = array( + 'af_ZA' => array('Afrikaans', 'Afrikaans'), + 'sq_AL' => array('Albanian', 'shqip'), + 'ar_EG' => array('Arabic', 'العربية'), + 'eu_ES' => array('Basque', 'euskera'), + 'be_BY' => array('Belarusian', 'Беларуская мова'), + 'bn_BD' => array('Bengali', 'বাংলা'), + 'bg_BG' => array('Bulgarian', 'български'), + 'ca_ES' => array('Catalan', 'català'), + 'zh_yue' => array('Chinese (Cantonese)', '廣東話 [广东话]'), + 'zh_cmn' => array('Chinese (Mandarin)', '普通話 [普通话]'), + 'hr_HR' => array('Croatian', 'Hrvatski'), + 'cs_CZ' => array('Czech', 'čeština'), + 'cy_GB' => array('Welsh', 'Welsh/Cymraeg'), + 'da_DK' => array('Danish', 'dansk'), + 'nl_NL' => array('Dutch', 'Nederlands'), + 'en_NZ' => array('English (NZ)', 'English (NZ)'), + 'en_US' => array('English (US)', 'English (US)'), + 'en_GB' => array('English (UK)', 'English (UK)'), + 'eo_XX' => array('Esperanto', 'Esperanto'), + 'et_EE' => array('Estonian', 'eesti keel'), + 'fo_FO' => array('Faroese', 'Føroyska'), + 'fi_FI' => array('Finnish', 'suomi'), + 'fr_FR' => array('French', 'français'), + 'gd_GB' => array('Gaelic', 'Gaeilge'), + 'gl_ES' => array('Galician', 'Galego'), + 'de_DE' => array('German', 'Deutsch'), + 'el_GR' => array('Greek', 'ελληνικά'), + 'gu_IN' => array('Gujarati', 'ગુજરાતી'), + 'ha_NG' => array('Hausa', 'حَوْسَ'), + 'he_IL' => array('Hebrew', 'עברית'), + 'hi_IN' => array('Hindi', 'हिन्दी'), + 'hu_HU' => array('Hungarian', 'magyar'), + 'is_IS' => array('Icelandic', 'Íslenska'), + 'id_ID' => array('Indonesian', 'Bahasa Indonesia'), + 'ga_IE' => array('Irish', 'Irish'), + 'it_IT' => array('Italian', 'italiano'), + 'ja_JP' => array('Japanese', '日本語'), + 'jv_ID' => array('Javanese', 'basa Jawa'), + 'ko_KR' => array('Korean', '한국어 [韓國語]'), + 'ku_IQ' => array('Kurdish', 'Kurdí'), + 'lv_LV' => array('Latvian', 'latviešu'), + 'lt_LT' => array('Lithuanian', 'lietuviškai'), + 'mk_MK' => array('Macedonian', 'македонски'), + 'mi_NZ' => array('Maori', 'Maori'), + 'ms_MY' => array('Malay', 'Bahasa melayu'), + 'mt_MT' => array('Maltese', 'Malti'), + 'mr_IN' => array('Marathi', 'मराठी'), + 'ne_NP' => array('Nepali', 'नेपाली'), + 'nb_NO' => array('Norwegian', 'Norsk'), + 'om_ET' => array('Oromo', 'Afaan Oromo'), + 'fa_IR' => array('Persian', 'فارسى'), + 'pl_PL' => array('Polish', 'polski'), + 'pt_PT' => array('Portuguese (Portugal)', 'português (Portugal)'), + 'pt_BR' => array('Portuguese (Brazil)', 'português (Brazil)'), + 'pa_IN' => array('Punjabi', 'ਪੰਜਾਬੀ'), + 'qu_PE' => array('Quechua', 'Quechua'), + 'rm_CH' => array('Romansh', 'rumantsch'), + 'ro_RO' => array('Romanian', 'român'), + 'ru_RU' => array('Russian', 'Русский'), + 'sco_SCO' => array('Scots', 'Scoats leid, Lallans'), + 'sr_RS' => array('Serbian', 'српски'), + 'sk_SK' => array('Slovak', 'slovenčina'), + 'sl_SI' => array('Slovenian', 'slovenščina'), + 'es_ES' => array('Spanish', 'español'), + 'sv_SE' => array('Swedish', 'Svenska'), + 'tl_PH' => array('Tagalog', 'Tagalog'), + 'ta_IN' => array('Tamil', 'தமிழ்'), + 'te_IN' => array('Telugu', 'తెలుగు'), + 'to_TO' => array('Tonga', 'chiTonga'), + 'ts_ZA' => array('Tsonga', 'xiTshonga'), + 'tn_ZA' => array('Tswana', 'seTswana'), + 'tr_TR' => array('Turkish', 'Türkçe'), + 'tk_TM' => array('Turkmen', 'түркmенче'), + 'tw_GH' => array('Twi', 'twi'), + 'uk_UA' => array('Ukrainian', 'Українська'), + 'ur_PK' => array('Urdu', 'اردو'), + 'uz_UZ' => array('Uzbek', 'ўзбек'), + 've_ZA' => array('Venda', 'tshiVenḓa'), + 'vi_VN' => array('Vietnamese', 'tiếng việt'), + 'wo_SN' => array('Wolof', 'Wollof'), + 'xh_ZA' => array('Xhosa', 'isiXhosa'), + 'zu_ZA' => array('Zulu', 'isiZulu'), +); // Discover which databases are available DatabaseAdapterRegistry::autodiscover(); @@ -655,37 +725,25 @@ class InstallRequirements { } function getTempFolder() { - if (defined('TEMP_FOLDER')) { - $sysTmp = TEMP_FOLDER; - } elseif(file_exists($this->getBaseDir() . 'silverstripe-cache')) { - $sysTmp = $this->getBaseDir(); - } elseif(function_exists('sys_get_temp_dir')) { - $sysTmp = sys_get_temp_dir(); - } elseif(isset($_ENV['TMP'])) { - $sysTmp = $_ENV['TMP']; - } else { - @$tmpFile = tempnam('adfadsfdas', ''); - @unlink($tmpFile); - $sysTmp = dirname($tmpFile); - } - - $worked = true; - $ssTmp = $sysTmp . DIRECTORY_SEPARATOR . 'silverstripe-cache'; + $sysTmp = sys_get_temp_dir(); + $worked = true; + $ssTmp = "$sysTmp/silverstripe-cache"; if(!@file_exists($ssTmp)) { @$worked = mkdir($ssTmp); + } - if(!$worked) { - $ssTmp = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'silverstripe-cache'; - $worked = true; - if(!@file_exists($ssTmp)) { - @$worked = mkdir($ssTmp); - } + if(!$worked) { + $ssTmp = dirname($_SERVER['SCRIPT_FILENAME']) . '/silverstripe-cache'; + $worked = true; + if(!@file_exists($ssTmp)) { + @$worked = mkdir($ssTmp); } } if($worked) return $ssTmp; - else return false; + + return false; } function requireTempFolder($testDetails) { @@ -695,9 +753,9 @@ class InstallRequirements { if(!$tempFolder) { $testDetails[2] = "Permission problem gaining access to a temp directory. " . "Please create a folder named silverstripe-cache in the base directory " . - "of the installation and ensure it has the adequate permissions"; + "of the installation and ensure it has the adequate permissions."; $this->error($testDetails); - } + } } function requireApacheModule($moduleName, $testDetails) { @@ -997,6 +1055,7 @@ class Installer extends InstallRequirements { $locale = isset($_POST['locale']) ? $_POST['locale'] : 'en_US'; $type = $config['db']['type']; $dbConfig = $config['db'][$type]; + if(!isset($dbConfig['path'])) $dbConfig['path'] = ''; if(!$dbConfig) { echo "

Bad config submitted

";
 			print_r($config);
@@ -1103,10 +1162,10 @@ PHP
 		// Show errors as if you're in development mode
 		$_SESSION['isDev'] = 1;
 
-		require_once('core/Core.php');
-
 		$this->statusMessage("Building database schema...");
 
+		require_once 'core/Core.php';
+
 		// Build database
 		$con = new Controller();
 		$con->pushCurrent();
@@ -1126,16 +1185,25 @@ PHP
 		$adminMember->Password = $config['admin']['password'];
 		$adminMember->PasswordEncryption = Security::get_password_encryption_algorithm();
 
-		// @todo Exception thrown if database with admin already exists with same Email
 		try {
-			$this->statusMessage('Creating default admin account...');
+			$this->statusMessage('Creating default CMS admin account...');
 			$adminMember->write();
 		} catch(Exception $e) {
-			$this->statusMessage('Admin account could not be created.');
+			$this->statusMessage(
+				sprintf('Warning: Default CMS admin account could not be created (error: %s)', $e->getMessage())
+			);
 		}
 
 		// Syncing filesystem (so /assets/Uploads is available instantly, see ticket #2266)
-		Filesystem::sync();
+		// show a warning if there was a problem doing so
+		try {
+			$this->statusMessage('Creating initial filesystem assets...');
+			Filesystem::sync();
+		} catch(Exception $e) {
+			$this->statusMessage(
+				sprintf('Warning: Creating initial filesystem assets failed (error: %s)', $e->getMessage())
+			);
+		}
 
 		$_SESSION['username'] = $config['admin']['username'];
 		$_SESSION['password'] = $config['admin']['password'];
diff --git a/tests/core/CoreTest.php b/tests/core/CoreTest.php
index ce45407a4..c3a1e44d7 100644
--- a/tests/core/CoreTest.php
+++ b/tests/core/CoreTest.php
@@ -20,26 +20,26 @@ class CoreTest extends SapphireTest {
 			$this->assertEquals(getTempFolder(), $this->tempPath);
 		} else {
 			// A typical Windows location for where sites are stored on IIS
-			$this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), getSysTempDir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
+			$this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
 
 			// A typical Mac OS X location for where sites are stored
-			$this->assertEquals(getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'), getSysTempDir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
+			$this->assertEquals(getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
 
 			// A typical Linux location for where sites are stored
-			$this->assertEquals(getTempFolder('/var/www/silverstripe-test-project'), getSysTempDir() . '/silverstripe-cache-var-www-silverstripe-test-project');
+			$this->assertEquals(getTempFolder('/var/www/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project');
 		}
 	}
 
 	public function tearDown() {
 		parent::tearDown();
-		if(file_exists(getSysTempDir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project')) {
-			rmdir(getSysTempDir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
+		if(file_exists(sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project')) {
+			rmdir(sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
 		}
-		if(file_exists(getSysTempDir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project')) {
-			rmdir(getSysTempDir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
+		if(file_exists(sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project')) {
+			rmdir(sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
 		}
-		if(file_exists(getSysTempDir() . '/silverstripe-cache-var-www-silverstripe-test-project')) {
-			rmdir(getSysTempDir() . '/silverstripe-cache-var-www-silverstripe-test-project');
+		if(file_exists(sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project')) {
+			rmdir(sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project');
 		}
 	}
 
diff --git a/thirdparty/tinymce/tiny_mce_gzip.php b/thirdparty/tinymce/tiny_mce_gzip.php
index a75a898c0..21adf61ff 100755
--- a/thirdparty/tinymce/tiny_mce_gzip.php
+++ b/thirdparty/tinymce/tiny_mce_gzip.php
@@ -9,29 +9,12 @@
  * Contributing: http://tinymce.moxiecode.com/contributing
  */
 
-// CUSTOM SilverStripe: Copied from Core.php
-if(!function_exists('getSysTempDir')) {
-	function getSysTempDir() {
-		if(function_exists('sys_get_temp_dir')) {
-			$sysTmp = sys_get_temp_dir();
-		} elseif(isset($_ENV['TMP'])) {
-			$sysTmp = $_ENV['TMP'];    	
-		} else {
-			$tmpFile = tempnam('adfadsfdas','');
-			unlink($tmpFile);
-			$sysTmp = dirname($tmpFile);
-		}
-		return $sysTmp;
-	}	
-}
-// CUSTOM END
-
 // Handle incoming request if it's a script call
 if (TinyMCE_Compressor::getParam("js")) {
 	// Default settings
 	$tinyMCECompressor = new TinyMCE_Compressor(array(
 		// CUSTOM SilverStripe
-		'cache_dir' => getSysTempDir()
+		'cache_dir' => sys_get_temp_dir()
 		// CUSTOM END
 	));