} // END - if
// 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) . ' - ENTERED!');
+function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $isDryRun = false) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_mode=' . $ext_mode . ',ext_ver=' . $ext_ver . ',isDryRun=' . intval($isDryRun) . ' - 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')))) {
// 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!
- reportBug(__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.0 ext_name=' . $ext_name . ', ext_mode=' . $ext_mode . ', isDryRun=' . intval($isDryRun));
} // END - if
}
// Set dry-run
- enableExtensionDryRun($dry_run);
+ enableExtensionDryRun($isDryRun);
// Init array
initIncludePool('extension');
}
// Registers an extension and possible update dependencies
-function registerExtension ($ext_name, $taskId, $dry_run = false, $ignoreUpdates = false) {
+function registerExtension ($ext_name, $taskId, $isDryRun = false, $ignoreUpdates = false) {
// Set current extension name
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',task_id=' . intval($taskId) . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - ENTERED!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId=' . intval($taskId) . ',isDryRun=' . intval($isDryRun) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - ENTERED!');
setCurrentExtensionName($ext_name);
// Enable dry-run
- enableExtensionDryRun($dry_run);
+ enableExtensionDryRun($isDryRun);
// By default all extensions are in productive phase
enableExtensionProductive();
// When this extension is already in registration/update phase, all is fine
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: */ reportBug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId=' . $taskId . ',dry_run=' . intval($dry_run) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - Please investigate!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in registration/update phase, all fine,taskId=' . $taskId . ',isDryRun=' . intval($isDryRun) . ',ignoreUpdates=' . intval($ignoreUpdates));
+ //* BUG: */ reportBug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',taskId=' . $taskId . ',isDryRun=' . intval($isDryRun) . ',ignoreUpdates=' . intval($ignoreUpdates) . ' - Please investigate!');
return true;
} // END - if
} // END - if
// Is the task id zero? Then we need to auto-fix it here
- if (($taskId == '0') && (!isInstallationPhase())) {
+ if (((is_null($taskId)) || ($taskId == '0')) && (!isInstallationPhase())) {
// Try to find the task
$taskId = determineExtensionTaskId(getCurrentExtensionName());
// Still zero and not in dry-run?
- if (($taskId == '0') && (!isExtensionDryRun())) {
+ if (((is_null($taskId)) || ($taskId == '0')) && (!isExtensionDryRun())) {
// Now try to create a new task
$taskId = createNewExtensionTask(getCurrentExtensionName());
// Is it still zero?
- if ($taskId == '0') {
+ if ((is_null($taskId)) || ($taskId == '0')) {
// Then request a bug report
reportBug(__FUNCTION__, __LINE__, sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)",
__FUNCTION__,
//* 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);
+ $updateTaskId = determineExtensionTaskId($ext_update);
// Entry found?
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'taskId=' . $taskId . ',isInstallationPhase()=' . intval(isInstallationPhase()) . ',currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ' - CHECKING!');
- if (($taskId > 0) || (isInstallationPhase())) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'updateTaskId=' . $updateTaskId . ',isInstallationPhase()=' . intval(isInstallationPhase()) . ',currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ' - CHECKING!');
+ if (($updateTaskId > 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);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',ext_update=' . $ext_update . ',updateTaskId=' . $updateTaskId . ',isExtensionDryRun()=' . intval(isExtensionDryRun()));
+ $processResult = registerExtension($ext_update, $updateTaskId, isExtensionDryRun(), true);
// Reset extension name
setCurrentExtensionName($ext_name);
// Is there no update?
if (countExtensionUpdateDependencies(getCurrentExtensionName()) == 0) {
// Then test is passed!
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName() . ',processResult=true,countExtensionUpdateDependencies()=0 - Test passed!');
$processResult = true;
} // END - if
}
// @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())) {
+ if (($ret === true) && ($isDryRun === 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
} // END - if
// Return status code
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',currName=' . getCurrentExtensionName() . ',ext_name=' . $ext_name . ',processResult=' . intval($processResult) . ',ret=' . intval($ret) . ' - EXIT!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',currName=' . getCurrentExtensionName() . ',processResult=' . intval($processResult) . ',ret=' . intval($ret) . ' - EXIT!');
return $ret;
}
}
// Updates a given extension with current extension version to latest version
-function updateExtension ($ext_name, $ext_ver, $dry_run = false, $ignoreDependencies = false) {
+function updateExtension ($ext_name, $ext_ver, $isDryRun = false, $ignoreDependencies = false) {
// Only admins are allowed to update extensions
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_ver=' . $ext_ver . ',dry_run=' . intval($dry_run) . ',ignoreDependencies=' . intval($ignoreDependencies) . ' - ENTERED!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_ver=' . $ext_ver . ',isDryRun=' . intval($isDryRun) . ',ignoreDependencies=' . intval($ignoreDependencies) . ' - ENTERED!');
if ((!isAdmin()) || (empty($ext_name))) {
// Called as non-admin or empty extension
reportBug(__FUNCTION__, __LINE__, 'Called as non-admin (isAdmin()=' . intval(isAdmin()) . '), or empty extension name. ext_name=' . $ext_name);
setCurrentExtensionName($ext_name);
// Is this extension update already running?
- if ((isExtensionUpdateRunning($ext_name, $ignoreDependencies)) && ($dry_run === false)) {
+ if ((isExtensionUpdateRunning($ext_name, $ignoreDependencies)) && ($isDryRun === false)) {
// This is fine but needs logging ATM
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in update phase, all fine.');
//* BUG: */ reportBug(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - already in update phase, please investigate!');
$processResult = updateExtension($ext_depend, getExtensionVersion($ext_depend), isExtensionDryRun(), true);
} else {
// Register new extension
- $processResult = registerExtension($ext_depend, 0, isExtensionDryRun());
+ $processResult = registerExtension($ext_depend, NULL, isExtensionDryRun());
}
} // END - if
} // END - foreach
} // END - if
} // END - if
- //* DEBUG: */logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_ver=' . $ext_ver . ',dry_run=' . intval($dry_run) . ',ignoreDependencies=' . intval($ignoreDependencies) . ' - EXIT!');
+ //* DEBUG: */logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',ext_ver=' . $ext_ver . ',isDryRun=' . intval($isDryRun) . ',ignoreDependencies=' . intval($ignoreDependencies) . ' - EXIT!');
}
// Output verbose SQL table for extension
}
// Deactivate given extension
-function doDeactivateExtension ($ext_name) {
+function doDeactivateExtension ($ext_name, $inRebuild = false) {
// Is the extension installed?
if (!isExtensionInstalled($ext_name)) {
// Non-installed extensions cannot be activated
// Create new task (we ignore the task id here)
createExtensionDeactivationTask($ext_name);
- // Rebuild cache
- rebuildCache('extension', 'extension');
+ // Do not rebuild cache if it is already been rebuild
+ if ($inRebuild === false) {
+ // Rebuild cache
+ rebuildCache('extension', 'extension');
+ } // END - if
// Notify the admin
sendAdminNotification(
// Determines the task id for given extension
function determineExtensionTaskId ($ext_name) {
+ // Is it installation phase and table task_system is not found?
+ if ((isInstallationPhase()) && (!ifSqlTableExists('task_system'))) {
+ // Then return NULL (not found)
+ return NULL;
+ } // END - if
+
// Default is not found
- $data['task_id'] = '0';
+ $data['task_id'] = NULL;
// Search for extension task's id
$result = SQL_QUERY_ESC("SELECT `id` AS task_id FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1",
* Double-adding happens when the extension and an update of the same
* extension requires the same other extension again.
*/
- logDebugMessage(__FUNCTION__, __LINE__, 'updateDepends=' . $updateDepends . ',extensionMode=' . getExtensionMode() . ',currentExtension=' . getCurrentExtensionName() . ' - called twice.');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'updateDepends=' . $updateDepends . ',extensionMode=' . getExtensionMode() . ',currentExtension=' . getCurrentExtensionName() . ' - called twice.');
return;
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHE - START!');
foreach ($GLOBALS['cache_array']['extension']['ext_name'] as $key => $ext_name) {
// Load it
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name='.$ext_name.' - START');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - START');
loadExtension($ext_name, 'init', getExtensionVersion($ext_name));
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name='.$ext_name.' - END');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - END');
} // END - foreach
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHE - END!');
} // END - if
}
// Setter for dry-run
-function enableExtensionDryRun ($dry_run = true) {
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()='.getCurrentExtensionName().',dry_run='.intval($dry_run));
- $GLOBALS['ext_dry_run'] = (bool) $dry_run;
+function enableExtensionDryRun ($isDryRun = true) {
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getCurrentExtensionName()='.getCurrentExtensionName().',isDryRun='.intval($isDryRun));
+ $GLOBALS['ext_isDryRun'] = (bool) $isDryRun;
}
// Getter for dry-run
function isExtensionDryRun () {
- return $GLOBALS['ext_dry_run'];
+ return $GLOBALS['ext_isDryRun'];
}
// Setter for current extension version
// Adds a CREATE TABLE statement if the requested table is not there
function addCreateTableSql ($tableName, $sql, $comment) {
// Is the table not there?
- if (!isSqlTableCreated($tableName)) {
+ if (!ifSqlTableExists($tableName)) {
// Is not found, so add it
addExtensionSql('CREATE TABLE
`{?_MYSQL_PREFIX?}_' . $tableName . '` (' . $sql . ')
// Adds a DROP TABLE statement if the requested tabled is there
function addDropTableSql ($tableName) {
// Is the table there?
- if (isSqlTableCreated($tableName)) {
+ if (ifSqlTableExists($tableName)) {
// Then add it, non-existing tables can be ignored because it will
// happen with every newly installed extension.
addExtensionSql('DROP TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '`');
// Mark it as gone
- $GLOBALS['isSqlTableCreated'][$tableName] = false;
+ $GLOBALS['ifSqlTableExists'][$tableName] = false;
} // END - if
}
// Add configuration entry if not found for actual extension
function addConfigAddSql ($columnName, $columnSql) {
// Is the column there?
- if (!isSqlTableColumnFound('{?_MYSQL_PREFIX?}_config', $columnName)) {
+ if (!ifSqlColumnExists('{?_MYSQL_PREFIX?}_config', $columnName)) {
// Not found, so add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `' . $columnName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
// Drop configuration entry if found for actual extension
function addConfigDropSql ($columnName) {
// Is the column there?
- if (isSqlTableColumnFound('{?_MYSQL_PREFIX?}_config', $columnName)) {
+ if (ifSqlColumnExists('{?_MYSQL_PREFIX?}_config', $columnName)) {
// Found, so add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `' . $columnName . '`');
} elseif (isDebugModeEnabled()) {