} elseif (($ext_name == 'cache') || (GET_EXT_VERSION('cache') == '')) {
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "DB! ext_name={$ext_name}");
// Load from database
- $result = SQL_QUERY_ESC("SELECT ext_active FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `ext_active` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
// Entry found?
}
// Debug message
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " ext_name={$ext_name},active={$active}");
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "ext_name={$ext_name},active={$active}");
// Is this extension activated? (For admins we always have active extensions...)
return ($active == 'Y');
incrementConfigEntry('cache_hits');
} elseif (!isCacheInstanceValid()) {
// Load from database
- $result = SQL_QUERY_ESC("SELECT ext_version FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `ext_version` FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": DB - ".SQL_NUMROWS($result)."");
// Version history array (add more with , '0.1.0' and so on)
EXT_SET_VER_HISTORY(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2'));
-switch ($EXT_LOAD_MODE)
-{
+// Which load mode?
+switch ($EXT_LOAD_MODE) {
case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
// SQL commands to run
ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD cache_update BIGINT(20) UNSIGNED NOT NULL DEFAULT 3600");
break;
case 'update': // Update an extension
- switch ($EXT_VER)
- {
+ // Which version?
+ switch ($EXT_VER) {
case '0.0.1': // SQL queries for v0.0.1
// Update notes (these will be set as task text!)
EXT_SET_UPDATE_NOTES("Es wurde die Zeitmarke der Cache-Datei extensions.cache mit berücksichtigt. Dies hatte die Folge, dass wenn bei einem Gast die Datei aktualisiert wurde, nur aktivierte und nicht die deaktivierten mit geladen wurden. Folglich fiehlen einfach ein paar Erweiterungen aus.");
}
break;
- case 'modify': // When the extension got modified
- break;
+ case 'modify': // When the extension got modified
+ break;
- case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
- break;
+ case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
+ break;
- default: // Do stuff when extension is loaded
- // Create instance on class
- if ($GLOBALS['cache_mode'] != 'init') {
- // Initialize cache system only when it's needed
- $GLOBALS['cache_instance'] = new CacheSystem(getConfig('cache_update'), "inc/".getConfig('cache_path'), getConfig('cache_tested'));
- if ($GLOBALS['cache_instance']->getStatus() != 'done') {
- // Failed to initialize cache sustem
- addFatalMessage(__FILE__, __LINE__, "(<font color=\"#0000aa\">".__LINE__."</font>): ".getMessage('CACHE_CANNOT_INITIALIZE'));
- } // END - if
- } // END - if
- break;
+ default: // Do stuff when extension is loaded
+ // Create instance on class
+ if ($GLOBALS['cache_mode'] != 'init') {
+ // Initialize cache system only when it's needed
+ $GLOBALS['cache_instance'] = new CacheSystem(getConfig('cache_update'), 'inc/' . getConfig('cache_path'), getConfig('cache_tested'));
+ if ($GLOBALS['cache_instance']->getStatus() != 'done') {
+ // Failed to initialize cache sustem
+ addFatalMessage(__FILE__, __LINE__, "(<font color=\"#0000aa\">".__LINE__."</font>): ".getMessage('CACHE_CANNOT_INITIALIZE'));
+ } // END - if
+ } // END - if
+ break;
}
// Keep this extension always active!
// Filters for post-extension-registration
registerFilter('post_extension_installed', 'AUTO_ACTIVATE_EXTENSION');
registerFilter('post_extension_installed', 'SOLVE_TASK');
- registerFilter('post_extension_installed', 'loadIncludeLUDES');
+ registerFilter('post_extension_installed', 'LOAD_INCLUDES');
registerFilter('post_extension_installed', 'REMOVE_UPDATES');
// Solving tasks
registerFilter('solve_task', 'SOLVE_TASK');
// Loading includes in general
- registerFilter('load_includes', 'loadIncludeLUDES');
+ registerFilter('load_includes', 'LOAD_INCLUDES');
// Run SQLs
registerFilter('run_sqls', 'RUN_SQLS');
function runFilterChain ($filterName, $data = null, $silentAbort = true) {
// Is that filter chain there?
if (!isset($GLOBALS['filters']['chains'][$filterName])) {
- // Then abort here (quick'N'dirty hack)
- if (($silentAbort === false) && (defined('FILTER_FAILED_NO_FILTER_FOUND'))) {
- // Add fatal message
- addFatalMessage(__FUNCTION__, __LINE__, getMessage('FILTER_FAILED_NO_FILTER_FOUND'), $filterName);
- } // END - if
-
- // Abort here
- return false;
+ // We should find all these non-existing filter chains
+ debug_report_bug('Filter chain '.$filterName.' not found!');
} // END - if
// Default return value
$returnValue = $data;
// Then run all filters
- foreach ($GLOBALS['filters']['chains'][$filterName] as $filterFunction=>$active) {
+ foreach ($GLOBALS['filters']['chains'][$filterName] as $filterFunction => $active) {
// Debug message
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Running: name={$filterName},func={$filterFunction},active={$active}");
}
// Filter to load include files
-function FILTER_loadIncludeLUDES () {
+function FILTER_LOAD_INCLUDES () {
// Default is $data as inclusion list
$data = GET_INC_POOL();
$ret = $tmpl_file;
}
- // Add surrounding HTML comments to help finding bugs faster
- $ret = "<!-- Template " . $template . " - Start -->\n" . $ret . "<!-- Template " . $template . " - End -->\n";
+ // Normal HTML output?
+ if ($GLOBALS['output_mode'] == 0) {
+ // Add surrounding HTML comments to help finding bugs faster
+ $ret = "<!-- Template " . $template . " - Start -->\n" . $ret . "<!-- Template " . $template . " - End -->\n";
+ } // END - if
} elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
$ret = "<br /><span class=\"guest_failed\">{--TEMPLATE_404--}</span><br />
} // END - if
// Is the cache file outdated/invalid?
- if ($new === true){
+ if ($new === true) {
+ // Reload the cache file
+ $GLOBALS['cache_instance']->loadCacheFile('revision');
+
// Destroy cache file
- $GLOBALS['cache_instance']->destroyCacheFile();
+ $GLOBALS['cache_instance']->destroyCacheFile(false, true);
// @TODO shouldn't do the unset and the reloading $GLOBALS['cache_instance']->destroyCacheFile() Or a new methode like forceCacheReload('revision')?
unset($GLOBALS['cache_array']['revision']);
}
// Destroy an existing cache file
- function destroyCacheFile ($removeArray = false) {
+ function destroyCacheFile ($removeArray = false, $force = false) {
// Only run in regular output mode
- if (getOutputMode() != 0) {
+ if ((getOutputMode() != 0) && ($force === false)) {
// Debug message if allowed
if (isDebugModeEnabled()) {
// Debug message
- DEBUG_LOG(__METHOD__, __LINE__, 'Not removing cache ' . $this->name . ' in output_mode=' . getOutputMode());
+ debug_report_bug('Not removing cache ' . $this->name . ' in output_mode=' . getOutputMode());
} // END - if
// Abort here
// Free memory
SQL_FREERESULT($res_ext_crt);
-} elseif (!EXT_IS_ACTIVE('cache')) {
+} elseif ((!EXT_IS_ACTIVE('cache')) || (($GLOBALS['cache_mode'] == 'init') && (getOutputMode() != 0))) {
// Init filter system even when there are no extensions installed. #16
initFilterSystem();
+} elseif ($GLOBALS['cache_mode'] != 'load') {
+ // Something unexpected!
+ debug_report_bug('Unexpected state in '.basename(__FILE__).': cache_mode='.$GLOBALS['cache_mode'].', numRows='.SQL_NUMROWS($res_ext_crt));
}
// Run the filter
foreach ($DEL as $del_ext) {
// First remove entry from extensions table
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_extensions` WHERE `ext_name`='%s' LIMIT 1",
- array($del_ext), __FILE__, __LINE__);
+ array($del_ext), __FILE__, __LINE__);
// Remove (maybe?) found tasks (main task and possible updates
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE subject='[%s:]' AND (task_type='EXTENSION' OR task_type='EXTENSION_UPDATE')",
- array($del_ext), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `subject`='[%s:]' AND (`task_type`='EXTENSION' OR `task_type`='EXTENSION_UPDATE')",
+ array($del_ext), __FILE__, __LINE__);
} // END - foreach
// I think it's not neccessary to run the optimization function here
} else {
// @TODO Nothing helped???
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("ret=%s,locked=%s,admin=%s,mem=%s",
- $ret,
- $locked,
- $admin,
- $mem
+ $ret,
+ $locked,
+ $admin,
+ $mem
));
}
} // END - if
// Still no luck or not found?
- if (($ret == 'cache_miss') || ($found === false)) {
+ if (($found === false) && (!EXT_IS_ACTIVE('cache')) && ($ret != 'done')) {
// ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name ---
if ((isFileReadable(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) {
// Data is missing so we add it
// Module not found we don't add it to the database
$ret = '404';
}
- } elseif (!$found) {
+ } elseif ($ret == 'cache_miss') {
+ // Rebuild the cache files
+ rebuildCacheFiles('modreg', 'modreg');
+ } elseif ($found === false) {
// Problem with module detected
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Problem in module %s detected. ret=%s, locked=%s, hidden=%s, mem=%s, admin=%s",
$mod,