MidCOM svn: r11850 - in trunk/midcom/midcom.core/midcom: . services
services/auth/backend
bergie
midcom-commits at lists.midgard-project.org
Thu Aug 30 11:32:35 CEST 2007
Author: bergie
Date: Thu Aug 30 11:32:35 2007
New Revision: 11850
URL: http://trac.midgard-project.org/software/changeset/11850
Log:
Remove some unnecessary logging and legacy AIS code, refs #102
Modified:
trunk/midcom/midcom.core/midcom/application.php
trunk/midcom/midcom.core/midcom/services/auth/backend/simple.php
trunk/midcom/midcom.core/midcom/services/cache.php
trunk/midcom/midcom.core/midcom/services/i18n.php
Modified: trunk/midcom/midcom.core/midcom/application.php
==============================================================================
--- trunk/midcom/midcom.core/midcom/application.php (original)
+++ trunk/midcom/midcom.core/midcom/application.php Thu Aug 30 11:32:35 2007
@@ -463,7 +463,8 @@
// Initialize Root Topic
$root_topic = new midcom_db_topic($GLOBALS['midcom_config']['midcom_root_topic_guid']);
- if (! $root_topic)
+ if ( ! $root_topic
+ || !$root_topic->guid)
{
if (mgd_errno() == MGD_ERR_ACCESS_DENIED)
{
@@ -521,27 +522,25 @@
*
* @see midcom_application::_process()
*/
- function codeinit() {
- debug_push("midcom_application::codeinit");
-
+ function codeinit()
+ {
$oldcontext = $this->_currentcontext;
$this->_currentcontext = 0;
// Initialize the UI message stack from session
$this->uimessages->initialize();
- debug_add("Creating URL Parser with argc/v from global Environment", MIDCOM_LOG_DEBUG);
$topic = $this->get_context_data(MIDCOM_CONTEXT_ROOTTOPIC);
$this->_parser = new midcom_helper_urlparser($topic->id);
- if (!$this->_parser) {
- debug_add("URL Parser is not instantinated, Bailing out.", MIDCOM_LOG_ERROR);
+ if (!$this->_parser)
+ {
+ debug_push_class(__CLASS__, __FUNCTION__);
+ debug_add('URL Parser is not instantinated, bailing out.', MIDCOM_LOG_ERROR);
debug_pop();
- $this->generate_error(MIDCOM_ERRCRIT,$GLOBALS["midcom_errstr"]);
+ $this->generate_error(MIDCOM_ERRCRIT, $GLOBALS['midcom_errstr']);
}
- debug_print_r ("ARGC = {$GLOBALS['argc']}; ARGV =", $GLOBALS["argv"]);
-
$this->_process();
$this->_codeinit = false;
@@ -550,9 +549,6 @@
// Let metadata service add its meta tags
$this->metadata->populate_meta_head();
-
- debug_add("code-init finished", MIDCOM_LOG_INFO);
- debug_pop();
}
/**
@@ -561,11 +557,12 @@
* This function must be called in the content area of the
* Style template, usually <(content)>.
*/
- function content() {
- debug_push("midcom_application::content");
+ function content()
+ {
+ debug_push_class(__CLASS__, __FUNCTION__);
// Enter Context
- debug_add("Entering Context 0 (old Context: $this->_currentcontext)", MIDCOM_LOG_DEBUG);
+ debug_add("Entering Context 0 (old Context: {$this->_currentcontext})", MIDCOM_LOG_DEBUG);
$oldcontext = $this->_currentcontext;
$this->_currentcontext = 0;
$this->style->enter_context(0);
@@ -573,7 +570,7 @@
$this->_output();
// Leave Context
- debug_add("Leaving Context 0 (new Context: $oldcontext)", MIDCOM_LOG_DEBUG);
+ debug_add("Leaving Context 0 (new Context: {$oldcontext})", MIDCOM_LOG_DEBUG);
$this->style->leave_context();
$this->_currentcontext = $oldcontext;
@@ -660,18 +657,13 @@
*
* @param string $url The URL, relative to the Midgard Page, that is to be requested.
* @param Array $config A key=>value array with any configuration overrides.
- * @param int $type Any one of the MIDCOM_REQUEST_* constants (used for AIS only).
- * @param int $topicid The ID of the content root topic (used for AIS only).
- * @param string $urlparser_prefix The Prefix for the URL parser to use (used for AIS only).
* @return int The ID of the newly created context.
*/
- function dynamic_load($url, $config = array(), $type = MIDCOM_REQUEST_CONTENT, $topicid = null, $urlparser_prefix = null) {
- global $midcom_errstr;
-
+ function dynamic_load($url, $config = array(), $type = MIDCOM_REQUEST_CONTENT)
+ {
debug_push_class(__CLASS__, __FUNCTION__);
debug_add("Dynamic load of URL {$url}", MIDCOM_LOG_INFO);
- debug_add("Request Type is {$type}, optional Root Topic ID is {$topicid}");
if (substr($url, -5) == '.html')
{
@@ -682,17 +674,13 @@
&& $this->_status < MIDCOM_STATUS_CONTENT)
{
debug_add("dynamic_load content request called before content output phase. Aborting.", MIDCOM_LOG_ERROR);
+ debug_pop();
$this->generate_error(MIDCOM_ERRCRIT, "dynamic_load content request called before content output phase.");
- }
-
- if (!is_null($topicid) && is_null($urlparser_prefix))
- {
- $urlparser_prefix = $this->get_component_context(MIDCOM_CONTEXT_ANCHORPREFIX);
+ // This will exit
}
// Determine new Context ID and set $this->_currentcontext,
// enter that context and prepare its data structure.
-
$context = $this->_create_context();
$oldcontext = $this->_currentcontext;
$this->_currentcontext = $context;
@@ -700,14 +688,7 @@
$this->_context[$context][MIDCOM_CONTEXT_REQUESTTYPE] = $type;
$this->_context[$context][MIDCOM_CONTEXT_CONTENTTOPIC] = null;
$this->_context[$context][MIDCOM_CONTEXT_COMPONENT] = null;
- if (is_null($topicid))
- {
- $this->_context[$context][MIDCOM_CONTEXT_ROOTTOPIC] = $this->_context[0][MIDCOM_CONTEXT_ROOTTOPIC];
- }
- else
- {
- $this->_context[$context][MIDCOM_CONTEXT_ROOTTOPIC] = new midcom_db_topic($topicid);
- }
+ $this->_context[$context][MIDCOM_CONTEXT_ROOTTOPIC] = $this->_context[0][MIDCOM_CONTEXT_ROOTTOPIC];
$this->_context[$context][MIDCOM_CONTEXT_OUTPUT] = null;
$this->_context[$context][MIDCOM_CONTEXT_NAP] = null;
$this->_context[$context][MIDCOM_CONTEXT_PAGETITLE] = "";
@@ -733,22 +714,14 @@
$argv = explode ("/", $url);
}
- if (is_null($topicid))
- {
- $topic = $this->get_context_data(MIDCOM_CONTEXT_ROOTTOPIC);
- $this->_parser = new midcom_helper_urlparser($topic->id, $argv);
- }
- else
- {
- $this->_parser = new midcom_helper_urlparser($topicid, $argv, $urlparser_prefix);
- }
-
+ $topic = $this->get_context_data(MIDCOM_CONTEXT_ROOTTOPIC);
+ $this->_parser = new midcom_helper_urlparser($topic->id, $argv);
if (!$this->_parser)
{
debug_add("URL Parser could not be instantinated: $midcom_errstr", MIDCOM_LOG_ERROR);
debug_pop();
- $this->generate_error(MIDCOM_ERRCRIT, "URL Parser could not be instantinated: $midcom_errstr");
+ $this->generate_error(MIDCOM_ERRCRIT, "URL Parser could not be instantinated: {$GLOBALS['midcom_errstr']}");
}
// Processing, upon error the generate_error function will die here...
Modified: trunk/midcom/midcom.core/midcom/services/auth/backend/simple.php
==============================================================================
--- trunk/midcom/midcom.core/midcom/services/auth/backend/simple.php (original)
+++ trunk/midcom/midcom.core/midcom/services/auth/backend/simple.php Thu Aug 30 11:32:35 2007
@@ -39,23 +39,16 @@
*/
function midcom_services_auth_backend_simple ()
{
- debug_push_class(__CLASS__, __FUNCTION__);
-
$this->_cookie_id .= $GLOBALS['midcom_config']['auth_backend_simple_cookie_id'];
- debug_add("We have to use this cookie id: {$this->_cookie_id}");
- debug_pop();
return parent::midcom_services_auth_backend();
}
function read_login_session()
{
- debug_push_class(__CLASS__, __FUNCTION__);
-
- debug_print_r('Checking this Cookie Array:', $_COOKIE);
-
if (! array_key_exists($this->_cookie_id, $_COOKIE))
{
+ debug_push_class(__CLASS__, __FUNCTION__);
debug_add('There is no cookie, we cannot read the login session.');
debug_pop();
return false;
@@ -64,9 +57,10 @@
$data = explode('-', $_COOKIE[$this->_cookie_id]);
if (count($data) != 2)
{
+ debug_push_class(__CLASS__, __FUNCTION__);
debug_add("The cookie data could not be parsed, assuming tampered session.",
MIDCOM_LOG_ERROR);
- debug_add('Killing the cookie...');
+ debug_add('Killing the cookie...', MIDCOM_LOG_INFO);
$this->_delete_cookie();
debug_pop();
return false;
@@ -75,11 +69,11 @@
$session_id = $data[0];
$user_id = $data[1];
- debug_add("Extracted the user ID {$user_id} and the session ID {$session_id}.");
$this->user =& $_MIDCOM->auth->get_user($user_id);
if (! $this->user)
{
+ debug_push_class(__CLASS__, __FUNCTION__);
debug_add("The user ID {$user_id} is invalid, could not load the user from the database, assuming tampered session.",
MIDCOM_LOG_ERROR);
debug_add('Killing the cookie...');
@@ -92,6 +86,7 @@
if (! $this->session_id)
{
+ debug_push_class(__CLASS__, __FUNCTION__);
debug_add("The session {$this->session_id} is invalid (usually this means an expired session).",
MIDCOM_LOG_ERROR);
debug_add('Killing the cookie...');
@@ -100,7 +95,6 @@
return false;
}
- debug_pop();
return true;
}
Modified: trunk/midcom/midcom.core/midcom/services/cache.php
==============================================================================
--- trunk/midcom/midcom.core/midcom/services/cache.php (original)
+++ trunk/midcom/midcom.core/midcom/services/cache.php Thu Aug 30 11:32:35 2007
@@ -79,7 +79,7 @@
foreach ($GLOBALS['midcom_config']['cache_autoload_queue'] as $name)
{
- debug_add("Auto-Loading module {$name}", MIDCOM_LOG_INFO);
+ debug_add("Auto-Loading module {$name}", MIDCOM_LOG_DEBUG);
$this->load_module($name);
}
Modified: trunk/midcom/midcom.core/midcom/services/i18n.php
==============================================================================
--- trunk/midcom/midcom.core/midcom/services/i18n.php (original)
+++ trunk/midcom/midcom.core/midcom/services/i18n.php Thu Aug 30 11:32:35 2007
@@ -504,17 +504,16 @@
* suitable default language. Cookies have priority here.
*/
function _set_startup_langs()
- {
- debug_push("midcom_services_i18n::_set_startup_langs");
-
+ {
$this->_current_content_language_midgard = $_MIDGARD['lang'];
$this->_read_cookie();
if (!is_null ($this->_cookie_data))
{
- $this->_current_language = $this->_cookie_data["language"];
- $this->_current_charset = $this->_cookie_data["charset"];
- debug_add("Set current language to " . $this->_current_language . " with charset " . $this->_current_charset . " (cookie)", MIDCOM_LOG_INFO);
+ $this->_current_language = $this->_cookie_data['language'];
+ $this->_current_charset = $this->_cookie_data['charset'];
+ debug_push_class(__CLASS__, __FUNCTION__);
+ debug_add("Set current language to {$this->_current_language} with charset {$this->_current_charset} (source: cookie)", MIDCOM_LOG_INFO);
debug_pop();
return;
}
@@ -524,7 +523,8 @@
if ($content_language)
{
$this->_current_language = $content_language;
- debug_add("Set current language to " . $this->_current_language . " with charset (Midgard host language)", MIDCOM_LOG_INFO);
+ debug_push_class(__CLASS__, __FUNCTION__);
+ debug_add("Set current language to {$this->_current_language} (source: Midgard host language)", MIDCOM_LOG_INFO);
debug_pop();
return;
}
@@ -541,7 +541,8 @@
}
}
}
- debug_add("Set current language to " . $this->_current_language . " with charset " . $this->_current_charset. " (HTTP)", MIDCOM_LOG_INFO);
+ debug_push_class(__CLASS__, __FUNCTION__);
+ debug_add("Set current language to {$this->_current_language} with charset {$this->_current_charset} (Source: HTTP)", MIDCOM_LOG_INFO);
debug_pop();
}
@@ -551,27 +552,23 @@
*/
function _read_cookie ()
{
- debug_push("midcom_services_i18n::_read_cookie");
-
if (!isset ($_COOKIE))
{
- debug_add("No Cookies found at all.", MIDCOM_LOG_DEBUG);
- debug_pop();
return;
}
if (!array_key_exists("midcom_services_i18n",$_COOKIE))
{
- debug_add("No midcom_services_i18n Cookie on this site", MIDCOM_LOG_DEBUG);
- debug_pop();
return;
}
- $rawdata = base64_decode($_COOKIE["midcom_services_i18n"]);
+ $rawdata = base64_decode($_COOKIE['midcom_services_i18n']);
$array = unserialize($rawdata);
- if (! array_key_exists("language",$array) || ! array_key_exists("charset",$array))
+ if ( ! array_key_exists('language', $array)
+ || ! array_key_exists('charset', $array))
{
+ debug_push_class(__CLASS__, __FUNCTION__);
debug_add("Rejecting cookie, it seems invalid.", MIDCOM_LOG_DEBUG);
debug_pop();
return;
@@ -589,8 +586,6 @@
*/
function _read_http_negotiation ()
{
- debug_push("midcom_services_i18n::_read_http_negotiation");
-
$headers = getallheaders();
if (array_key_exists("Accept-Language", $headers))
@@ -631,7 +626,6 @@
$this->_http_lang[$lang] = $q;
}
arsort($this->_http_lang, SORT_NUMERIC);
- debug_print_r("Language preference array:", $this->_http_lang, MIDCOM_LOG_DEBUG);
}
if (array_key_exists("Accept-Charset", $headers))
@@ -672,10 +666,7 @@
$this->_http_charset[$lang] = $q;
}
arsort ($this->_http_charset, SORT_NUMERIC);
- debug_print_r("Charset preference array:", $this->_http_charset);
}
-
- debug_pop();
}
/**
More information about the midcom-commits
mailing list