From df785ee14455a9b6730943e28030ad2ee6e1ecb7 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Mon, 1 Oct 2012 22:18:16 +0000
Subject: [PATCH] Installation phase fixed (even more): - Fixed handling of
 flushing filters while in installation phase. This didn't   let all
 registered filters by extensions flush to database - Added stubs for upcoming
 rewrite of install-inc.php - Commented out very noisy debug line - TODOs.txt
 updated

---
 .gitattributes               |  2 ++
 DOCS/TODOs.txt               |  2 +-
 inc/extensions-functions.php |  2 +-
 inc/filters.php              | 18 ++++++---------
 inc/install/.htaccess        |  1 +
 inc/install/install-inc_     | 44 ++++++++++++++++++++++++++++++++++++
 6 files changed, 56 insertions(+), 13 deletions(-)
 create mode 100644 inc/install/.htaccess
 create mode 100644 inc/install/install-inc_

diff --git a/.gitattributes b/.gitattributes
index 69ce45db49..6ca8e40900 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -263,6 +263,8 @@ inc/img/.htaccess svneol=native#text/plain
 inc/inc-functions.php svneol=native#text/plain
 inc/install-functions.php svneol=native#text/plain
 inc/install-inc.php svneol=native#text/plain
+inc/install/.htaccess svneol=native#text/plain
+inc/install/install-inc_ svneol=native#text/plain
 inc/js/.htaccess svneol=native#text/plain
 inc/js/js- svneol=native#text/plain
 inc/js/js-admin_ajax.php svneol=native#text/plain
diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt
index 423b8bc3dc..b4f89f440e 100644
--- a/DOCS/TODOs.txt
+++ b/DOCS/TODOs.txt
@@ -185,7 +185,7 @@
 ./inc/template-functions.php:285:	// @TODO Remove these sanity checks if all is fine
 ./inc/template-functions.php:598:// @TODO $simple/$constants are deprecated
 ./inc/template-functions.php:696:			// @TODO $userid is deprecated and should be removed from loadEmailTemplate() and replaced with $content[userid] in all templates
-./inc/wrapper-functions.php:2956:	// @TODO Find a way to not use direct module comparison
+./inc/wrapper-functions.php:2968:	// @TODO Find a way to not use direct module comparison
 ./inc/wrapper-functions.php:494:// @TODO Do some more sanity check here
 ./inc/xml-functions.php:208:	// @TODO Handle characters
 ./mailid.php:102:		// @TODO Rewrite this to a filter
diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php
index 184df7cd02..022440a79d 100644
--- a/inc/extensions-functions.php
+++ b/inc/extensions-functions.php
@@ -1571,7 +1571,7 @@ function addExtensionSql ($sql) {
 	} // END - if
 
 	// Add it
-	/* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',ext_version=' . getCurrentExtensionVersion() . ',sql=' . $sql);
+	//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',ext_version=' . getCurrentExtensionVersion() . ',sql=' . $sql);
 	array_push($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()], $sql);
 }
 
diff --git a/inc/filters.php b/inc/filters.php
index 2bfb349587..3437775a70 100644
--- a/inc/filters.php
+++ b/inc/filters.php
@@ -45,21 +45,17 @@ function FILTER_FLUSH_FILTERS () {
 	// Clear all previous SQL queries
 	initSqls();
 
-	// Are we installing?
-	if ((isInstallationPhase())) {
-		// Then silently skip this filter
-		return true;
-	} // END - if
-
 	// Is a database link here and not in installation mode?
-	if ((!SQL_IS_LINK_UP()) && (!isInstalling())) {
+	if ((!SQL_IS_LINK_UP()) && (!isInstallationPhase())) {
 		// Abort here
 		reportBug(__FUNCTION__, __LINE__, 'No database link is up. Cannot flush filters.');
-		return false;
-	} // END - if
+	} elseif ((isInstallationPhase()) && (!SQL_IS_LINK_UP())) {
+		// If the link is not up in installation phase, skip flushing filters
+		return;
+	}
 
-	// Is the extension ext-sql_patches updated?
-	if ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9'))) {
+	// Is the extension ext-sql_patches updated and not in installation phase?
+	if ((!isInstallationPhase()) && ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9')))) {
 		// Log only in debug mode
 		if (isDebugModeEnabled()) {
 			logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9')));
diff --git a/inc/install/.htaccess b/inc/install/.htaccess
new file mode 100644
index 0000000000..3a42882788
--- /dev/null
+++ b/inc/install/.htaccess
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/install/install-inc_ b/inc/install/install-inc_
new file mode 100644
index 0000000000..9449a58188
--- /dev/null
+++ b/inc/install/install-inc_
@@ -0,0 +1,44 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 10/02/2012 *
+ * ===================                          Last change: 10/02/2012 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : install-inc_                                     *
+ * -------------------------------------------------------------------- *
+ * Short description : Installation page include file                   *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Include-Datei fuer Installationsseite            *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if ((!defined('__SECURITY')) || (!isInstallationPhase())) {
+	die();
+} // END - if
+
+// [EOF]
+?>
-- 
2.39.5