Plugin Directory

Changeset 3730078


Ignore:
Timestamp:
10/06/2026 05:56:00 AM (3 weeks ago)
Author:
lionheartgroup
Message:

Release 0.1.3

Location:
template-oriented-form-utilities
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • template-oriented-form-utilities/tags/0.1.3/readme.txt

    r3723117 r3730078  
    22Contributors: lionheartgroup
    33Tags: forms, utilities, template-oriented
    4 Requires at least: 6.0
     4Requires at least: 6.5
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 0.1.2
     7Stable tag: 0.1.3
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.txt
    … …  
    164164    - Declared `Requires at least: 6.0`, so translate.wordpress.org imports the plugin's strings.
    165165    - Escaped and sanitized request values flagged by Plugin Check.
     166* v0.1.3
     167    - Fixed: database migrations now also run when the plugin's files are replaced without
     168      WordPress's updater (FTP, deployments). The plugin compares the stored `tofu_db_version`
     169      with its own version on `init` and runs any outstanding migration once; a failed one is
     170      retried on the next request.
     171    - Requires WordPress 6.5.
    166172
    167173
  • template-oriented-form-utilities/tags/0.1.3/src/Init/Migrate.php

    r3723117 r3730078  
    1212     */
    1313    const TABLE_SUFFIX = 'tofu_migrate';
     14
     15    /**
     16     * Option holding the plugin version whose migrations have all run.
     17     */
     18    const VERSION_OPTION = 'tofu_db_version';
    1419
    1520    /**
    … …  
    7479
    7580    /**
     81     * Run the migrations once per plugin version, on any request.
     82     *
     83     * Activation and `upgrader_process_complete` miss updates made by
     84     * replacing the plugin's files (FTP, deployments), so `init` compares the
     85     * stored version first — one autoloaded option, no query when it matches.
     86     * It runs on the front end too: a form saving a record must not meet a
     87     * table without the columns it writes. Migrations are idempotent, so two
     88     * requests running them at once do no harm.
     89     *
     90     * @param string $version The plugin's version (TOFU_VERSION).
     91     * @param ?callable(): bool $runner Runs the migrations; migrate() by default.
     92     * @return bool Whether the migrations ran.
     93     */
     94    public static function maybeMigrate(string $version, ?callable $runner = null): bool
     95    {
     96        if (!static::needsMigration(get_option(static::VERSION_OPTION), $version)) {
     97            return false;
     98        }
     99
     100        $runner ??= [static::class, 'migrate'];
     101        if ($runner() === true) {
     102            update_option(static::VERSION_OPTION, $version, true);
     103        }
     104
     105        return true;
     106    }
     107
     108    /**
     109     * Whether the stored version calls for running the migrations.
     110     *
     111     * @param mixed $stored get_option() result (false when missing).
     112     * @param string $version
     113     * @return bool
     114     */
     115    public static function needsMigration(mixed $stored, string $version): bool
     116    {
     117        return $stored !== $version;
     118    }
     119
     120    /**
    76121     * Execute migrations
    77122     *
    78      * @return void
    79      */
    80     public static function migrate(): void
     123     * @return bool True when every migration has been applied (now or before).
     124     */
     125    public static function migrate(): bool
    81126    {
    82127        global $wpdb;
    83128        static::checkMigrateTable();
     129        $complete = true;
    84130
    85131        foreach ([
    … …  
    99145            if ($migrateClass === null) {
    100146                Logger::error("Migration {$migrate} does not return a Migration object.");
     147                $complete = false;
    101148                continue;
    102149            }
    … …  
    108155                if ($result === false) {
    109156                    Logger::error("Migration {$migrate} raw query failed: " . $wpdb->last_error);
     157                    $complete = false;
    110158                    continue;
    111159                }
    … …  
    125173            ]);
    126174        }
     175
     176        return $complete;
    127177    }
    128178
  • template-oriented-form-utilities/tags/0.1.3/template-oriented-form-utilities.php

    r3723117 r3730078  
    1111 * Plugin URI: https://github.com/lionheart-group/wp-template-oriented-plugins/tree/master/plugins/template-oriented-form-utilities
    1212 * Description: Template-Oriented Form Utilities is a WordPress plugin that provides a set of utilities for handling forms in a template-oriented manner.
    13  * Version: 0.1.2
     13 * Version: 0.1.3
    1414 * Author: lionheartgroup
    1515 * Author URI: https://www.lionheart.co.jp/
    1616 * Text Domain: template-oriented-form-utilities
    1717 * Domain Path: /languages
    18  * Requires at least: 6.0
     18 * Requires at least: 6.5
    1919 * Requires PHP: 8.1
    2020 * License: GPL-3.0+
    … …  
    3030 * Rename this for your plugin and update it as you release new versions.
    3131 */
    32 define('TOFU_VERSION', '0.1.2');
     32define('TOFU_VERSION', '0.1.3');
    3333define('TOFU_PLUGIN_DIR', plugin_dir_path(__FILE__));
    3434define('TOFU_PLUGIN_FILE', __FILE__);
    … …  
    4343use TofuPlugin\Init\FormsPage;
    4444use TofuPlugin\Init\Initializer;
     45use TofuPlugin\Init\Migrate;
    4546use TofuPlugin\Init\Endpoint;
    4647use TofuPlugin\Init\RestEndpoint;
    … …  
    7576    Initializer::deactivate();
    7677});
     78
     79// Run migrations not yet applied for this version, whatever way the files were
     80// updated (the hooks below miss FTP uploads and deployments).
     81add_action('init', function () {
     82    Migrate::maybeMigrate(TOFU_VERSION);
     83}, 0);
    7784
    7885// Register hooks that are fired when the plugin is upgraded.
  • template-oriented-form-utilities/tags/0.1.3/vendor/autoload.php

    r3723117 r3730078  
    2020require_once __DIR__ . '/composer/autoload_real.php';
    2121
    22 return ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2::getLoader();
     22return ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1::getLoader();
  • template-oriented-form-utilities/tags/0.1.3/vendor/composer/autoload_real.php

    r3723117 r3730078  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2
     5class ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1
    66{
    77    private static $loader;
    … …  
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::getInitializer($loader));
    3333
    3434        $loader->setClassMapAuthoritative(true);
  • template-oriented-form-utilities/tags/0.1.3/vendor/composer/autoload_static.php

    r3723117 r3730078  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2
     7class ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1
    88{
    99    public static $prefixLengthsPsr4 = array (
    … …  
    157157    {
    158158        return \Closure::bind(function () use ($loader) {
    159             $loader->prefixLengthsPsr4 = ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::$prefixLengthsPsr4;
    160             $loader->prefixDirsPsr4 = ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::$prefixDirsPsr4;
    161             $loader->classMap = ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::$classMap;
     159            $loader->prefixLengthsPsr4 = ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::$prefixLengthsPsr4;
     160            $loader->prefixDirsPsr4 = ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::$prefixDirsPsr4;
     161            $loader->classMap = ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::$classMap;
    162162
    163163        }, null, ClassLoader::class);
  • template-oriented-form-utilities/trunk/readme.txt

    r3723117 r3730078  
    22Contributors: lionheartgroup
    33Tags: forms, utilities, template-oriented
    4 Requires at least: 6.0
     4Requires at least: 6.5
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 0.1.2
     7Stable tag: 0.1.3
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.txt
    … …  
    164164    - Declared `Requires at least: 6.0`, so translate.wordpress.org imports the plugin's strings.
    165165    - Escaped and sanitized request values flagged by Plugin Check.
     166* v0.1.3
     167    - Fixed: database migrations now also run when the plugin's files are replaced without
     168      WordPress's updater (FTP, deployments). The plugin compares the stored `tofu_db_version`
     169      with its own version on `init` and runs any outstanding migration once; a failed one is
     170      retried on the next request.
     171    - Requires WordPress 6.5.
    166172
    167173
  • template-oriented-form-utilities/trunk/src/Init/Migrate.php

    r3723117 r3730078  
    1212     */
    1313    const TABLE_SUFFIX = 'tofu_migrate';
     14
     15    /**
     16     * Option holding the plugin version whose migrations have all run.
     17     */
     18    const VERSION_OPTION = 'tofu_db_version';
    1419
    1520    /**
    … …  
    7479
    7580    /**
     81     * Run the migrations once per plugin version, on any request.
     82     *
     83     * Activation and `upgrader_process_complete` miss updates made by
     84     * replacing the plugin's files (FTP, deployments), so `init` compares the
     85     * stored version first — one autoloaded option, no query when it matches.
     86     * It runs on the front end too: a form saving a record must not meet a
     87     * table without the columns it writes. Migrations are idempotent, so two
     88     * requests running them at once do no harm.
     89     *
     90     * @param string $version The plugin's version (TOFU_VERSION).
     91     * @param ?callable(): bool $runner Runs the migrations; migrate() by default.
     92     * @return bool Whether the migrations ran.
     93     */
     94    public static function maybeMigrate(string $version, ?callable $runner = null): bool
     95    {
     96        if (!static::needsMigration(get_option(static::VERSION_OPTION), $version)) {
     97            return false;
     98        }
     99
     100        $runner ??= [static::class, 'migrate'];
     101        if ($runner() === true) {
     102            update_option(static::VERSION_OPTION, $version, true);
     103        }
     104
     105        return true;
     106    }
     107
     108    /**
     109     * Whether the stored version calls for running the migrations.
     110     *
     111     * @param mixed $stored get_option() result (false when missing).
     112     * @param string $version
     113     * @return bool
     114     */
     115    public static function needsMigration(mixed $stored, string $version): bool
     116    {
     117        return $stored !== $version;
     118    }
     119
     120    /**
    76121     * Execute migrations
    77122     *
    78      * @return void
    79      */
    80     public static function migrate(): void
     123     * @return bool True when every migration has been applied (now or before).
     124     */
     125    public static function migrate(): bool
    81126    {
    82127        global $wpdb;
    83128        static::checkMigrateTable();
     129        $complete = true;
    84130
    85131        foreach ([
    … …  
    99145            if ($migrateClass === null) {
    100146                Logger::error("Migration {$migrate} does not return a Migration object.");
     147                $complete = false;
    101148                continue;
    102149            }
    … …  
    108155                if ($result === false) {
    109156                    Logger::error("Migration {$migrate} raw query failed: " . $wpdb->last_error);
     157                    $complete = false;
    110158                    continue;
    111159                }
    … …  
    125173            ]);
    126174        }
     175
     176        return $complete;
    127177    }
    128178
  • template-oriented-form-utilities/trunk/template-oriented-form-utilities.php

    r3723117 r3730078  
    1111 * Plugin URI: https://github.com/lionheart-group/wp-template-oriented-plugins/tree/master/plugins/template-oriented-form-utilities
    1212 * Description: Template-Oriented Form Utilities is a WordPress plugin that provides a set of utilities for handling forms in a template-oriented manner.
    13  * Version: 0.1.2
     13 * Version: 0.1.3
    1414 * Author: lionheartgroup
    1515 * Author URI: https://www.lionheart.co.jp/
    1616 * Text Domain: template-oriented-form-utilities
    1717 * Domain Path: /languages
    18  * Requires at least: 6.0
     18 * Requires at least: 6.5
    1919 * Requires PHP: 8.1
    2020 * License: GPL-3.0+
    … …  
    3030 * Rename this for your plugin and update it as you release new versions.
    3131 */
    32 define('TOFU_VERSION', '0.1.2');
     32define('TOFU_VERSION', '0.1.3');
    3333define('TOFU_PLUGIN_DIR', plugin_dir_path(__FILE__));
    3434define('TOFU_PLUGIN_FILE', __FILE__);
    … …  
    4343use TofuPlugin\Init\FormsPage;
    4444use TofuPlugin\Init\Initializer;
     45use TofuPlugin\Init\Migrate;
    4546use TofuPlugin\Init\Endpoint;
    4647use TofuPlugin\Init\RestEndpoint;
    … …  
    7576    Initializer::deactivate();
    7677});
     78
     79// Run migrations not yet applied for this version, whatever way the files were
     80// updated (the hooks below miss FTP uploads and deployments).
     81add_action('init', function () {
     82    Migrate::maybeMigrate(TOFU_VERSION);
     83}, 0);
    7784
    7885// Register hooks that are fired when the plugin is upgraded.
  • template-oriented-form-utilities/trunk/vendor/autoload.php

    r3723117 r3730078  
    2020require_once __DIR__ . '/composer/autoload_real.php';
    2121
    22 return ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2::getLoader();
     22return ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1::getLoader();
  • template-oriented-form-utilities/trunk/vendor/composer/autoload_real.php

    r3723117 r3730078  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2
     5class ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1
    66{
    77    private static $loader;
    … …  
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit08837cd0811da7fc7d20fb8e1a718df2', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitb966618717ad8d72bb2f45653c8b67f1', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::getInitializer($loader));
    3333
    3434        $loader->setClassMapAuthoritative(true);
  • template-oriented-form-utilities/trunk/vendor/composer/autoload_static.php

    r3723117 r3730078  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2
     7class ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1
    88{
    99    public static $prefixLengthsPsr4 = array (
    … …  
    157157    {
    158158        return \Closure::bind(function () use ($loader) {
    159             $loader->prefixLengthsPsr4 = ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::$prefixLengthsPsr4;
    160             $loader->prefixDirsPsr4 = ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::$prefixDirsPsr4;
    161             $loader->classMap = ComposerStaticInit08837cd0811da7fc7d20fb8e1a718df2::$classMap;
     159            $loader->prefixLengthsPsr4 = ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::$prefixLengthsPsr4;
     160            $loader->prefixDirsPsr4 = ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::$prefixDirsPsr4;
     161            $loader->classMap = ComposerStaticInitb966618717ad8d72bb2f45653c8b67f1::$classMap;
    162162
    163163        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.