[Pkg-owncloud-commits] [owncloud] 309/394: Backport of #1113 should fix #622

David Prévot taffit at alioth.debian.org
Fri Nov 8 23:12:37 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.

commit 8c3519acf32ddf9107800ed0f1f922dde4c9daa0
Author: Brice Maron <brice at bmaron.net>
Date:   Sat Jan 26 16:09:16 2013 +0000

    Backport of #1113 should fix #622
---
 core/js/js.js                   |    2 +-
 core/templates/layout.base.php  |    1 -
 core/templates/layout.guest.php |    1 -
 lib/db.php                      |   17 ++++++++++++++---
 lib/setup.php                   |    2 ++
 lib/template.php                |    1 +
 lib/templatelayout.php          |   17 ++++++-----------
 7 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/core/js/js.js b/core/js/js.js
index e3590c1..4018dc8 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -56,7 +56,7 @@ var OC={
 	PERMISSION_DELETE:8,
 	PERMISSION_SHARE:16,
 	webroot:oc_webroot,
-	appswebroots:oc_appswebroots,
+	appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
 	currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
 	coreApps:['', 'admin','log','search','settings','core','3rdparty'],
 	/**
diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php
index f78b6ff..3323d84 100644
--- a/core/templates/layout.base.php
+++ b/core/templates/layout.base.php
@@ -9,7 +9,6 @@
 		<?php endforeach; ?>
 		<script type="text/javascript">
 			var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
-			var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
 			var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
 			var oc_requestlifespan = '<?php echo $_['requestlifespan']; ?>';
 		</script>
diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php
index 6f59e18..084974f 100644
--- a/core/templates/layout.guest.php
+++ b/core/templates/layout.guest.php
@@ -9,7 +9,6 @@
 		<?php endforeach; ?>
 		<script type="text/javascript">
 			var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
-			var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
 			var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
 			var oc_requestlifespan = '<?php echo $_['requestlifespan']; ?>';
 		</script>
diff --git a/lib/db.php b/lib/db.php
index 4c1c18f..57feebe 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -147,7 +147,7 @@ class OC_DB {
 						$dsn='pgsql:dbname='.$name.';host='.$host;
 					}
 					/**
-					* Ugly fix for pg connections pbm when password use spaces
+					* Ugly fix for pg connections pbm when password use spaces (php#62479)
 					*/
 					$e_user = addslashes($user);
 					$e_password = addslashes($pass);
@@ -168,7 +168,13 @@ class OC_DB {
 			try{
 				self::$PDO=new PDO($dsn, $user, $pass, $opts);
 			}catch(PDOException $e) {
-				OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.$e->getMessage().')' );
+			  OC_Log::write('core', $e->getMessage(), OC_Log::FATAL);
+				OC_User::setUserId(null);
+				// send http status 503
+				header('HTTP/1.1 503 Service Temporarily Unavailable');
+				header('Status: 503 Service Temporarily Unavailable');
+				OC_Template::printErrorPage('Failed to connect to database');
+				die();
 			}
 			// We always, really always want associative arrays
 			self::$PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
@@ -262,7 +268,12 @@ class OC_DB {
 
 			// Die if we could not connect
 			if( PEAR::isError( self::$MDB2 )) {
-				OC_Template::printErrorPage( 'can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')' );
+				OC_User::setUserId(null);
+
+				header('HTTP/1.1 503 Service Temporarily Unavailable');
+				header('Status: 503 Service Temporarily Unavailable');
+				OC_Template::printErrorPage('Failed to connect to database');
+				die();
 			}
 
 			// We always, really always want associative arrays
diff --git a/lib/setup.php b/lib/setup.php
index 8e9ffd1..7097d11 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -386,6 +386,8 @@ class OC_Setup {
 			if(count($error) == 0) {
 				OC_Appconfig::setValue('core', 'installedat',microtime(true));
 				OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true));
+				OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
+				OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
 
 				OC_Group::createGroup('admin');
 				OC_Group::addToGroup($username, 'admin');
diff --git a/lib/template.php b/lib/template.php
index f58e6e6..7fbfa15 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -490,6 +490,7 @@ class OC_Template{
 		*/
 	public static function printErrorPage( $error_msg, $hint = '' ) {
 		$errors = array(array('error' => $error_msg, 'hint' => $hint));
+		OC_Util::addStyle( "styles" );
 		OC_Template::printGuestPage("", "error", array("errors" => $errors));
 		die();
 	}
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 715b68c..a6842c2 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -29,23 +29,18 @@ class OC_TemplateLayout extends OC_Template {
 					break;
 				}
 			}
+			$apps_paths = array();
+			foreach(OC_App::getEnabledApps() as $app) {
+				$apps_paths[$app] = OC_App::getAppWebPath($app);
+			}
+			$this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes
+
 		} else if ($renderas == 'guest') {
 			parent::__construct('core', 'layout.guest');
 		} else {
 			parent::__construct('core', 'layout.base');
 		}
 
-		$apps_paths = array();
-		foreach(OC_App::getEnabledApps() as $app) {
-			$apps_paths[$app] = OC_App::getAppWebPath($app);
-		}
-		$this->assign( 'apps_paths', str_replace('\\/', '/',json_encode($apps_paths)),false ); // Ugly unescape slashes waiting for better solution
-
-		if (OC_Config::getValue('installed', false) && !OC_AppConfig::getValue('core', 'remote_core.css', false)) {
-			OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
-			OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
-		}
-
 		// Add the js files
 		$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
 		$this->assign('jsfiles', array(), false);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list