]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions-functions.php
Make sure that extension versions not 0.0.0 are handled as updates (0.0.0 is a dummy...
[mailer.git] / inc / extensions-functions.php
index a6a2e372cc7487910e7451b10345dab6fcab9661..9c270f2ff06c669d74a2ee122a4213af8e42f714 100644 (file)
@@ -41,7 +41,7 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Load the extension and maybe found language and function files.
-function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0', $dry_run = false) {
+function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = false) {
        // 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')))) {
@@ -66,7 +66,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0', $dry_run = false
                setCurrentExtensionVersion($ext_ver);
        } else {
                // Set it to 0.0 by default
-               setCurrentExtensionVersion('0.0');
+               setCurrentExtensionVersion('0.0.0');
 
                // Is the extension installed?
                if ((isExtensionInstalled($ext_name)) && ($ext_mode != 'register')) {
@@ -75,7 +75,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0', $dry_run = false
                } // END - if
 
                // In all but test-mode we need these messages to debug! Please report all (together, e.g.)
-               if (($ext_mode != 'test') && (getCurrentExtensionVersion() == '0.0')) {
+               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));
                } // END - if
@@ -247,7 +247,7 @@ function registerExtension ($ext_name, $taskId, $dry_run = false) {
 
        // Does this extension exists?
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName=' . getCurrentExtensionName());
-       if (loadExtension(getCurrentExtensionName(), 'register', '0.0', isExtensionDryRun())) {
+       if (loadExtension(getCurrentExtensionName(), 'register', '0.0.0', isExtensionDryRun())) {
                // Set current extension name again
                setCurrentExtensionName($ext_name);
 
@@ -446,7 +446,7 @@ function doExtensionSqls ($ext_id, $load_mode) {
 
        // Load extension in detected mode
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name[' . $ext_id . ']=' . getCurrentExtensionName() . ',load_mode=' . $load_mode);
-       loadExtension(getCurrentExtensionName(), $load_mode, '0.0', false);
+       loadExtension(getCurrentExtensionName(), $load_mode, '0.0.0', false);
 
        // Init these SQLs
        initSqls();
@@ -670,8 +670,11 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
        // Check if version is updated
        //* DEBUG: */ debugOutput(getCurrentExtensionName() . '/' . $ext_name . ':' . getThisExtensionVersion() . '/' . $ext_ver . '/' . intval(is_array($history)));
        if (((getThisExtensionVersion() != $ext_ver) || (isExtensionDryRun())) && (is_array($history))) {
-               // Search for starting point
-               $start = array_search($ext_ver, $history);
+               // Search for starting point (-1 for making 0.0 -> 0.0.0 switch work)
+               $start = -1;
+               if ($ext_ver != '0.0') {
+                       $start = array_search($ext_ver, $history);
+               } // END - if
 
                // And load SQL queries in order of version history
                for ($idx = ($start + 1); $idx < count($history); $idx++) {
@@ -741,11 +744,11 @@ function updateExtension ($ext_name, $ext_ver, $dry_run = false) {
 }
 
 // Output verbose SQL table for extension
-function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false, $width = '100%') {
+function addExtensionVerboseSqlTable ($title = '{--ADMIN_SQLS_EXECUTED_ON_REMOVAL--}', $dashed = '', $switch = false, $width = '100%') {
        // Empty title?
        if (empty($title)) {
-               // Then fix it to default
-               $title = '{--ADMIN_SQLS_EXECUTED_ON_REMOVAL--}';
+               // Then abort here
+               debug_report_bug(__FUNCTION__, __LINE__, 'title is empty.');
        } // END - if
 
        // Init variables
@@ -1095,7 +1098,7 @@ function addExtensionNotes ($ext_ver) {
        // Is do we have verbose output enabled?
        if ((!isExtensionActive('sql_patches')) || (isVerboseSqlEnabled())) {
                // Update notes found?
-               if (isExtensionUpdateNoteSet($ext_ver)) {
+               if ((isExtensionUpdateNoteSet($ext_ver)) && ($ext_ver != '0.0.0')) {
                        // Update notes found
                        $content = array(
                                'ver'   => $ext_ver,
@@ -1104,12 +1107,21 @@ function addExtensionNotes ($ext_ver) {
 
                        // Reset them
                        setExtensionUpdateNotes('', $ext_ver);
-               } elseif (in_array($ext_ver, array('0.0', '0.0.0'))) {
-                       // Initial release
-                       $content = array(
-                               'ver'   => $ext_ver,
-                               'notes' => '{--INITIAL_RELEASE--}'
-                       );
+               } elseif ($ext_ver == '0.0.0') {
+                       // Is the extension productive?
+                       if (isExtensionProductive(getCurrentExtensionName())) {
+                               // Initial release
+                               $content = array(
+                                       'ver'   => $ext_ver,
+                                       'notes' => '{--INITIAL_RELEASE--}'
+                               );
+                       } else {
+                               // Not productive
+                               $content = array(
+                                       'ver'   => $ext_ver,
+                                       'notes' => '{--DEVELOPER_RELEASE--}'
+                               );
+                       }
                } else {
                        // No update notes found
                        $content = array(