X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fextensions-functions.php;h=3ea8b87b0b143634d8fc1703c6ce4e8fc7a8e04a;hb=8def2eea23fae29ba4d86b4bf7df9307e62f61b7;hp=f89233a146abd1604cbb8917b369c0b84e87bb73;hpb=d3c4fdd9bfab35389e1a5ff48f3952d527c7b4bb;p=mailer.git diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index f89233a146..3ea8b87b0b 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -102,7 +102,7 @@ function loadExtension ($ext_name, $ext_mode = 'init', $ext_ver = '', $dry_run = // Download functions file loadIncludeOnce($funcsInclude); } // END - if - } elseif ((!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name])) && (isDebugModeEnabled()) && (getOutputMode() == 0) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme') && (getExtensionMode() == 'test')) { + } elseif ((!isset($GLOBALS['cache_array']['extension']['ext_func'][$ext_name])) && (isDebugModeEnabled()) && (getOutputMode() == '0') && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme') && (getExtensionMode() == 'test')) { // No functions file is not so good... logDebugMessage(__FUNCTION__, __LINE__, sprintf("NOTICE: Extension %s has no own functions file or we cannot read from it. mode=%s", $ext_name, @@ -173,12 +173,12 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru initExtensionUpdateDependencies(); // Is the task id zero? Then we need to auto-fix it here - if ($task_id == 0) { + if ($task_id == '0') { // Try to find the task $task_id = determineExtensionTaskId(getCurrentExtensionName()); // Still zero and not in dry-run? - if (($task_id == 0) && (!getExtensionDryRun())) { + if (($task_id == '0') && (!getExtensionDryRun())) { // Then request a bug report debug_report_bug(sprintf("%s: task_id is still zero after determineExtensionTaskId(%s)", __FUNCTION__, @@ -278,7 +278,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru } // END - for // Is there no update? - if (countExtensionUpdateDependencies(getCurrentExtensionName()) == 0) { + if (countExtensionUpdateDependencies(getCurrentExtensionName()) == '0') { // Then test is passed! $test = true; } // END - if @@ -450,11 +450,10 @@ function isExtensionInstalled ($ext_name) { // Extensions are all inactive/not installed during installation } else { // Look in database - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", - array($ext_name), __FILE__, __LINE__); + $ext_id = getExtensionId($ext_name); // Do we have a record? - $isInstalled = (SQL_NUMROWS($result) == 1); + $isInstalled = ($ext_id > 0); // Is it installed, then cache the entry if ($isInstalled === true) { @@ -462,9 +461,6 @@ function isExtensionInstalled ($ext_name) { getExtensionId($ext_name, true); } // END - if - // Free result - SQL_FREERESULT($result); - // Remember the status $GLOBALS['ext_is_installed'][$ext_name] = $isInstalled; } @@ -524,9 +520,9 @@ function isExtensionActive ($ext_name) { } // Get version from extensions -function getExtensionVersion ($ext_name) { +function getExtensionVersion ($ext_name, $force = false) { // By default no extension is found - $ext_ver = 'invalid'; + $ext_ver = 'false'; // Empty extension name should be fixed! if (empty($ext_name)) { @@ -569,7 +565,7 @@ function getExtensionVersion ($ext_name) { } // Extension version should not be invalid - if ($ext_ver == 'invalid') { + if (($ext_ver == 'false') && ($force === false)) { // Please report this trouble debug_report_bug(sprintf("Extension %s has empty version!", $ext_name)); } // END - if @@ -769,17 +765,18 @@ function getExtensionName ($ext_id) { } // Get extension id from name -function getExtensionId ($ext_name, $forceDb = false) { +function getExtensionId ($ext_name) { // Init id number - $ret = 0; + $ret = '0'; + // Do we have cache? if (isset($GLOBALS['cache_array']['extension']['ext_id'][$ext_name])) { // Load from cache $ret = $GLOBALS['cache_array']['extension']['ext_id'][$ext_name]; // Count cache hits incrementStatsEntry('cache_hits'); - } elseif (($forceDb === true) || (!isExtensionActive('cache'))) { + } else { // Load from database $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", array($ext_name), __FUNCTION__, __LINE__); @@ -797,11 +794,6 @@ function getExtensionId ($ext_name, $forceDb = false) { $GLOBALS['cache_array']['extension']['ext_id'][$ext_name] = $ret; } - if ($ret == 0) { - // We should fix these all! - debug_report_bug(__FUNCTION__ . ': Invalid extension name found. ext_name=' . $ext_name); - } // END - if - // Return value return $ret; } @@ -899,7 +891,7 @@ function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) { // Is the extension there? if (isExtensionInstalled($ext_name)) { // Check if task is not there - if (determineTaskIdBySubject($subject) == 0) { + if (determineTaskIdBySubject($subject) == '0') { // Create extension update-task createNewTask($subject, $notes, 'EXTENSION_UPDATE', 0, $adminId); } // END - if @@ -912,7 +904,7 @@ function createExtensionUpdateTask ($adminId, $ext_name, $ext_ver, $notes) { // Creates a new task for newly installed extension function createNewExtensionTask ($adminId, $subject, $ext) { // Not installed and do we have created a task for the admin? - if ((determineTaskIdBySubject($subject) == 0) && (!isExtensionInstalled($ext))) { + if ((determineTaskIdBySubject($subject) == '0') && (!isExtensionInstalled($ext))) { // Set default message if ext-foo is missing $message = sprintf(getMessage('ADMIN_EXT_TEXT_FILE_MISSING'), $ext); @@ -943,7 +935,7 @@ function createExtensionDeactivationTask ($ext) { $subject = sprintf("[%s:] %s", $ext, getMessage('TASK_SUBJ_EXTENSION_DEACTIVATED')); // Not installed and do we have created a task for the admin? - if ((determineTaskIdBySubject($subject) == 0) && (getExtensionVersion($ext) != '')) { + if ((determineTaskIdBySubject($subject) == '0') && (getExtensionVersion($ext) != '')) { // Task not created so add it createNewTask($subject, SQL_ESCAPE(loadTemplate('task_ext_deactivated', true, $ext)), 'EXTENSION_DEACTIVATION'); } // END - if @@ -1001,7 +993,7 @@ function ifModuleHasMenu ($mod, $forceDb = false) { // Determines the task id for given extension function determineExtensionTaskId ($ext_name) { // Default is not found - $task_id = 0; + $task_id = '0'; // Search for extension task's id $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `task_type`='EXTENSION' AND `subject`='[%s:]' LIMIT 1", @@ -1023,7 +1015,7 @@ function determineExtensionTaskId ($ext_name) { // Determines the task id for given subject function determineTaskIdBySubject ($subject) { // Default is not found - $task_id = 0; + $task_id = '0'; // Search for task id $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1", @@ -1242,7 +1234,7 @@ function removeExtensionUpdateDependency ($ext_name) { // Init iterator for update depencies function initExtensionUpdateIterator () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName()); - $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()] = 0; + $GLOBALS['ext_depend_iterator'][getCurrentExtensionName()] = '0'; } // Getter for depency iterator