Skip to content

Update to v6.5.0

KasDim edited this page May 27, 2026 · 22 revisions

1. Backup Scripts and Database

Ensure you have complete backups of your current scripts and database before proceeding.

2. Install the New Client Application

Download and install the latest version of the client application.

3. Update Server-Side Scripts

  • Docker Setup: If using a Docker container, pull the latest image and restart the container.
  • Manual Setup: Download the updated scripts and overwrite the core folder on your server.

4. Update Server Configurations

  • Migrate base constants from the config.php script to the config.json file.

  • CRITICAL: Do not forget to restrict access to config.json in your .htaccess file.

  • Update constant names to use the new MELBIS_ prefix.

  • Remove constants: MELBIS_VERSION_CACHE and MELBIS_OBFUSCATE_URL.

  • Rename constant: SHOP_CHARSET to MELBIS_CHARSET.

  • Add new constants:

  • MELBIS_ROOT (/)

  • MELBIS_CACHE (True)

  • MELBIS_BUILD (1)

  • MELBIS_ENGINE (MyISAM)

  • MELBIS_ENGINE_TEMP (Memory)

5. Execute Database Migrations

Connect to your database and run the following SQL commands:

ALTER TABLE {DBNICK}_store_comment_block ADD COLUMN from_ip6 CHAR(45) DEFAULT NULL AFTER from_ip, ADD COLUMN to_ip6 CHAR(45) DEFAULT NULL AFTER to_ip;
UPDATE {DBNICK}_store_comment_block SET from_ip6 = INET_NTOA(from_ip), to_ip6 = INET_NTOA(to_ip);
ALTER TABLE {DBNICK}_store_comment_block DROP COLUMN from_ip, DROP COLUMN to_ip, CHANGE COLUMN from_ip6 from_ip CHAR(45) NOT NULL DEFAULT '', CHANGE COLUMN to_ip6 to_ip CHAR(45) NOT NULL DEFAULT '';

ALTER TABLE {DBNICK}_user_log ADD COLUMN user_ip6 CHAR(45) DEFAULT NULL AFTER user_ip;
UPDATE {DBNICK}_user_log SET user_ip6 = INET_NTOA(user_ip);
ALTER TABLE {DBNICK}_user_log DROP COLUMN user_ip, CHANGE COLUMN user_ip6 user_ip CHAR(45) NOT NULL DEFAULT '';

ALTER TABLE {DBNICK}_store_comment ADD COLUMN user_ip6 CHAR(45) DEFAULT NULL AFTER user_ip;
UPDATE {DBNICK}_store_comment SET user_ip6 = INET_NTOA(user_ip);
ALTER TABLE {DBNICK}_store_comment DROP COLUMN user_ip, CHANGE COLUMN user_ip6 user_ip CHAR(45) NOT NULL DEFAULT '';

ALTER TABLE {DBNICK}_store_comment_vote ADD COLUMN user_ip6 CHAR(45) DEFAULT NULL AFTER user_ip;
UPDATE {DBNICK}_store_comment_vote SET user_ip6 = INET_NTOA(user_ip);
ALTER TABLE {DBNICK}_store_comment_vote DROP COLUMN user_ip, CHANGE COLUMN user_ip6 user_ip CHAR(45) NOT NULL DEFAULT '';

ALTER TABLE {DBNICK}_trans_origin ADD is_update TINYINT UNSIGNED DEFAULT '0' NOT NULL AFTER is_active;

CREATE TABLE {DBNICK}_tmp_trans_origin (
    id INT UNSIGNED DEFAULT '0' NOT NULL,
    user_id INT UNSIGNED DEFAULT NULL,
    UNIQUE (user_id, id)
) ENGINE = {ENGINE} DEFAULT CHARSET={CHARSET};

ALTER TABLE {DBNICK}_oper ADD load_max_1 DECIMAL(10,2) DEFAULT '0' NOT NULL AFTER allow_to;
ALTER TABLE {DBNICK}_oper ADD load_max_5 DECIMAL(10,2) DEFAULT '0' NOT NULL AFTER load_max_1;
ALTER TABLE {DBNICK}_oper ADD load_max_15 DECIMAL(10,2) DEFAULT '0' NOT NULL AFTER load_max_5;

ALTER TABLE {DBNICK}_self_key_value ADD prefix CHAR(100) DEFAULT '' NOT NULL AFTER code;

6. Update Client Application Settings

Launch the client application and update the following permissions under System/Users -> Operations and Permissions (Система/Пользователи -> Операции и права доступа):

Design -> Development Environment -> File Management

  • EDIT: Load list (SCRIPTS_TREE_LOAD).
  • ADD: Update structural data (SCRIPTS_STRUCTURE_REFRESH).

Installation

  • ADD: Setup settings language (SERVER_SET_LANG).

7. Refactor the Development Environment

Navigate to the Development Environment and apply the following changes to your scripts:

Core Environment Updates

  • Update standard modules: Ensure melbis.php, melbis_inc_logic.php, and other demonstration scripts are refreshed.
  • Error Logging: Place an empty error.save file in the site root to track errors (logs will be written to _error_back.log and _error_front.log). CRITICAL: Deny web access to these log files in .htaccess.
  • Entry Point: Delete lazy.php. You can now use index.php as a single entry point.

Code Adjustments

  • Superglobals: Replace legacy globals ($gGet, $gPost, $gFiles, $gServer) with native PHP superglobals ($_GET, $_POST, $_FILES, $_SERVER).

  • Includes: Replace MELBIS_INC with require_once.

  • Global Variables: Remove old globals and replace them with the new configuration constants:

  • $gSitePathMELBIS_PATH

  • $gUseCacheMELBIS_CACHE

  • $gTemplateMELBIS_TEMPLATE

  • $gBuildMELBIS_BUILD

  • IP Handling: IPv6 addresses are now stored in a text field. Review your custom code and remove conversions like INET_NTOA, INET_ATON, ip2long, and long2ip where necessary.

  • XML Module: The parameter order has changed: Xml($mFile, $mShopCharset = MELBIS_CHARSET, $mXMLCharset = 'UTF-8', $mPutTitle = true, $mStandAlone = false).

Updates to index.php

  • Remove require_once('config.php');.
  • Remove the legacy method MELBIS()->ParseLazy().
  • Remove $gSession. Session variable access is now handled via the Parser. Retain MELBIS()->DefineSession('MELBIS_SHOP'); and refactor dependent scripts accordingly.
  • Update parser variable order to the new syntax: MELBIS()->Run($entry_point, $entry_param);.

Parser & Logic Execution

  • The parser is now executed via MELBIS()-> (defined in melbis.php). You may still use the global $gParser if you define it manually in your scripts.

  • Namespaces: Note the new namespaced class instantiations:

  • $gDb = new \Melbis\MelbisShop\MySql('MELBIS_halt');

  • $gParser = new \Melbis\MelbisShop\Parser('MELBIS_halt', $gDb);

  • New Methods: Utilize MELBIS()->LanguageSet() and MELBIS()->TemplateSet() for setting the language and template groups.

  • New Methods: Convenient configuration of cron tasks directly in the development environment: MELBIS()->CronAdd() and MELBIS()->CronRun().

  • Update Method: MELBIS()->DefineSelfVars(Prefix) - now you can set a prefix for a custom constant loaded into the global MELBIS()->gVars array.

  • Order Modules: Calculation and order creation modules (e.g., MELBIS_INC_LOGIC_order_calc, MELBIS_INC_LOGIC_order_edit) now require the UserID to be passed as a separate variable (e.g., ...($mUserId, $mVersion)). Previously, this was passed inside $mVersion['user_id'].

  • Order Modules: Added/changed call parameters for MELBIS_INC_LOGIC_order_calc, MELBIS_INC_LOGIC_order_edit, instead of sub-array '_', they are in the first-level array: parameters, parent_version_id, order_id, order_version_id, order_code, order_date_time

  • Template Keys: Update system keys in your templates:

  • {PHPSESSID}{PHP_SESS_ID}

  • {LASTMODIFY}{LAST_MODIFY}

  • (Also verify: {LANG}, {ROOT}, {BUILD}, {TEMPLATE}, {TIME_ZONE})

Database Handling & Caching

  • Table Locking: Method parameters have changed. For MELBIS()->SqlTableUnlock($mLine, $mTables) and MELBIS()->SqlTableLock($mLine, $mTables), you must now pass the call line and table names including the {DBNICK} prefix.
  • APCu Requirement: Table modification timestamps are now cached in APCu memory. Ensure the PHP APCu extension is installed and that PHP is running as an Apache module or FPM to avoid data loss. (You can use the official [apc.php script](https://github.com/krakjoe/apcu/blob/master/apc.php) for monitoring).
  • Modification Tracking: Standard methods (SqlUpdate, SqlInsert, SqlDelete) track changes automatically. If altering data via custom MELBIS()->SqlQuery() calls, you must manually log the changes using MELBIS()->SqlTableChange($mLine, $mTables, $mCheckAffect = false).
  • Configure any necessary parameters for the Trick and Smart caching modules.
  • Rename module cache reset procedures: MELBIS()->ResetModuleCache()MELBIS()->UnitCacheReset().
  • Automated Maintenance: Enable automatic cache clearing with MELBIS()->CacheClearAuto(), or (highly recommended) set up a cron job using:
  • MELBIS()->CacheSmartReset()
  • MELBIS()->CacheBaseClear()
  • MELBIS()->CacheTrickClear()
  • MELBIS()->CacheStaticClear()

Optional: InnoDB Migration

If you wish to migrate your tables to the InnoDB format (which unlocks transaction methods like SqlBegin, SqlCommit, SqlRollback, and SqlTransactionActive), you can run the following automated script:

// Require main logic unit
require_once('units/melbis.php');

$command = "SHOW TABLE STATUS";
$store = MELBIS()->SqlSelect(__LINE__, $command);

foreach ($store as $row) {
    // Skip non-MyISAM tables
    if ($row['Engine'] != 'MyISAM') {
        continue;
    }

    $table = $row['Name'];

    // Check if the table matches the database prefix
    if (strpos($table, MELBIS_DB_NICK) === 0) {
        $table = substr($table, strlen(MELBIS_DB_NICK));
        $command = "ALTER TABLE {DBNICK}$table ENGINE = InnoDB";
        MELBIS()->SqlQuery(__LINE__, $command);
    }
}