Re: Automatic database upgrade for non-module objects?

Posted by skenow on 1726437418

Well, some experimenting has gotten me the results I was looking for - with a pretty small change to icms_db_legacy_updater_Handler::upgradeObjectItem(). Here's how the first lines look -

  function upgradeObjectItem($dirname, $item) {
        $module_handler = icms_getModuleHandler($item, $dirname, null, true); // this is changed

        if (!$module_handler) { // added this branch
                $module_handler = icms::handler($dirname . '_' . $item);
        }
        if (!$module_handler) {
                return false;
        }

Then, in the system module's upgrade file I added at the end

    if (!$abortUpdate) $newDbVersion = 45;
    
    if ($dbVersion < $newDbVersion) {
        $icmsDatabaseUpdater->automaticUpgrade('icms_data', array('file', 'urllink'));
        /* Finish up this portion of the db update */
        if (!$abortUpdate) {
            $icmsDatabaseUpdater->updateModuleDBVersion($newDbVersion, 'system');
            echo sprintf(_DATABASEUPDATER_UPDATE_OK, icms_conv_nr2local($newDbVersion)) . '<br />';
        }
    }        

After upgrading the system module, I had the 2 tables I needed. Updates of other IPF modules still work.

Any unexpected risks? Another few sets of eyes on this would be fantastic!


This Post was from: https://www.impresscms.org/iforum/viewtopic.php?topic_id=5951&post_id=50995