X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fextensions-functions.php;h=3ac6e884603d8550f7edb6564cd55d3ca58f8d49;hp=7e65fe9c0d8ce6cac7a88d719084438f5851ae44;hb=63f159414369b5ea19a8ca75d8cd8033c45d8341;hpb=a454def0bfba8288ffc839d034c710f034cf4728 diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 7e65fe9c0d..3ac6e88460 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2011 by Mailer Developer Team * + * 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 * @@ -42,12 +42,12 @@ if (!defined('__SECURITY')) { // Load the extension and maybe found language and function files. function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = false) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_mode=' . $ext_mode . ',ext_ver=' . $ext_ver . ',dry_run=' . intval($dry_run)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_mode=' . $ext_mode . ',ext_ver=' . $ext_ver . ',dry_run=' . intval($dry_run) . ' - ENTERED!'); // Loading an extension in same mode, but not test/update, twice is not // good, so is the extension $ext_name already loaded in mode $ext_mode? if ((isset($GLOBALS['loaded_extension'][$ext_name][$ext_mode])) && (!in_array($ext_mode, array('update', 'test')))) { // If this happens twice, we need the bug report from you, except for updates/tests - debug_report_bug(__FUNCTION__, __LINE__, __FUNCTION__ . '() is called twice: ext_name=' . $ext_name . ', ext_mode='. $ext_mode . ',ext_sqls=' . print_r(getExtensionSqls(), true) . ', ext_register_running=' . print_r($GLOBALS['ext_register_running'], true) . ', ext_running_updates=' . print_r($GLOBALS['ext_running_updates'], true)); + reportBug(__FUNCTION__, __LINE__, __FUNCTION__ . '() is called twice: ext_name=' . $ext_name . ', ext_mode='. $ext_mode . ',ext_sqls=' . print_r(getExtensionSqls(), true) . ', ext_register_running=' . print_r($GLOBALS['ext_register_running'], true) . ', ext_running_updates=' . print_r($GLOBALS['ext_running_updates'], true)); } // END - if // Make sure this situation can only happen once @@ -78,7 +78,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal // In all but test-mode we need these messages to debug! Please report all (together, e.g.) if (($ext_mode != 'test') && (getCurrentExtensionVersion() == '0.0.0')) { // Abort here, this must now always be set! - debug_report_bug(__FUNCTION__, __LINE__, 'Extension version is empty, setting to 0.0. ext_name=' . $ext_name . ', ext_mode=' . $ext_mode . ', dry_run=' . intval($dry_run)); + reportBug(__FUNCTION__, __LINE__, 'Extension version is empty, setting to 0.0. ext_name=' . $ext_name . ', ext_mode=' . $ext_mode . ', dry_run=' . intval($dry_run)); } // END - if } @@ -98,7 +98,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal initExtensionSqls(); // Is the extension already loaded? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Loading extension ' . $ext_name . ', mode=' . getExtensionMode() . ', ver=' . getCurrentExtensionVersion()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Loading extension ' . $ext_name . ', getExtensionMode()=' . getExtensionMode() . ', getCurrentExtensionVersion()=' . getCurrentExtensionVersion()); if ((isExtensionLoaded($ext_name)) && (getExtensionMode() == 'init')) { // Debug message logDebugMessage(__FUNCTION__, __LINE__, sprintf("Extension %s already loaded.", $ext_name)); @@ -110,7 +110,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal // Is the extension file NOT there? if (!isExtensionNameValid($ext_name)) { // Debug message - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Extension %s not found or not readable.", $ext_name)); + logDebugMessage(__FUNCTION__, __LINE__, sprintf("Extension %s not found or not readable or the PHP script is deprecated.", $ext_name)); // Abort here return false; @@ -179,7 +179,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal // Registers an extension and possible update dependencies function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates = false) { // Set current extension name - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . $taskId . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . intval($taskId) . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - ENTERED!'); setCurrentExtensionName($ext_name); // Enable dry-run @@ -189,8 +189,9 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates enableExtensionProductive(); // This shall never do a non-admin user or if the extension is active (already installed) - if ((!isAdmin()) || (isExtensionInstalled($ext_name))) { + if (((!isAdmin()) && (!isInstallationPhase())) || (isExtensionInstalled($ext_name))) { // Abort here with 'false' + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - ABORTED: isAdmin()=' . intval(isAdmin()) . ',isInstallationPhase()=' . intval(isInstallationPhase()) . ',isExtensionInstalled()=' . intval(isExtensionInstalled($ext_name))); return false; } // END - if @@ -198,7 +199,7 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates if ((isExtensionRegistrationRunning($ext_name)) || ((isExtensionUpdateRunning($ext_name)) && ($ignoreUpdates === false))) { // Then abort here with 'true' becaus it is fine //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in registration/update phase, all fine,taskId=' . $taskId . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates)); - ///* BUG: */ debug_report_bug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId=' . $taskId . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - Please investigate!'); + //* BUG: */ reportBug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId=' . $taskId . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - Please investigate!'); return true; } // END - if @@ -212,7 +213,7 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates } // END - if // Is the task id zero? Then we need to auto-fix it here - if ($taskId == '0') { + if (($taskId == '0') && (!isInstallationPhase())) { // Try to find the task $taskId = determineExtensionTaskId(getCurrentExtensionName()); @@ -224,7 +225,7 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates // Is it still zero? if ($taskId == '0') { // Then request a bug report - debug_report_bug(__FUNCTION__, __LINE__, sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)", + reportBug(__FUNCTION__, __LINE__, sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)", __FUNCTION__, getCurrentExtensionName() )); @@ -245,7 +246,7 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates enableExtensionReportingFailure(); // Does this extension exists? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ' - CALLING loadExtension() ...'); if (loadExtension(getCurrentExtensionName(), 'register', '0.0.0', isExtensionDryRun())) { // Set current extension name again setCurrentExtensionName($ext_name); @@ -284,12 +285,14 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates } // END - if // Extension version set? If empty the extension is not registered + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_ver[' . gettype($ext_ver) . ']=' . $ext_ver . ',isInstallationPhase()=' . intval(isInstallationPhase()) . ',currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ' - EMPTY?'); if (empty($ext_ver)) { // Extension not registered so far so first load task's id... $taskId = determineExtensionTaskId($ext_update); // Entry found? - if ($taskId > 0) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'taskId=' . $taskId . ',isInstallationPhase()=' . intval(isInstallationPhase()) . ',currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ' - CHECKING!'); + if (($taskId > 0) || (isInstallationPhase())) { // Try to register the extension //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ',taskId=' . $taskId . ',isExtensionDryRun()=' . isExtensionDryRun()); $processResult = registerExtension($ext_update, $taskId, isExtensionDryRun(), true); @@ -414,16 +417,27 @@ function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates array(bigintval($taskId)), __FUNCTION__, __LINE__); } + // @TODO This redirect is still needed to register sql_patches! Please try to avoid it + if (($ret === true) && ($dry_run === false) && ($ext_name == 'sql_patches') && (!isInstallationPhase())) { + /* + * This is a really dirty hack to prevent an error about a missing + * configuration entry which should be there after registration of + * ext-sql_patches. + */ + redirectToRequestUri(); + } // END - if + // Return status code - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ',processResult=' . intval($processResult) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',currName=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ',processResult=' . intval($processResult) . ',ret=' . intval($ret) . ' - EXIT!'); return $ret; } // Run SQL queries for given extension id // @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) function doExtensionSqls ($ext_id, $load_mode) { - // This shall never do a non-admin user! - if (!isAdmin()) { + // This shall never do a non-admin user but installation phase is okay + if ((!isAdmin()) && (!isInstallationPhase())) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_id=' . $ext_id. ',load_mode=' . $load_mode . ',isAdmin()=' . intval(isAdmin()) . ',isInstallationPhase()=' . intval(isInstallationPhase()) . ' - ABORT!'); return false; } // END - if @@ -466,7 +480,7 @@ function doExtensionSqls ($ext_id, $load_mode) { runFilterChain('extension_' . $load_mode); // Remove cache file(s) if extension is active - if (((isExtensionActive('cache')) && ((!SQL_HASZEROAFFECTED())) || ($sqlRan === true) || ($load_mode == 'activate') || ($load_mode == 'deactivate'))) { + if (((isExtensionActive('cache')) && ((!SQL_HASZEROAFFECTED()) || ($sqlRan === true) || ($load_mode == 'activate') || ($load_mode == 'deactivate')))) { // Run filters runFilterChain('post_extension_run_sql', getCurrentExtensionName()); } // END - if @@ -480,13 +494,13 @@ function doExtensionSqls ($ext_id, $load_mode) { } // END - if } -// Check wether the given extension is installed +// Check whether the given extension is installed function isExtensionInstalled ($ext_name) { // We don't like empty extension names here //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - ENTERED!'); if (empty($ext_name)) { // Please fix them all - debug_report_bug(__FUNCTION__, __LINE__, 'ext_name is empty.'); + reportBug(__FUNCTION__, __LINE__, 'ext_name is empty.'); } // END - if // By default non is installed @@ -504,9 +518,9 @@ function isExtensionInstalled ($ext_name) { // Count cache hits incrementStatsEntry('cache_hits'); - } elseif ((isInstallationPhase())) { + } elseif (isInstallationPhase()) { // Extensions are all inactive/not installed during installation - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - installion phase'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - installation phase detected.'); } else { // Look in database $ext_id = getExtensionId($ext_name); @@ -536,12 +550,14 @@ function isExtensionInstalled ($ext_name) { function isExtensionActive ($ext_name) { if (isInstallationPhase()) { // Extensions are all inactive during installation + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Extensions are always inactive while installation phase. ext_name=' . $ext_name); return false; } elseif (empty($ext_name)) { // Empty extension names must befixed - debug_report_bug(__FUNCTION__, __LINE__, 'Empty extension name provided.'); + reportBug(__FUNCTION__, __LINE__, 'Empty extension name provided.'); } elseif (!isExtensionInstalled($ext_name)) { // Not installed extensions are always inactive + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not installed extensions are always inactive. ext_name=' . $ext_name); return false; } @@ -558,7 +574,7 @@ function isExtensionActive ($ext_name) { incrementStatsEntry('cache_hits'); } elseif (isExtensionLoaded($ext_name)) { // @TODO Extension is loaded, what next? - debug_report_bug(__FUNCTION__, __LINE__, 'LOADED:' . $ext_name); + reportBug(__FUNCTION__, __LINE__, 'LOADED:' . $ext_name); } elseif (($ext_name == 'cache') || (!isExtensionInstalled('cache'))) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DB! ext_name=' . $ext_name); // Load from database @@ -599,11 +615,12 @@ function getExtensionVersion ($ext_name, $force = false) { // Empty extension name should be fixed! if (empty($ext_name)) { // Please report this bug! - debug_report_bug(__FUNCTION__, __LINE__, 'ext_name is empty which is not allowed here.'); + reportBug(__FUNCTION__, __LINE__, 'ext_name is empty which is not allowed here.'); } // END - if // Extensions are all inactive during installation if (isInstallationPhase()) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',force=' . intval($force) . ' - Installation phase detected, returning empty version.'); return ''; } // END - if @@ -641,7 +658,7 @@ function getExtensionVersion ($ext_name, $force = false) { // Extension version should not be invalid if (($data['ext_version'] == 'false') && ($force === false)) { // Please report this trouble - debug_report_bug(__FUNCTION__, __LINE__, sprintf("Extension %s has empty version!", $ext_name)); + reportBug(__FUNCTION__, __LINE__, sprintf("Extension %s has empty version!", $ext_name)); } // END - if // Return result @@ -655,7 +672,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false, $ignoreDependen //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_ver=' . $ext_ver . ',dry_run=' . intval($dry_run) . ',ignoreDependencies=' . intval($ignoreDependencies) . ' - ENTERED!'); if ((!isAdmin()) || (empty($ext_name))) { // Called as non-admin or empty extension - debug_report_bug(__FUNCTION__, __LINE__, 'Called as non-admin (isAdmin()=' . intval(isAdmin()) . '), or empty extension name. ext_name=' . $ext_name); + reportBug(__FUNCTION__, __LINE__, 'Called as non-admin (isAdmin()=' . intval(isAdmin()) . '), or empty extension name. ext_name=' . $ext_name); } // END - if // Set current SQL name @@ -665,7 +682,7 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false, $ignoreDependen if ((isExtensionUpdateRunning($ext_name, $ignoreDependencies)) && ($dry_run === false)) { // This is fine but needs logging ATM //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in update phase, all fine.'); - ///* BUG: */ debug_report_bug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in update phase, please investigate!'); + //* BUG: */ reportBug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in update phase, please investigate!'); return true; } // END - if @@ -766,7 +783,7 @@ function addExtensionVerboseSqlTable ($title = '{--ADMIN_SQLS_EXECUTED_ON_REMOVA // Empty title? if (empty($title)) { // Then abort here - debug_report_bug(__FUNCTION__, __LINE__, 'title is empty.'); + reportBug(__FUNCTION__, __LINE__, 'title is empty.'); } // END - if // Init variables @@ -790,7 +807,7 @@ function addExtensionVerboseSqlTable ($title = '{--ADMIN_SQLS_EXECUTED_ON_REMOVA // Prepare output for template $content = array( 'i' => ($idx + 1), - 'sql' => str_replace('{', '{', str_replace('}', '}', encodeEntities($sql))) + 'sql' => str_replace(array('{', '}'), array('{', '}'), encodeEntities($sql)) ); // Load row template @@ -812,7 +829,7 @@ function addExtensionVerboseSqlTable ($title = '{--ADMIN_SQLS_EXECUTED_ON_REMOVA $OUT = loadTemplate('admin_extension_sql_table', true, $content); } else { // No addional SQL commands to run - $OUT = displayMessage('{--ADMIN_NO_ADDITIONAL_SQLS--}', true); + $OUT = displayMessage('{--ADMIN_EXTENSION_VERBOSE_SQLS_404--}', true); } } // END - if @@ -850,7 +867,7 @@ function getExtensionName ($ext_id) { // Did we find some extension? if (empty($data['ext_name'])) { // We should fix these all! - debug_report_bug(__FUNCTION__, __LINE__, 'ext_name is empty. ext_id=' . $ext_id); + reportBug(__FUNCTION__, __LINE__, 'ext_name is empty. ext_id=' . $ext_id); } // END - if // Return the extension name @@ -891,7 +908,7 @@ function getExtensionId ($ext_name) { return $data['ext_id']; } -// Determines wether the given extension name is valid +// Determines whether the given extension name is valid function isExtensionNameValid ($ext_name) { // Do we have cache? if (!isset($GLOBALS['ext_name_valid'][$ext_name])) { @@ -906,7 +923,7 @@ function isExtensionNameValid ($ext_name) { return $GLOBALS['ext_name_valid'][$ext_name]; } -// Determines wether the given extension id is valid +// Determines whether the given extension id is valid function isExtensionIdValid ($ext_id) { // Default is nothing valid $isValid = false; @@ -932,7 +949,7 @@ function doActivateExtension ($ext_name) { // Is the extension installed? if (!isExtensionInstalled($ext_name)) { // Non-installed extensions cannot be activated - debug_report_bug(__FUNCTION__, __LINE__, 'Tried to activate non-installed extension ' . $ext_name); + reportBug(__FUNCTION__, __LINE__, 'Tried to activate non-installed extension ' . $ext_name); } // END - if // Activate the extension @@ -948,7 +965,7 @@ function doDeactivateExtension ($ext_name) { // Is the extension installed? if (!isExtensionInstalled($ext_name)) { // Non-installed extensions cannot be activated - debug_report_bug(__FUNCTION__, __LINE__, 'Tried to deactivate non-installed extension ' . $ext_name . ',getExtensionMode()=' . getExtensionMode()); + reportBug(__FUNCTION__, __LINE__, 'Tried to deactivate non-installed extension ' . $ext_name . ',getExtensionMode()=' . getExtensionMode()); } // END - if // Activate the extension @@ -972,7 +989,7 @@ function doDeactivateExtension ($ext_name) { ); } -// Checks wether the extension is older than given +// Checks whether the extension is older than given function isExtensionOlder ($ext_name, $ext_ver) { // Get current extension version $currVersion = getExtensionVersion($ext_name); @@ -1002,7 +1019,7 @@ function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) { } // END - if } else { // Extension not there! :-( - debug_report_bug(__FUNCTION__, __LINE__, sprintf("Extension %s not found but should be updated?", $ext_name)); + reportBug(__FUNCTION__, __LINE__, sprintf("Extension %s not found but should be updated?", $ext_name)); } // Return task id @@ -1187,7 +1204,7 @@ function addExtensionCssFile ($file) { } // END - if // Add the entry - $GLOBALS['css_files'][] = $file; + array_push($GLOBALS['css_files'], $file); } // Setter for EXT_ALWAYS_ACTIVE flag @@ -1200,7 +1217,7 @@ function getThisExtensionAlwaysActive () { return $GLOBALS['ext_always_active'][getCurrentExtensionName()]; } -// Checks wether the current extension is always active +// Checks whether the current extension is always active function isThisExtensionAlwaysActive () { return (getThisExtensionAlwaysActive() == 'Y'); } @@ -1221,8 +1238,18 @@ function setExtensionDeprecated ($deprecated) { } // Getter for EXT_DEPRECATED flag -function isExtensionDeprecated () { - return ($GLOBALS['ext_deprecated'][getCurrentExtensionName()] == 'Y'); +function isExtensionDeprecated ($ext_name = NULL) { + // Default is from current (NULL) extension + $isDeprecated = ($GLOBALS['ext_deprecated'][getCurrentExtensionName()] == 'Y'); + + // Is ext_name set? + if (!is_null($ext_name)) { + // Then use it instead + $isDeprecated = ((isset($GLOBALS['ext_deprecated'][$ext_name])) && ($GLOBALS['ext_deprecated'][$ext_name] == 'Y')); + } // END - if + + // Return it + return $isDeprecated; } // Setter for EXT_UPDATE_DEPENDS flag @@ -1231,7 +1258,7 @@ function addExtensionDependency ($updateDepends) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . '/' . $updateDepends . ',extensionMode=' . getExtensionMode() . ' - ENTERED!'); if (empty($updateDepends)) { // Please report this bug! - debug_report_bug(__FUNCTION__, __LINE__, 'updateDepends is empty: currentExtension=' . getCurrentExtensionName()); + reportBug(__FUNCTION__, __LINE__, 'updateDepends is empty: currentExtension=' . getCurrentExtensionName()); } // END - if // Is it not yet added? @@ -1245,10 +1272,10 @@ function addExtensionDependency ($updateDepends) { } // END - if // Add it to the list of extension update depencies map - $GLOBALS['ext_update_depends'][getCurrentExtensionName()][] = (string) $updateDepends; + array_push($GLOBALS['ext_update_depends'][getCurrentExtensionName()], $updateDepends); // Remember it in the list of running updates - $GLOBALS['ext_running_updates'][getCurrentExtensionName()][] = $updateDepends; + array_push($GLOBALS['ext_running_updates'][getCurrentExtensionName()], $updateDepends); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . '/' . $updateDepends . ',extensionMode=' . getExtensionMode() . ' - EXIT!'); } @@ -1257,7 +1284,7 @@ function getExtensionUpdatesRunning () { return $GLOBALS['ext_running_updates'][getCurrentExtensionName()]; } -// Checks wether the given extension registration is in progress +// Checks whether the given extension registration is in progress function isExtensionRegistrationRunning ($ext_name) { // Simply check it $isRunning = ((isset($GLOBALS['ext_register_running'])) && (in_array($ext_name, $GLOBALS['ext_register_running']))); @@ -1274,7 +1301,7 @@ function initExtensionUpdateDependencies () { // Init update depency map automatically if not found if (isExtensionUpdateDependenciesInitialized()) { // We need these bug reports as well... - debug_report_bug(__FUNCTION__, __LINE__, '() is called twice: currName=' . getCurrentExtensionName()); + reportBug(__FUNCTION__, __LINE__, '() is called twice: currName=' . getCurrentExtensionName()); } // END - if $GLOBALS['ext_update_depends'][getCurrentExtensionName()] = array(); @@ -1291,21 +1318,21 @@ function addExtensionRunningRegistration ($ext_name) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Registration in progress: ext_name=' . $ext_name . ' - ENTERED!'); if (isExtensionRegistrationRunning($ext_name)) { // This is really bad and should not be quietly ignored - debug_report_bug(__FUNCTION__, __LINE__, '() already called! ext_name=' . $ext_name); + reportBug(__FUNCTION__, __LINE__, '() already called! ext_name=' . $ext_name); } // END - if // Then add it! - $GLOBALS['ext_register_running'][] = $ext_name; + array_push($GLOBALS['ext_register_running'], $ext_name); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Registration in progress: ext_name=' . $ext_name . ' - EXIT!'); } -// Checks wether EXT_UPDATE_DEPENDS is initialized +// Checks whether EXT_UPDATE_DEPENDS is initialized function isExtensionUpdateDependenciesInitialized () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName()); return (isset($GLOBALS['ext_update_depends'][getCurrentExtensionName()])); } -// Checks wether an update is already running for given extension +// Checks whether an update is already running for given extension function isExtensionUpdateRunning ($ext_name, $ignoreDependencies = false) { // Current and given extensions means whole array //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currentExtension=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ',ignoreDependencies=' . intval($ignoreDependencies) . ' - ENTERED!'); @@ -1361,7 +1388,7 @@ function getExtensionUpdateDependenciesIterator () { // Counter for extension update depencies function countExtensionUpdateDependencies () { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . '=' . count($GLOBALS['ext_update_depends'][getCurrentExtensionName()])); return count($GLOBALS['ext_update_depends'][getCurrentExtensionName()]); } @@ -1370,6 +1397,9 @@ function removeExtensionDependency ($ext_name) { // Look it up $key = array_search($ext_name, getExtensionUpdateDependencies()); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',key[' . gettype($key) . ']=' . $key); + // Is it valid? if ($key !== false) { // Then remove it @@ -1389,10 +1419,13 @@ function initExtensionUpdateIterator () { // Getter for depency iterator function getExtensionUpdateIterator () { // Auto-init iterator - if (!isset($GLOBALS['ext_depend_iterator'][getCurrentExtensionName()])) initExtensionUpdateIterator(); + if (!isset($GLOBALS['ext_depend_iterator'][getCurrentExtensionName()])) { + // Initialize update iterator + initExtensionUpdateIterator(); + } // END - if // Return it - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName().'/'.$GLOBALS['ext_depend_iterator'][getCurrentExtensionName()]); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . '=' . $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()]); return $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()]; } @@ -1419,13 +1452,20 @@ function setExtensionVersionHistory ($versionHistory) { // Getter for EXT_VER_HISTORY array function getExtensionVersionHistory () { + // Is it set? + if (!isset($GLOBALS['ext_ver_history'][getCurrentExtensionName()])) { + // Then abort here to a avoid an ugly "Undefined index" error + reportBug(__FUNCTION__, __LINE__, 'Extension ext-' . getCurrentExtensionName() . ' has no history set! Is this extension empty?'); + } // END - if + + // Return the history return $GLOBALS['ext_ver_history'][getCurrentExtensionName()]; } // Setter for EXT_UPDATE_NOTICES function setExtensionUpdateNotes ($updateNotes, $ext_ver = '') { // - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()=' . getCurrentExtensionName() . ',getExtensionMode()=' . getExtensionMode() . ',ext_ver=' . $ext_ver . '/' . getCurrentExtensionVersion() . ',updateNotes()=' . strlen($updateNotes)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()=' . getCurrentExtensionName() . ',getExtensionMode()=' . getExtensionMode() . ',ext_ver=' . $ext_ver . '/' . getCurrentExtensionVersion() . ',updateNotes(length)=' . strlen($updateNotes)); if (empty($ext_ver)) { $GLOBALS['ext_update_notes'][getCurrentExtensionName()][getCurrentExtensionVersion()] = (string) $updateNotes; } else { @@ -1448,7 +1488,7 @@ function initExtensionNotes ($force = false) { // Is it already initialized? if (($force === false) && (isset($GLOBALS['ext_notes'][getCurrentExtensionName()]))) { // This is mostly not wanted, so please report it - debug_report_bug(__FUNCTION__, __LINE__, 'ext_notes already set for extension ' . getCurrentExtensionName()); + reportBug(__FUNCTION__, __LINE__, 'ext_notes already set for extension ' . getCurrentExtensionName()); } // END - if //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()=' . getCurrentExtensionName()); @@ -1457,7 +1497,7 @@ function initExtensionNotes ($force = false) { // Append extension notice function appendExtensionNotes ($notes) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()=' . getCurrentExtensionName() . ', notes()=' . strlen($notes)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()=' . getCurrentExtensionName() . ', notes(length)=' . strlen($notes)); $GLOBALS['ext_notes'][getCurrentExtensionName()] .= (string) trim($notes); } @@ -1475,7 +1515,7 @@ function setCurrentExtensionName ($ext_name) { function getCurrentExtensionName () { if (!isset($GLOBALS['curr_extension_name'])) { // Not set! - debug_report_bug(__FUNCTION__, __LINE__, 'curr_extension_name not initialized. Please execute initExtensionSqls() before calling this function.'); + reportBug(__FUNCTION__, __LINE__, 'curr_extension_name not initialized. Please execute initExtensionSqls() before calling this function.'); } // END - if // Return it @@ -1498,7 +1538,7 @@ function initExtensionSqls ($force = false) { function addExtensionSql ($sql) { // Add it //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . getCurrentExtensionName() . ',ext_version=' . getCurrentExtensionVersion() . ',sql=' . $sql); - $GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()][] = $sql; + array_push($GLOBALS['ext_sqls'][getCurrentExtensionName()][getCurrentExtensionVersion()], $sql); } // Getter for SQLs array for current extension @@ -1506,7 +1546,7 @@ function getExtensionSqls () { // Output debug backtrace if not found (SHOULD NOT HAPPEN!) if (!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()])) { // Not found, should not happen - debug_report_bug(__FUNCTION__, __LINE__, sprintf("ext_sqls is empty, current extension: %s", + reportBug(__FUNCTION__, __LINE__, sprintf("ext_sqls is empty, current extension: %s", getCurrentExtensionName() )); } // END - if @@ -1520,7 +1560,7 @@ function countExtensionSqls () { // Output debug backtrace if not found (SHOULD NOT HAPPEN!) if (!isset($GLOBALS['ext_sqls'][getCurrentExtensionName()])) { // Not found, should not happen - debug_report_bug(__FUNCTION__, __LINE__, sprintf("ext_sqls is empty, current extension: %s", + reportBug(__FUNCTION__, __LINE__, sprintf("ext_sqls is empty, current extension: %s", getCurrentExtensionName() )); } // END - if @@ -1543,7 +1583,7 @@ function initExtensionRemovalList () { } // END - if } -// Checks wether the current extension is on the removal list +// Checks whether the current extension is on the removal list function isExtensionOnRemovalList () { // Init removal list initExtensionRemovalList(); @@ -1555,7 +1595,7 @@ function isExtensionOnRemovalList () { // Adds the current extension to the removal list function addCurrentExtensionToRemovalList () { // Simply add it - $GLOBALS['ext_update_remove'][] = getCurrentExtensionName(); + array_push($GLOBALS['ext_update_remove'], getCurrentExtensionName()); } // Getter for removal list @@ -1575,8 +1615,11 @@ function redirectOnUninstalledExtension ($ext_name) { // Filter for initialization of all extensions by loading them in 'init' mode function FILTER_INIT_EXTENSIONS () { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTERED!'); + // Init notification pool + initIncludePool('notify'); + // Do we have some entries? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY!'); if (isset($GLOBALS['cache_array']['extension']['ext_name'])) { // Load all found extensions if found //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHE - START!'); @@ -1588,6 +1631,10 @@ function FILTER_INIT_EXTENSIONS () { } // END - foreach //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHE - END!'); } // END - if + + // Run any notifications + runFilterChain('load_includes', 'notify'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'EXIT!'); } @@ -1617,7 +1664,7 @@ function setCurrentExtensionVersion ($ext_ver) { // ext_ver should never be empty in other modes than 'test' if ((empty($ext_ver)) && (getExtensionMode() != 'test')) { // Please report all these messages - debug_report_bug(__FUNCTION__, __LINE__, 'ext_ver is empty. Current extension name: ' . getCurrentExtensionName() . ', mode=' . getExtensionMode()); + reportBug(__FUNCTION__, __LINE__, 'ext_ver is empty. Current extension name: ' . getCurrentExtensionName() . ', mode=' . getExtensionMode()); } // END - if // Add version @@ -1680,7 +1727,7 @@ function getExtensionHasCss () { return $GLOBALS[__FUNCTION__][getCurrentExtensionName()][getCurrentTheme()]; } -// Checks wether the given extension has a language file +// Checks whether the given extension has a language file function ifExtensionHasLanguageFile ($ext_name) { // Do we have cache? if (isset($GLOBALS['cache_array']['extension']['ext_lang'][$ext_name])) { @@ -1700,7 +1747,7 @@ function loadCurrentExtensionInclude () { // Is it readable? if (!isExtensionIncludeReadable()) { // Not readable - debug_report_bug(__FUNCTION__, __LINE__, 'Extension ' . getCurrentExtensionName() . ' should be loaded, but is not readable.'); + reportBug(__FUNCTION__, __LINE__, 'Extension ' . getCurrentExtensionName() . ' should be loaded, but is not readable.'); } // END - if // Generate INC name @@ -1710,7 +1757,7 @@ function loadCurrentExtensionInclude () { loadInclude($INC); } -// Checks wether an extension is readable +// Checks whether an extension is readable function isExtensionIncludeReadable ($ext_name = '') { // If empty, use current if (empty($ext_name)) { @@ -1765,10 +1812,10 @@ function addCreateTableSql ($tableName, $sql, $comment) { ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci -COMMENT ' . "'" . $comment . "'"); +COMMENT ' . chr(39) . $comment . chr(39)); } else { // Is already there, which should not happen - debug_report_bug(__FUNCTION__, __LINE__, 'The table ' . $tableName . ' is already created which should not happen.'); + reportBug(__FUNCTION__, __LINE__, 'The table ' . $tableName . ' is already created which should not happen.'); } } @@ -1928,7 +1975,7 @@ function addConfigDropSql ($columnName) { // Found, so add it addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `' . $columnName . '`'); } elseif (isDebugModeEnabled()) { - // Add debug line, debug_report_bug() would cause some extenion updates fail + // Add debug line, reportBug() would cause some extenion updates fail logDebugMessage(__FUNCTION__, __LINE__, 'Configuration entry ' . $columnName . ' not found.'); } } @@ -1950,7 +1997,7 @@ function enableExtensionProductive ($isProductive = true) { $GLOBALS['ext_productive'][getCurrentExtensionName()] = (bool) $isProductive; } -// Checks wether the extension is in productive phase. If not set, development +// Checks whether the extension is in productive phase. If not set, development // phase (=false) is assumed. function isExtensionProductive ($ext_name = '') { // Is the extension name empty? Then use current @@ -1982,7 +2029,7 @@ function markExtensionAsLoaded ($ext_name) { // Is it already loaded? if (isExtensionLoaded($ext_name)) { // Then abort here - debug_report_bug(__FUNCTION__, __LINE__, 'Extension ' . $ext_name . ' is already marked as loaded!'); + reportBug(__FUNCTION__, __LINE__, 'Extension ' . $ext_name . ' is already marked as loaded!'); } // END - if // Mark it @@ -1990,7 +2037,7 @@ function markExtensionAsLoaded ($ext_name) { $GLOBALS['ext_loaded']['ext_name'][$ext_name] = true; } -// Determine wether the given extension is already loaded +// Determine whether the given extension is already loaded function isExtensionLoaded ($ext_name) { // Is it there? return ((isset($GLOBALS['ext_loaded']['ext_name'][$ext_name])) && ($GLOBALS['ext_loaded']['ext_name'][$ext_name] === true)); @@ -2001,14 +2048,14 @@ function markExtensionLibraryAsLoaded ($ext_name) { // Is it already loaded? if (isExtensionLibraryLoaded($ext_name)) { // Then abort here - debug_report_bug(__FUNCTION__, __LINE__, 'Extension library ' . $ext_name . ' is already marked as loaded!'); + reportBug(__FUNCTION__, __LINE__, 'Extension library ' . $ext_name . ' is already marked as loaded!'); } // END - if // Mark it $GLOBALS['ext_loaded']['library'][$ext_name] = true; } -// Determine wether the given extension's library is already loaded +// Determine whether the given extension's library is already loaded function isExtensionLibraryLoaded ($ext_name) { // Is it there? return ((isset($GLOBALS['ext_loaded']['library'][$ext_name])) && ($GLOBALS['ext_loaded']['library'][$ext_name] === true));