Plugin Directory

Changeset 3479656


Ignore:
Timestamp:
03/11/2026 02:15:21 AM (3 weeks ago)
Author:
linguise
Message:

Updating to version 2.2.30

Location:
linguise
Files:
52 edited
1 copied

Legend:

Unmodified
Added
Removed
  • linguise/tags/2.2.30/composer.json

    r3463145 r3479656  
    2222  },
    2323  "require": {
    24     "linguise/script-php": "^1.3.45",
     24    "linguise/script-php": "^1.3.46",
    2525    "symfony/polyfill-intl-idn": "1.31.0",
    2626    "symfony/polyfill-mbstring": "1.31.0",
  • linguise/tags/2.2.30/languages/linguise.pot

    r3478678 r3479656  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2.29\n"
     5"Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2.30\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/linguise\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  • linguise/tags/2.2.30/linguise.php

    r3478678 r3479656  
    55 * Plugin URI: https://www.linguise.com/
    66 * Description: Linguise translation plugin
    7  * Version:2.2.29
     7 * Version:2.2.30
    88 * Text Domain: linguise
    99 * Domain Path: /languages
  • linguise/tags/2.2.30/readme.txt

    r3478678 r3479656  
    44Requires at least: 4.0
    55Tested up to: 6.9
    6 Stable tag: 2.2.29
     6Stable tag: 2.2.30
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    108108
    109109== Changelog ==
     110= 2.2.30 =
     111- Feature: Make cache clearing more consistent and eager
     112
    110113= 2.2.29 =
    111114- Fix: "has attribute" can be null in some cases should have used conditional op
  • linguise/tags/2.2.30/src/constants.php

    r3478678 r3479656  
    11<?php
    22if (!defined('LINGUISE_SCRIPT_TRANSLATION_VERSION')) {
    3     define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.29');
     3    define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.30');
    44}
    55
    66if (!defined('LINGUISE_VERSION')) {
    7     define('LINGUISE_VERSION', '2.2.29');
     7    define('LINGUISE_VERSION', '2.2.30');
    88}
  • linguise/tags/2.2.30/vendor/autoload.php

    r3463145 r3479656  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617::getLoader();
     25return ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7::getLoader();
  • linguise/tags/2.2.30/vendor/composer/autoload_psr4.php

    r3226654 r3479656  
    1313    'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
    1414    'Symfony\\Polyfill\\Intl\\Idn\\' => array($vendorDir . '/symfony/polyfill-intl-idn'),
     15    'Linguise\\Script\\Core\\Templates\\' => array($vendorDir . '/linguise/script-php/src/templates'),
    1516    'Linguise\\Script\\Core\\' => array($vendorDir . '/linguise/script-php/src'),
    1617    'JsonPath\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar/JsonPath'),
  • linguise/tags/2.2.30/vendor/composer/autoload_real.php

    r3463145 r3479656  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617
     5class ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::getInitializer($loader));
    3131
    3232        $loader->register(true);
    3333
    34         $filesToLoad = \Composer\Autoload\ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$files;
     34        $filesToLoad = \Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::$files;
    3535        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3636            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • linguise/tags/2.2.30/vendor/composer/autoload_static.php

    r3463145 r3479656  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitaf7434287c0c5184d81a0a96ec705617
     7class ComposerStaticInit64d341d450ad698561b4da1b882592a7
    88{
    99    public static $files = array (
     
    3131        'L' =>
    3232        array (
     33            'Linguise\\Script\\Core\\Templates\\' => 31,
    3334            'Linguise\\Script\\Core\\' => 21,
    3435        ),
     
    6364        array (
    6465            0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn',
     66        ),
     67        'Linguise\\Script\\Core\\Templates\\' =>
     68        array (
     69            0 => __DIR__ . '/..' . '/linguise/script-php/src/templates',
    6570        ),
    6671        'Linguise\\Script\\Core\\' =>
     
    156161    {
    157162        return \Closure::bind(function () use ($loader) {
    158             $loader->prefixLengthsPsr4 = ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$prefixLengthsPsr4;
    159             $loader->prefixDirsPsr4 = ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$prefixDirsPsr4;
    160             $loader->classMap = ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$classMap;
     163            $loader->prefixLengthsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixLengthsPsr4;
     164            $loader->prefixDirsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixDirsPsr4;
     165            $loader->classMap = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$classMap;
    161166
    162167        }, null, ClassLoader::class);
  • linguise/tags/2.2.30/vendor/composer/installed.json

    r3463145 r3479656  
    5757        {
    5858            "name": "linguise/script-php",
    59             "version": "v1.3.45",
    60             "version_normalized": "1.3.45.0",
     59            "version": "v1.3.46",
     60            "version_normalized": "1.3.46.0",
    6161            "source": {
    6262                "type": "git",
    6363                "url": "git@bitbucket.org:linguise/script-php.git",
    64                 "reference": "0a8f5e7d6aaa343d311e7c4de3858808685272ef"
     64                "reference": "0d251debce930c506aa3cd7c9835f64045888d8a"
    6565            },
    6666            "require": {
     
    7575                "vlucas/phpdotenv": "^5.6"
    7676            },
    77             "time": "2026-02-17T06:35:08+00:00",
     77            "time": "2026-03-11T01:49:57+00:00",
    7878            "type": "library",
    7979            "installation-source": "source",
    8080            "autoload": {
    8181                "psr-4": {
    82                     "Linguise\\Script\\Core\\": "src/"
     82                    "Linguise\\Script\\Core\\": "src/",
     83                    "Linguise\\Script\\Core\\Templates\\": "src/templates/"
    8384                }
    8485            },
  • linguise/tags/2.2.30/vendor/composer/installed.php

    r3478678 r3479656  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '08a04170ddd02ca3bd401c6a811ee4c513c54364',
     6        'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'linguise/script-php' => array(
    23             'pretty_version' => 'v1.3.45',
    24             'version' => '1.3.45.0',
    25             'reference' => '0a8f5e7d6aaa343d311e7c4de3858808685272ef',
     23            'pretty_version' => 'v1.3.46',
     24            'version' => '1.3.46.0',
     25            'reference' => '0d251debce930c506aa3cd7c9835f64045888d8a',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../linguise/script-php',
     
    3232            'pretty_version' => 'dev-master',
    3333            'version' => 'dev-master',
    34             'reference' => '08a04170ddd02ca3bd401c6a811ee4c513c54364',
     34            'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42',
    3535            'type' => 'library',
    3636            'install_path' => __DIR__ . '/../../',
  • linguise/tags/2.2.30/vendor/linguise/script-php/.version

    r3463145 r3479656  
    1 1.3.45
     11.3.46
  • linguise/tags/2.2.30/vendor/linguise/script-php/composer.json

    r3366846 r3479656  
    1212  "autoload": {
    1313    "psr-4": {
    14       "Linguise\\Script\\Core\\": "src/"
     14      "Linguise\\Script\\Core\\": "src/",
     15      "Linguise\\Script\\Core\\Templates\\": "src/templates/"
    1516    }
    1617  },
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Cache.php

    r3321566 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Cache
     
    3939     * @return Cache
    4040     */
    41     public static function getInstance() {
    42 
    43         if(is_null(self::$_instance)) {
     41    public static function getInstance()
     42    {
     43        if (is_null(self::$_instance)) {
    4444            self::$_instance = new Cache();
    4545        }
     
    4848    }
    4949
    50     public function getPath() {
     50    public function getPath()
     51    {
    5152        Helper::prepareDataDir();
    5253        return Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
    5354    }
    5455
    55     public function serve() {
     56    public function serve()
     57    {
    5658        $response = Response::getInstance();
    5759
     
    6971        // In case we failed to json_encode (non utf8 chars and no mbstring extension)
    7072        if (!$this->_hash) {
    71             return false;
     73            return false; // @codeCoverageIgnore
    7274        }
    7375
     
    8284
    8385        if (!$this->load()) {
    84             return false;
     86            return false; // @codeCoverageIgnore
    8587        }
    8688
     
    9092    }
    9193
    92     protected function load() {
     94    protected function load()
     95    {
    9396        $cache_file = Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $this->_language . '_' . $this->_hash . '.php';
    9497
     
    108111    }
    109112
    110     public function save() {
     113    public function save()
     114    {
    111115        if (!$this->_hash || !$this->_language) {
    112116            return false;
     
    128132        }
    129133
     134        // Run clear first
     135        $this->clear(true, 30); // aggresive 30s cache time check
     136
    130137        file_put_contents($cache_file, '<?php die(); ?>' . $content);
    131138
     
    134141
    135142    /**
     143     * Internal method to check if the cache should be cleared based on the last cleared time and the cache time check defined in configuration
     144     *
     145     * @param int $cache_time_check The time in seconds to check if the cache should be cleared or not
     146     *
     147     * @return boolean
     148     */
     149    private function internalShouldBeExecuted($cache_time_check)
     150    {
     151        $cache_info_file = $this->getPath() . 'clear.txt';
     152
     153        if (file_exists($cache_info_file)) {
     154            $last_cleared = file_get_contents($cache_info_file);
     155            if ($last_cleared === false) {
     156                // If we cannot read the file, consider it as not cleared
     157                return true; // @codeCoverageIgnore
     158            }
     159
     160            // Strip then cast to int
     161            $last_cleared = (int)trim($last_cleared);
     162            if (time() - $last_cleared < $cache_time_check) {
     163                // Cache was cleared recently, skip
     164                return false;
     165            }
     166        }
     167
     168        // too old, we can clear it again
     169        return true;
     170    }
     171
     172    /**
    136173     * Check if the request to launch this task should be executed or not
    137174     *
    138175     * @return bool
    139176     */
    140     public function shouldBeExecuted() {
     177    public function shouldBeExecuted()
     178    {
    141179        if (!Configuration::getInstance()->get('cache_enabled')) {
    142180            return false;
    143181        }
    144         $cache_info_file = $this->getPath() . 'clear.txt';
    145         if (file_exists($cache_info_file) && (int)file_get_contents($cache_info_file) + Configuration::getInstance()->get('cache_time_check') > time()) {
    146             return false;
    147         }
    148         return true;
    149     }
    150 
    151     public function clear() {
    152         if (!$this->shouldBeExecuted()) {
     182
     183        $cache_time_check = Configuration::getInstance()->get('cache_time_check') ?? 600;
     184        // cast to int
     185        $cache_time_check = (int)$cache_time_check;
     186        return $this->internalShouldBeExecuted($cache_time_check);
     187    }
     188
     189    /**
     190     * Clear cache files until the total size is under the limit defined in configuration
     191     *
     192     * @param boolean $no_output Whether to output the response or not, set to true when this method is not called from web request
     193     * @param boolean $real_timing The real timing to check if the cache should be cleared or not, used for testing purposes
     194     */
     195    public function clear($no_output = false, $real_timing = null)
     196    {
     197        if ($real_timing !== null && !$this->internalShouldBeExecuted($real_timing)) {
    153198            return;
     199        } elseif ($real_timing === null && !$this->shouldBeExecuted()) {
     200            return;
    154201        }
    155202
     
    158205        $files = glob($cache_path . '*.php');
    159206
    160         usort($files, function($x, $y) {
     207        usort($files, function ($x, $y) {
    161208            $x_mtime = @filemtime($x); // Silent both errors if the file does not exist or is not readable
    162209            $y_mtime = @filemtime($y);
    163210            if ($x_mtime === false || $y_mtime === false) {
    164                 return 0; // If we cannot get the modification time, consider them equal
     211                // If we cannot get the modification time, consider them equal
     212                return 0; // @codeCoverageIgnore
    165213            }
    166214            return ($x_mtime < $y_mtime) ? -1 : 1;
     
    176224            $size = @filesize($file); // Silent the error if the file does not exist or is not readable
    177225            if ($size === false) {
    178                 continue; // If we cannot get the size, skip this file
     226                // If we cannot get the size, skip this file
     227                continue; // @codeCoverageIgnore
    179228            }
    180229            $total_size += $size;
     
    188237        file_put_contents($cache_path . 'clear.txt', time());
    189238
     239        if ($no_output) {
     240            return;
     241        }
     242
    190243        $response = Response::getInstance();
    191244        $response->setResponseCode(200, false);
    192         $response->setContent('Cleared cache: ' . (int)($total_cleared/1000) . 'kb');
     245        $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb');
    193246        $response->end();
    194247    }
     
    200253        $files = glob($cache_path . '*.php');
    201254
    202         foreach($files as $file) {
     255        foreach ($files as $file) {
    203256            if (!in_array($file, ['.', '..']) && is_file($file)) {
    204257                $size = @filesize($file); // Silent the error if the file does not exist or is not readable
    205258                if ($size === false) {
    206                     continue; // If we cannot get the size, skip this file
     259                    // If we cannot get the size, skip this file
     260                    continue; // @codeCoverageIgnore
    207261                }
    208262                $total_cleared += $size;
     
    213267        $response = Response::getInstance();
    214268        if ($total_cleared > 0) {
    215             $response->setContent('Cleared cache: ' . (int)($total_cleared/1000) . 'kb');
     269            $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb');
    216270        } else {
    217271            $response->setContent('Cache Empty!');
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Certificates.php

    r3397694 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Certificates
     
    7070    /**
    7171     * Download latest bundle
     72     *
     73     * @codeCoverageIgnore
    7274     *
    7375     * @return void
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Configuration.php

    r3316163 r3479656  
    44use ReflectionProperty;
    55
    6 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     6defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    77
    88class Configuration {
     
    120120        $configurationLocalLoaded = $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'ConfigurationLocal.php', true);
    121121        if (!$configurationLocalLoaded) {
    122             $this->load($basePath . DIRECTORY_SEPARATOR . 'Configuration.php');
     122            $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'Configuration.php');
    123123        }
    124124    }
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Defer.php

    r2650802 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Defer
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Helper.php

    r3388557 r3479656  
    344344        }
    345345    }
     346
     347    /**
     348     * Stop the script execution
     349     *
     350     * @param string $message Optional message to display upon stopping
     351     *
     352     * @return void
     353     */
     354    public static function stop($message = '')
     355    {
     356        if (!defined('LINGUISE_SCRIPT_TESTING')) {
     357            die($message); // @codeCoverageIgnore
     358        }
     359    }
    346360}
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Hook.php

    r3265440 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Hook
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/HttpResponse.php

    r3354997 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    7 class HttpResponse {
     7class HttpResponse
     8{
    89    static function errorJSON($message, $code = 500)
    910    {
     
    1415            'message' => $message
    1516        ]);
    16         exit;
     17        Helper::stop();
    1718    }
    1819
     
    2627            'data' => $data
    2728        ]);
    28         exit;
     29        Helper::stop();
    2930    }
    3031
     
    3536        echo '<h1>403 Forbidden</h1>';
    3637        echo '<p>You are not allowed to access this page.</p>';
    37         die();
     38        Helper::stop();
    3839    }
    3940
     
    4445        echo '<h1>400 Bad Request</h1>';
    4546        echo '<p>Unknown action.</p>';
    46         die();
     47        Helper::stop();
    4748    }
    4849}
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Management.php

    r3397694 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
     6
    67use Linguise\Vendor\Linguise\Script\Core\HttpResponse;
    78
    8 class Management {
     9class Management
     10{
    911    /**
    1012     * @var null|Management
     
    4648    }
    4749
    48     public function editorRun() {
     50    public function editorRun()
     51    {
    4952        Helper::defineConstants(false);
    5053
     
    6770            $oobe = OobeManager::getInstance();
    6871            $oobe->run($message, $api_web_errors);
     72            return;
    6973        }
    7074        if (!isset($_POST['_token'])) {
     
    7377            $oobe = OobeManager::getInstance();
    7478            $oobe->run($message, $api_web_errors);
     79            return;
    7580        }
    7681        if (!$sess->verifyCsrfToken('linguise_config', $_POST['_token'])) {
     
    7883            $oobe = OobeManager::getInstance();
    7984            $oobe->run($message, $api_web_errors);
     85            return;
    8086        }
    8187
     
    127133                    ];
    128134                } else {
     135                    // @codeCoverageIgnoreStart
    129136                    $api_web_errors[] = [
    130137                        'type' => 'error',
    131138                        'message' => 'Unable to load configuration from Linguise, please try again later or contact our support team if the problem persist.',
    132139                    ];
     140                    // @codeCoverageIgnoreEnd
    133141                }
    134142
     
    158166
    159167            if (empty($dynamic_translations['public_key']) && !empty($old_options['dynamic_translations']['public_key'])) {
    160                 $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key'];
     168                $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key']; // @codeCoverageIgnore
    161169            }
    162170
     
    169177                    if ($token_changed) {
    170178                        // If token changed, we update enabled state
     179                        // @codeCoverageIgnoreStart
    171180                        $dynamic_translations['enabled'] = Helper::boolInt($api_result['data']['dynamic_translations']['enabled']);
     181                        // @codeCoverageIgnoreEnd
    172182                    }
    173183                } else if ($api_result !== false && isset($api_result['status_code'])) {
     
    329339                if ($original['value'] === $value) {
    330340                    // Skip if value is the same as original
    331                     continue;
     341                    continue; // @codeCoverageIgnore
    332342                }
    333343
    334344                if ($original['value'] === null && empty($value)) {
    335345                    // If original is null and value is empty, we don't need to save it
    336                     continue;
     346                    continue; // @codeCoverageIgnore
    337347                }
    338348
     
    355365        if (!$sess->hasSession()) {
    356366            HttpResponse::errorJSON('Unauthorized', 401);
     367            return;
    357368        }
    358369        if (!isset($_POST['nonce'])) {
    359370            HttpResponse::errorJSON('Missing nonce token', 400);
     371            return;
    360372        }
    361373        if (!$sess->verifyCsrfToken('linguise_config_iframe', $_POST['nonce'])) {
    362374            HttpResponse::errorJSON('Invalid nonce token', 403);
     375            return;
    363376        }
    364377
     
    378391                // response with error
    379392                HttpResponse::errorJSON('Missing required field: ' . $field, 400);
     393                return;
    380394            }
    381395        }
     
    414428    }
    415429
    416     // This is from API -> Website
     430    /**
     431     * This is from API -> Website (here)
     432     *
     433     * @codeCoverageIgnore
     434     */
    417435    public function remoteUpdate()
    418436    {
     
    421439        if (empty($jwt_token)) {
    422440            HttpResponse::errorJSON('Missing Hash header', 400);
     441            return;
    423442        }
    424443
     
    427446        if (empty($input_data)) {
    428447            HttpResponse::errorJSON('Invalid request', 400);
     448            return;
    429449        }
    430450
     
    432452        if (json_last_error() !== JSON_ERROR_NONE) {
    433453            HttpResponse::errorJSON('Invalid JSON data', 400);
     454            return;
    434455        }
    435456
     
    440461        if ($input_data['token'] !== $options['token']) {
    441462            HttpResponse::errorJSON('Invalid token', 401);
     463            return;
    442464        }
    443465
     
    503525            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    504526            if (Configuration::getInstance()->get('dl_certificates') === true) {
    505                 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath());
     527                curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore
    506528            }
    507529        }
     
    510532        $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    511533        if (PHP_VERSION_ID < 80000) {
     534            // @codeCoverageIgnoreStart
    512535            curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5)
     536            // @codeCoverageIgnoreEnd
    513537        }
    514538
    515539        if ($response_code !== 200) {
    516540            HttpResponse::errorJSON('Invalid JWT verification token: ' . print_r($response_code, true), 403);
     541            return;
    517542        }
    518543
     
    538563            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    539564            if (Configuration::getInstance()->get('dl_certificates') === true) {
    540                 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath());
     565                curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore
    541566            }
    542567        }
     
    548573        $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    549574        if (PHP_VERSION_ID < 80000) {
     575            // @codeCoverageIgnoreStart
    550576            curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5)
     577            // @codeCoverageIgnoreEnd
    551578        }
    552579
     
    597624            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    598625            if (Configuration::getInstance()->get('dl_certificates') === true) {
    599                 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath());
     626                curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore
    600627            }
    601628        }
     
    607634        $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    608635        if (PHP_VERSION_ID < 80000) {
     636            // @codeCoverageIgnoreStart
    609637            curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5)
     638            // @codeCoverageIgnoreEnd
    610639        }
    611640
     
    636665
    637666            if (!empty($api_host)) {
    638                 return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . '';
     667                return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . ''; // @codeCoverageIgnore
    639668            }
    640669        }
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/OobeManager.php

    r3463145 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77use Linguise\Vendor\Linguise\Script\Core\Helper;
    88
    9 class OobeManager {
     9class OobeManager
     10{
    1011    /**
    1112     * @var null|OobeManager
     
    3738    }
    3839
    39     public function oobeRun($html_message = \null) {
     40    public function oobeRun($html_message = \null)
     41    {
    4042        // Start session
    4143        $sess = Session::getInstance()->start();
     
    5456    }
    5557
     58    /**
     59     * @codeCoverageIgnore
     60     */
    5661    private function writeOOBE($database_store)
    5762    {
     63        if (defined('LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE') && LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE) {
     64            return;
     65        }
     66
    5867        // Modify OOBE status in ui-config.php
    5968        $ui_config = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR . 'ui-config.php';
     
    6372        if (empty($replaced_content)) {
    6473            HttpResponse::errorJSON('Failed to update ui-config.php', 500);
     74            return;
    6575        }
    6676
     
    8090        http_response_code($status_code);
    8191        $this->oobeRun($message);
    82         die();
     92        if (!defined('LINGUISE_SCRIPT_TESTING')) {
     93            die(); // @codeCoverageIgnore
     94        }
    8395    }
    8496
     
    158170            if (!isset($_POST['_token'])) {
    159171                HttpResponse::errorJSON('Missing CSRF token', 400);
     172                return;
    160173            }
    161174            $sess = Session::getInstance()->start();
    162175            if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) {
    163176                HttpResponse::errorJSON('Invalid CSRF token', 403);
     177                return;
    164178            }
    165179        }
     
    176190        if (empty($mode)) {
    177191            HttpResponse::errorJSON('Missing `db_mode` data', 400);
     192            return;
    178193        }
    179194
     
    182197                if (empty($host) || empty($user) || empty($name)) {
    183198                    HttpResponse::errorJSON('Missing `db_host`, `db_user` or `db_name` data', 400);
     199                    return;
    184200                }
    185201                if (!$testMode && (empty($prefix))) {
    186202                    HttpResponse::errorJSON('Missing `db_prefix` data', 400);
     203                    return;
    187204                }
    188205
     
    191208                    if ($result !== true) {
    192209                        HttpResponse::errorJSON($result, 500);
     210                        return;
    193211                    }
    194212                    HttpResponse::successJSON(true, 'MySQL connection test successful', 200);
     213                    return;
    195214                }
    196215
     
    210229                    if ($result !== true) {
    211230                        HttpResponse::errorJSON($result, 500);
     231                        return;
    212232                    }
    213233                    HttpResponse::successJSON(true, 'SQLite connection test successful', 200);
     234                    return;
    214235                }
    215236
     
    228249        if (defined('LINGUISE_OOBE_DONE') && LINGUISE_OOBE_DONE) {
    229250            $this->oobeRunError('Not allowed', 403);
     251            return;
    230252        } elseif (!defined('LINGUISE_OOBE_DONE')) {
    231253            // Missing data
    232254            $this->oobeRunError('Unknown status', 500);
     255            return;
    233256        }
    234257
    235258        if (!isset($_POST['_token'])) {
    236259            $this->oobeRunError('Missing CSRF token', 400);
     260            return;
    237261        }
    238262        $sess = Session::getInstance()->start();
    239263        if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) {
    240264            $this->oobeRunError('Invalid CSRF token', 403);
     265            return;
    241266        }
    242267
     
    244269        if (empty($new_pass)) {
    245270            $this->oobeRunError('Missing password', 400);
     271            return;
    246272        }
    247273
     
    250276        if (strlen($new_pass) < 10) {
    251277            $this->oobeRunError('Password must be at least 10 characters long', 400);
     278            return;
    252279        }
    253280
    254281        if ($sess->hasSession()) {
    255282            $this->oobeRunError('Already activated', 403);
     283            return;
    256284        }
    257285
     
    260288            if (!isset($_POST['token'])) {
    261289                $this->oobeRunError('Missing token', 400);
     290                return;
    262291            }
    263292
     
    265294            if ($token !== Configuration::getInstance()->get('token')) {
    266295                $this->oobeRunError('Invalid token provided in session', 401);
     296                return;
    267297            }
    268298
     
    288318                if ($sqlite_test !== true) {
    289319                    $this->oobeRunError($sqlite_test, 500);
     320                    return;
    290321                }
    291322            }
     
    341372            $sess->setSession($hashed_pass, true); // Set session with password mode
    342373            $this->run();
    343             die();
     374            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     375                die(); // @codeCoverageIgnore
     376            }
    344377        } else {
    345378            // This will automatically return error response
     
    364397                if ($sqlite_test !== true) {
    365398                    $this->oobeRunError($sqlite_test, 500);
     399                    return;
    366400                }
    367401            }
     
    376410            if ($existing_password) {
    377411                $this->oobeRunError('Password already set', 400);
     412                return;
    378413            }
    379414
     
    394429            $sess->setSession($hashed_pass, true); // Set session with password mode
    395430            $this->run();
    396             die();
    397         }
    398     }
    399 
    400     public function run($html_message = \null, $api_web_errors = []) {
     431            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     432                die(); // @codeCoverageIgnore
     433            }
     434        }
     435    }
     436
     437    public function run($html_message = \null, $api_web_errors = [])
     438    {
    401439        // Start session
    402440        $sess = Session::getInstance()->start();
     
    411449                case 'download-debug':
    412450                    $this->downloadDebug();
    413                     break;
     451                    return; // @codeCoverageIgnore
    414452                case 'update-config':
    415453                    break;
     
    420458                        HttpResponse::unknownGETAction();
    421459                    }
    422                     break;
     460                    return; // @codeCoverageIgnore
    423461            }
    424462        }
     
    449487        }
    450488        require_once LINGUISE_BASE_DIR . 'src' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'footer.php';
    451         die();
     489        if (!defined('LINGUISE_SCRIPT_TESTING')) {
     490            die(); // @codeCoverageIgnore
     491        }
    452492    }
    453493
     
    464504            // No session, we just redirect to login page
    465505            HttpResponse::successJSON(true, 'No session found', 200);
    466             exit;
    467506        }
    468507    }
     
    473512            $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Missing CSRF token</div>';
    474513            $this->oobeRun($message);
     514            return;
    475515        }
    476516        $sess = Session::getInstance()->start();
     
    478518            $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Invalid CSRF token</div>';
    479519            $this->oobeRun($message);
     520            return;
    480521        }
    481522
     
    498539    }
    499540
     541    /**
     542     * @codeCoverageIgnore
     543     */
    500544    private function testMySQL($host, $user, $password, $name, $port = 3306, $prefix = '')
    501545    {
     546        if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     547            return LINGUISE_TESTING_SKIP_DB_CHECK;
     548        }
     549
    502550        // Check if MySQLi is enabled
    503551        if (!extension_loaded('mysqli')) {
     
    532580    }
    533581
     582    /**
     583     * @codeCoverageIgnore
     584     */
    534585    private function testSqlite()
    535586    {
     587        if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     588            return LINGUISE_TESTING_SKIP_DB_CHECK;
     589        }
     590
    536591        // Check if SQLite3 is enabled
    537592        if (!extension_loaded('sqlite3')) {
     
    557612    }
    558613
     614    /**
     615     * @codeCoverageIgnore
     616     */
    559617    private function prepareRootDatabaseSQLite()
    560618    {
     619        if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     620            return LINGUISE_TESTING_SKIP_DB_CHECK;
     621        }
     622
    561623        $databases_dir = LINGUISE_BASE_DIR . '.databases' . DIRECTORY_SEPARATOR;
    562624        if (!file_exists($databases_dir)) {
     
    596658        $sess = Session::getInstance()->start();
    597659        if (!$sess->hasSession()) {
    598             die('Unauthorized');
     660            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     661                die('Unauthorized'); // @codeCoverageIgnore
     662            } else {
     663                throw new \Exception('Unauthorized');
     664            }
    599665        }
    600666
    601667        $debug_file = LINGUISE_BASE_DIR . 'debug.php';
    602668        if (file_exists($debug_file)) {
     669            // @codeCoverageIgnoreStart
    603670            header('Content-Description: File Transfer');
    604671            header('Content-Type: application/octet-stream');
     
    617684            }
    618685
    619             die();
     686            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     687                die(); // @codeCoverageIgnore
     688            }
     689            // @codeCoverageIgnoreEnd
    620690        } else {
    621             die('No debug file found');
     691            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     692                die('No debug file found'); // @codeCoverageIgnore
     693            } else {
     694                echo 'No debug file found';
     695            }
    622696        }
    623697    }
     
    650724
    651725        // Connect to database and install options
    652         Helper::prepareDataDir();
     726        if (!defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     727            Helper::prepareDataDir(); // @codeCoverageIgnore
     728        }
    653729        $db = Database::getInstance(true);
    654730
    655731        if (!LINGUISE_OOBE_DONE) {
    656732            // Not yet ready
    657             return;
     733            return; // @codeCoverageIgnore
    658734        }
    659735
     
    694770        if (!$sess->hasSession()) {
    695771            HttpResponse::errorJSON('Unauthorized', 401);
     772            return;
    696773        }
    697774        if (!isset($_GET['nonce'])) {
    698775            HttpResponse::errorJSON('Missing nonce token', 400);
     776            return;
    699777        }
    700778        if (!$sess->verifyCsrfToken('linguise_clear_debug', $_GET['nonce'])) {
    701779            HttpResponse::errorJSON('Invalid nonce token', 403);
     780            return;
    702781        }
    703782
     
    721800        if (!$sess->hasSession()) {
    722801            HttpResponse::errorJSON('Unauthorized', 401);
     802            return;
    723803        }
    724804        if (!isset($_GET['nonce'])) {
    725805            HttpResponse::errorJSON('Missing nonce token', 400);
     806            return;
    726807        }
    727808        if (!$sess->verifyCsrfToken('linguise_clear_cache', $_GET['nonce'])) {
    728809            HttpResponse::errorJSON('Invalid nonce token', 403);
     810            return;
    729811        }
    730812
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/Session.php

    r3388557 r3479656  
    8080        }
    8181
    82         return Database::getInstance(true, true)->ensureConnection();
     82        return Database::getInstance(true, true)->ensureConnection(); // @codeCoverageIgnore
    8383    }
    8484
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/templates/Helper.php

    r3316993 r3479656  
    55use Linguise\Vendor\Linguise\Script\Core\Request;
    66
    7 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     7defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    88
    99class Helper {
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/templates/management-expert.php

    r3316993 r3479656  
    8989        return $root . '/' . AdminHelper::getManagementBase();
    9090    }
    91     return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action;
     91    return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action; // @codeCoverageIgnore
    9292}
    9393
  • linguise/tags/2.2.30/vendor/linguise/script-php/src/templates/management.php

    r3321000 r3479656  
    8181    $nonce = Session::getInstance()->getCsrfToken($nonce_key);
    8282    if (empty($nonce)) {
    83         return make_action_url($action);
     83        return make_action_url($action); // @codeCoverageIgnore
    8484    }
    8585    return make_action_url($action) . '&nonce=' . $nonce;
     
    9898foreach ($global_options['enabled_languages'] as $language) {
    9999    if ($language === $global_options['default_language']) {
    100         continue;
     100        continue; // @codeCoverageIgnore
    101101    }
    102102    if (isset($languages_contents[$language])) {
  • linguise/trunk/composer.json

    r3463145 r3479656  
    2222  },
    2323  "require": {
    24     "linguise/script-php": "^1.3.45",
     24    "linguise/script-php": "^1.3.46",
    2525    "symfony/polyfill-intl-idn": "1.31.0",
    2626    "symfony/polyfill-mbstring": "1.31.0",
  • linguise/trunk/languages/linguise.pot

    r3478678 r3479656  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2.29\n"
     5"Project-Id-Version: Linguise - AI Automatic Multilingual Translation 2.2.30\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/linguise\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  • linguise/trunk/linguise.php

    r3478678 r3479656  
    55 * Plugin URI: https://www.linguise.com/
    66 * Description: Linguise translation plugin
    7  * Version:2.2.29
     7 * Version:2.2.30
    88 * Text Domain: linguise
    99 * Domain Path: /languages
  • linguise/trunk/readme.txt

    r3478678 r3479656  
    44Requires at least: 4.0
    55Tested up to: 6.9
    6 Stable tag: 2.2.29
     6Stable tag: 2.2.30
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    108108
    109109== Changelog ==
     110= 2.2.30 =
     111- Feature: Make cache clearing more consistent and eager
     112
    110113= 2.2.29 =
    111114- Fix: "has attribute" can be null in some cases should have used conditional op
  • linguise/trunk/src/constants.php

    r3478678 r3479656  
    11<?php
    22if (!defined('LINGUISE_SCRIPT_TRANSLATION_VERSION')) {
    3     define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.29');
     3    define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.30');
    44}
    55
    66if (!defined('LINGUISE_VERSION')) {
    7     define('LINGUISE_VERSION', '2.2.29');
     7    define('LINGUISE_VERSION', '2.2.30');
    88}
  • linguise/trunk/vendor/autoload.php

    r3463145 r3479656  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617::getLoader();
     25return ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7::getLoader();
  • linguise/trunk/vendor/composer/autoload_psr4.php

    r3226654 r3479656  
    1313    'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
    1414    'Symfony\\Polyfill\\Intl\\Idn\\' => array($vendorDir . '/symfony/polyfill-intl-idn'),
     15    'Linguise\\Script\\Core\\Templates\\' => array($vendorDir . '/linguise/script-php/src/templates'),
    1516    'Linguise\\Script\\Core\\' => array($vendorDir . '/linguise/script-php/src'),
    1617    'JsonPath\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar/JsonPath'),
  • linguise/trunk/vendor/composer/autoload_real.php

    r3463145 r3479656  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617
     5class ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInitaf7434287c0c5184d81a0a96ec705617', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit64d341d450ad698561b4da1b882592a7', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::getInitializer($loader));
    3131
    3232        $loader->register(true);
    3333
    34         $filesToLoad = \Composer\Autoload\ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$files;
     34        $filesToLoad = \Composer\Autoload\ComposerStaticInit64d341d450ad698561b4da1b882592a7::$files;
    3535        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3636            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • linguise/trunk/vendor/composer/autoload_static.php

    r3463145 r3479656  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitaf7434287c0c5184d81a0a96ec705617
     7class ComposerStaticInit64d341d450ad698561b4da1b882592a7
    88{
    99    public static $files = array (
     
    3131        'L' =>
    3232        array (
     33            'Linguise\\Script\\Core\\Templates\\' => 31,
    3334            'Linguise\\Script\\Core\\' => 21,
    3435        ),
     
    6364        array (
    6465            0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn',
     66        ),
     67        'Linguise\\Script\\Core\\Templates\\' =>
     68        array (
     69            0 => __DIR__ . '/..' . '/linguise/script-php/src/templates',
    6570        ),
    6671        'Linguise\\Script\\Core\\' =>
     
    156161    {
    157162        return \Closure::bind(function () use ($loader) {
    158             $loader->prefixLengthsPsr4 = ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$prefixLengthsPsr4;
    159             $loader->prefixDirsPsr4 = ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$prefixDirsPsr4;
    160             $loader->classMap = ComposerStaticInitaf7434287c0c5184d81a0a96ec705617::$classMap;
     163            $loader->prefixLengthsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixLengthsPsr4;
     164            $loader->prefixDirsPsr4 = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$prefixDirsPsr4;
     165            $loader->classMap = ComposerStaticInit64d341d450ad698561b4da1b882592a7::$classMap;
    161166
    162167        }, null, ClassLoader::class);
  • linguise/trunk/vendor/composer/installed.json

    r3463145 r3479656  
    5757        {
    5858            "name": "linguise/script-php",
    59             "version": "v1.3.45",
    60             "version_normalized": "1.3.45.0",
     59            "version": "v1.3.46",
     60            "version_normalized": "1.3.46.0",
    6161            "source": {
    6262                "type": "git",
    6363                "url": "git@bitbucket.org:linguise/script-php.git",
    64                 "reference": "0a8f5e7d6aaa343d311e7c4de3858808685272ef"
     64                "reference": "0d251debce930c506aa3cd7c9835f64045888d8a"
    6565            },
    6666            "require": {
     
    7575                "vlucas/phpdotenv": "^5.6"
    7676            },
    77             "time": "2026-02-17T06:35:08+00:00",
     77            "time": "2026-03-11T01:49:57+00:00",
    7878            "type": "library",
    7979            "installation-source": "source",
    8080            "autoload": {
    8181                "psr-4": {
    82                     "Linguise\\Script\\Core\\": "src/"
     82                    "Linguise\\Script\\Core\\": "src/",
     83                    "Linguise\\Script\\Core\\Templates\\": "src/templates/"
    8384                }
    8485            },
  • linguise/trunk/vendor/composer/installed.php

    r3478678 r3479656  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '08a04170ddd02ca3bd401c6a811ee4c513c54364',
     6        'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'linguise/script-php' => array(
    23             'pretty_version' => 'v1.3.45',
    24             'version' => '1.3.45.0',
    25             'reference' => '0a8f5e7d6aaa343d311e7c4de3858808685272ef',
     23            'pretty_version' => 'v1.3.46',
     24            'version' => '1.3.46.0',
     25            'reference' => '0d251debce930c506aa3cd7c9835f64045888d8a',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../linguise/script-php',
     
    3232            'pretty_version' => 'dev-master',
    3333            'version' => 'dev-master',
    34             'reference' => '08a04170ddd02ca3bd401c6a811ee4c513c54364',
     34            'reference' => 'b3dc8d26c6f5a95b5137af0a0b83bcaac4023c42',
    3535            'type' => 'library',
    3636            'install_path' => __DIR__ . '/../../',
  • linguise/trunk/vendor/linguise/script-php/.version

    r3463145 r3479656  
    1 1.3.45
     11.3.46
  • linguise/trunk/vendor/linguise/script-php/composer.json

    r3366846 r3479656  
    1212  "autoload": {
    1313    "psr-4": {
    14       "Linguise\\Script\\Core\\": "src/"
     14      "Linguise\\Script\\Core\\": "src/",
     15      "Linguise\\Script\\Core\\Templates\\": "src/templates/"
    1516    }
    1617  },
  • linguise/trunk/vendor/linguise/script-php/src/Cache.php

    r3321566 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Cache
     
    3939     * @return Cache
    4040     */
    41     public static function getInstance() {
    42 
    43         if(is_null(self::$_instance)) {
     41    public static function getInstance()
     42    {
     43        if (is_null(self::$_instance)) {
    4444            self::$_instance = new Cache();
    4545        }
     
    4848    }
    4949
    50     public function getPath() {
     50    public function getPath()
     51    {
    5152        Helper::prepareDataDir();
    5253        return Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
    5354    }
    5455
    55     public function serve() {
     56    public function serve()
     57    {
    5658        $response = Response::getInstance();
    5759
     
    6971        // In case we failed to json_encode (non utf8 chars and no mbstring extension)
    7072        if (!$this->_hash) {
    71             return false;
     73            return false; // @codeCoverageIgnore
    7274        }
    7375
     
    8284
    8385        if (!$this->load()) {
    84             return false;
     86            return false; // @codeCoverageIgnore
    8587        }
    8688
     
    9092    }
    9193
    92     protected function load() {
     94    protected function load()
     95    {
    9396        $cache_file = Configuration::getInstance()->get('data_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $this->_language . '_' . $this->_hash . '.php';
    9497
     
    108111    }
    109112
    110     public function save() {
     113    public function save()
     114    {
    111115        if (!$this->_hash || !$this->_language) {
    112116            return false;
     
    128132        }
    129133
     134        // Run clear first
     135        $this->clear(true, 30); // aggresive 30s cache time check
     136
    130137        file_put_contents($cache_file, '<?php die(); ?>' . $content);
    131138
     
    134141
    135142    /**
     143     * Internal method to check if the cache should be cleared based on the last cleared time and the cache time check defined in configuration
     144     *
     145     * @param int $cache_time_check The time in seconds to check if the cache should be cleared or not
     146     *
     147     * @return boolean
     148     */
     149    private function internalShouldBeExecuted($cache_time_check)
     150    {
     151        $cache_info_file = $this->getPath() . 'clear.txt';
     152
     153        if (file_exists($cache_info_file)) {
     154            $last_cleared = file_get_contents($cache_info_file);
     155            if ($last_cleared === false) {
     156                // If we cannot read the file, consider it as not cleared
     157                return true; // @codeCoverageIgnore
     158            }
     159
     160            // Strip then cast to int
     161            $last_cleared = (int)trim($last_cleared);
     162            if (time() - $last_cleared < $cache_time_check) {
     163                // Cache was cleared recently, skip
     164                return false;
     165            }
     166        }
     167
     168        // too old, we can clear it again
     169        return true;
     170    }
     171
     172    /**
    136173     * Check if the request to launch this task should be executed or not
    137174     *
    138175     * @return bool
    139176     */
    140     public function shouldBeExecuted() {
     177    public function shouldBeExecuted()
     178    {
    141179        if (!Configuration::getInstance()->get('cache_enabled')) {
    142180            return false;
    143181        }
    144         $cache_info_file = $this->getPath() . 'clear.txt';
    145         if (file_exists($cache_info_file) && (int)file_get_contents($cache_info_file) + Configuration::getInstance()->get('cache_time_check') > time()) {
    146             return false;
    147         }
    148         return true;
    149     }
    150 
    151     public function clear() {
    152         if (!$this->shouldBeExecuted()) {
     182
     183        $cache_time_check = Configuration::getInstance()->get('cache_time_check') ?? 600;
     184        // cast to int
     185        $cache_time_check = (int)$cache_time_check;
     186        return $this->internalShouldBeExecuted($cache_time_check);
     187    }
     188
     189    /**
     190     * Clear cache files until the total size is under the limit defined in configuration
     191     *
     192     * @param boolean $no_output Whether to output the response or not, set to true when this method is not called from web request
     193     * @param boolean $real_timing The real timing to check if the cache should be cleared or not, used for testing purposes
     194     */
     195    public function clear($no_output = false, $real_timing = null)
     196    {
     197        if ($real_timing !== null && !$this->internalShouldBeExecuted($real_timing)) {
    153198            return;
     199        } elseif ($real_timing === null && !$this->shouldBeExecuted()) {
     200            return;
    154201        }
    155202
     
    158205        $files = glob($cache_path . '*.php');
    159206
    160         usort($files, function($x, $y) {
     207        usort($files, function ($x, $y) {
    161208            $x_mtime = @filemtime($x); // Silent both errors if the file does not exist or is not readable
    162209            $y_mtime = @filemtime($y);
    163210            if ($x_mtime === false || $y_mtime === false) {
    164                 return 0; // If we cannot get the modification time, consider them equal
     211                // If we cannot get the modification time, consider them equal
     212                return 0; // @codeCoverageIgnore
    165213            }
    166214            return ($x_mtime < $y_mtime) ? -1 : 1;
     
    176224            $size = @filesize($file); // Silent the error if the file does not exist or is not readable
    177225            if ($size === false) {
    178                 continue; // If we cannot get the size, skip this file
     226                // If we cannot get the size, skip this file
     227                continue; // @codeCoverageIgnore
    179228            }
    180229            $total_size += $size;
     
    188237        file_put_contents($cache_path . 'clear.txt', time());
    189238
     239        if ($no_output) {
     240            return;
     241        }
     242
    190243        $response = Response::getInstance();
    191244        $response->setResponseCode(200, false);
    192         $response->setContent('Cleared cache: ' . (int)($total_cleared/1000) . 'kb');
     245        $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb');
    193246        $response->end();
    194247    }
     
    200253        $files = glob($cache_path . '*.php');
    201254
    202         foreach($files as $file) {
     255        foreach ($files as $file) {
    203256            if (!in_array($file, ['.', '..']) && is_file($file)) {
    204257                $size = @filesize($file); // Silent the error if the file does not exist or is not readable
    205258                if ($size === false) {
    206                     continue; // If we cannot get the size, skip this file
     259                    // If we cannot get the size, skip this file
     260                    continue; // @codeCoverageIgnore
    207261                }
    208262                $total_cleared += $size;
     
    213267        $response = Response::getInstance();
    214268        if ($total_cleared > 0) {
    215             $response->setContent('Cleared cache: ' . (int)($total_cleared/1000) . 'kb');
     269            $response->setContent('Cleared cache: ' . (int)($total_cleared / 1000) . 'kb');
    216270        } else {
    217271            $response->setContent('Cache Empty!');
  • linguise/trunk/vendor/linguise/script-php/src/Certificates.php

    r3397694 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Certificates
     
    7070    /**
    7171     * Download latest bundle
     72     *
     73     * @codeCoverageIgnore
    7274     *
    7375     * @return void
  • linguise/trunk/vendor/linguise/script-php/src/Configuration.php

    r3316163 r3479656  
    44use ReflectionProperty;
    55
    6 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     6defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    77
    88class Configuration {
     
    120120        $configurationLocalLoaded = $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'ConfigurationLocal.php', true);
    121121        if (!$configurationLocalLoaded) {
    122             $this->load($basePath . DIRECTORY_SEPARATOR . 'Configuration.php');
     122            $this->loadFile($basePath . DIRECTORY_SEPARATOR . 'Configuration.php');
    123123        }
    124124    }
  • linguise/trunk/vendor/linguise/script-php/src/Defer.php

    r2650802 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Defer
  • linguise/trunk/vendor/linguise/script-php/src/Helper.php

    r3388557 r3479656  
    344344        }
    345345    }
     346
     347    /**
     348     * Stop the script execution
     349     *
     350     * @param string $message Optional message to display upon stopping
     351     *
     352     * @return void
     353     */
     354    public static function stop($message = '')
     355    {
     356        if (!defined('LINGUISE_SCRIPT_TESTING')) {
     357            die($message); // @codeCoverageIgnore
     358        }
     359    }
    346360}
  • linguise/trunk/vendor/linguise/script-php/src/Hook.php

    r3265440 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77class Hook
  • linguise/trunk/vendor/linguise/script-php/src/HttpResponse.php

    r3354997 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    7 class HttpResponse {
     7class HttpResponse
     8{
    89    static function errorJSON($message, $code = 500)
    910    {
     
    1415            'message' => $message
    1516        ]);
    16         exit;
     17        Helper::stop();
    1718    }
    1819
     
    2627            'data' => $data
    2728        ]);
    28         exit;
     29        Helper::stop();
    2930    }
    3031
     
    3536        echo '<h1>403 Forbidden</h1>';
    3637        echo '<p>You are not allowed to access this page.</p>';
    37         die();
     38        Helper::stop();
    3839    }
    3940
     
    4445        echo '<h1>400 Bad Request</h1>';
    4546        echo '<p>Unknown action.</p>';
    46         die();
     47        Helper::stop();
    4748    }
    4849}
  • linguise/trunk/vendor/linguise/script-php/src/Management.php

    r3397694 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
     6
    67use Linguise\Vendor\Linguise\Script\Core\HttpResponse;
    78
    8 class Management {
     9class Management
     10{
    911    /**
    1012     * @var null|Management
     
    4648    }
    4749
    48     public function editorRun() {
     50    public function editorRun()
     51    {
    4952        Helper::defineConstants(false);
    5053
     
    6770            $oobe = OobeManager::getInstance();
    6871            $oobe->run($message, $api_web_errors);
     72            return;
    6973        }
    7074        if (!isset($_POST['_token'])) {
     
    7377            $oobe = OobeManager::getInstance();
    7478            $oobe->run($message, $api_web_errors);
     79            return;
    7580        }
    7681        if (!$sess->verifyCsrfToken('linguise_config', $_POST['_token'])) {
     
    7883            $oobe = OobeManager::getInstance();
    7984            $oobe->run($message, $api_web_errors);
     85            return;
    8086        }
    8187
     
    127133                    ];
    128134                } else {
     135                    // @codeCoverageIgnoreStart
    129136                    $api_web_errors[] = [
    130137                        'type' => 'error',
    131138                        'message' => 'Unable to load configuration from Linguise, please try again later or contact our support team if the problem persist.',
    132139                    ];
     140                    // @codeCoverageIgnoreEnd
    133141                }
    134142
     
    158166
    159167            if (empty($dynamic_translations['public_key']) && !empty($old_options['dynamic_translations']['public_key'])) {
    160                 $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key'];
     168                $dynamic_translations['public_key'] = $old_options['dynamic_translations']['public_key']; // @codeCoverageIgnore
    161169            }
    162170
     
    169177                    if ($token_changed) {
    170178                        // If token changed, we update enabled state
     179                        // @codeCoverageIgnoreStart
    171180                        $dynamic_translations['enabled'] = Helper::boolInt($api_result['data']['dynamic_translations']['enabled']);
     181                        // @codeCoverageIgnoreEnd
    172182                    }
    173183                } else if ($api_result !== false && isset($api_result['status_code'])) {
     
    329339                if ($original['value'] === $value) {
    330340                    // Skip if value is the same as original
    331                     continue;
     341                    continue; // @codeCoverageIgnore
    332342                }
    333343
    334344                if ($original['value'] === null && empty($value)) {
    335345                    // If original is null and value is empty, we don't need to save it
    336                     continue;
     346                    continue; // @codeCoverageIgnore
    337347                }
    338348
     
    355365        if (!$sess->hasSession()) {
    356366            HttpResponse::errorJSON('Unauthorized', 401);
     367            return;
    357368        }
    358369        if (!isset($_POST['nonce'])) {
    359370            HttpResponse::errorJSON('Missing nonce token', 400);
     371            return;
    360372        }
    361373        if (!$sess->verifyCsrfToken('linguise_config_iframe', $_POST['nonce'])) {
    362374            HttpResponse::errorJSON('Invalid nonce token', 403);
     375            return;
    363376        }
    364377
     
    378391                // response with error
    379392                HttpResponse::errorJSON('Missing required field: ' . $field, 400);
     393                return;
    380394            }
    381395        }
     
    414428    }
    415429
    416     // This is from API -> Website
     430    /**
     431     * This is from API -> Website (here)
     432     *
     433     * @codeCoverageIgnore
     434     */
    417435    public function remoteUpdate()
    418436    {
     
    421439        if (empty($jwt_token)) {
    422440            HttpResponse::errorJSON('Missing Hash header', 400);
     441            return;
    423442        }
    424443
     
    427446        if (empty($input_data)) {
    428447            HttpResponse::errorJSON('Invalid request', 400);
     448            return;
    429449        }
    430450
     
    432452        if (json_last_error() !== JSON_ERROR_NONE) {
    433453            HttpResponse::errorJSON('Invalid JSON data', 400);
     454            return;
    434455        }
    435456
     
    440461        if ($input_data['token'] !== $options['token']) {
    441462            HttpResponse::errorJSON('Invalid token', 401);
     463            return;
    442464        }
    443465
     
    503525            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    504526            if (Configuration::getInstance()->get('dl_certificates') === true) {
    505                 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath());
     527                curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore
    506528            }
    507529        }
     
    510532        $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    511533        if (PHP_VERSION_ID < 80000) {
     534            // @codeCoverageIgnoreStart
    512535            curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5)
     536            // @codeCoverageIgnoreEnd
    513537        }
    514538
    515539        if ($response_code !== 200) {
    516540            HttpResponse::errorJSON('Invalid JWT verification token: ' . print_r($response_code, true), 403);
     541            return;
    517542        }
    518543
     
    538563            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    539564            if (Configuration::getInstance()->get('dl_certificates') === true) {
    540                 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath());
     565                curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore
    541566            }
    542567        }
     
    548573        $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    549574        if (PHP_VERSION_ID < 80000) {
     575            // @codeCoverageIgnoreStart
    550576            curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5)
     577            // @codeCoverageIgnoreEnd
    551578        }
    552579
     
    597624            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    598625            if (Configuration::getInstance()->get('dl_certificates') === true) {
    599                 curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath());
     626                curl_setopt($ch, CURLOPT_CAINFO, Certificates::getInstance()->getPath()); // @codeCoverageIgnore
    600627            }
    601628        }
     
    607634        $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    608635        if (PHP_VERSION_ID < 80000) {
     636            // @codeCoverageIgnoreStart
    609637            curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5)
     638            // @codeCoverageIgnoreEnd
    610639        }
    611640
     
    636665
    637666            if (!empty($api_host)) {
    638                 return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . '';
     667                return $protocol . '://' . $api_host . (in_array($api_port, $api_port_base) ? '' : ':' . $api_port) . ''; // @codeCoverageIgnore
    639668            }
    640669        }
  • linguise/trunk/vendor/linguise/script-php/src/OobeManager.php

    r3463145 r3479656  
    33namespace Linguise\Vendor\Linguise\Script\Core;
    44
    5 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     5defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    66
    77use Linguise\Vendor\Linguise\Script\Core\Helper;
    88
    9 class OobeManager {
     9class OobeManager
     10{
    1011    /**
    1112     * @var null|OobeManager
     
    3738    }
    3839
    39     public function oobeRun($html_message = \null) {
     40    public function oobeRun($html_message = \null)
     41    {
    4042        // Start session
    4143        $sess = Session::getInstance()->start();
     
    5456    }
    5557
     58    /**
     59     * @codeCoverageIgnore
     60     */
    5661    private function writeOOBE($database_store)
    5762    {
     63        if (defined('LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE') && LINGUISE_SCRIPT_TESTING_SKIP_OOBE_WRITE) {
     64            return;
     65        }
     66
    5867        // Modify OOBE status in ui-config.php
    5968        $ui_config = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR . 'ui-config.php';
     
    6372        if (empty($replaced_content)) {
    6473            HttpResponse::errorJSON('Failed to update ui-config.php', 500);
     74            return;
    6575        }
    6676
     
    8090        http_response_code($status_code);
    8191        $this->oobeRun($message);
    82         die();
     92        if (!defined('LINGUISE_SCRIPT_TESTING')) {
     93            die(); // @codeCoverageIgnore
     94        }
    8395    }
    8496
     
    158170            if (!isset($_POST['_token'])) {
    159171                HttpResponse::errorJSON('Missing CSRF token', 400);
     172                return;
    160173            }
    161174            $sess = Session::getInstance()->start();
    162175            if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) {
    163176                HttpResponse::errorJSON('Invalid CSRF token', 403);
     177                return;
    164178            }
    165179        }
     
    176190        if (empty($mode)) {
    177191            HttpResponse::errorJSON('Missing `db_mode` data', 400);
     192            return;
    178193        }
    179194
     
    182197                if (empty($host) || empty($user) || empty($name)) {
    183198                    HttpResponse::errorJSON('Missing `db_host`, `db_user` or `db_name` data', 400);
     199                    return;
    184200                }
    185201                if (!$testMode && (empty($prefix))) {
    186202                    HttpResponse::errorJSON('Missing `db_prefix` data', 400);
     203                    return;
    187204                }
    188205
     
    191208                    if ($result !== true) {
    192209                        HttpResponse::errorJSON($result, 500);
     210                        return;
    193211                    }
    194212                    HttpResponse::successJSON(true, 'MySQL connection test successful', 200);
     213                    return;
    195214                }
    196215
     
    210229                    if ($result !== true) {
    211230                        HttpResponse::errorJSON($result, 500);
     231                        return;
    212232                    }
    213233                    HttpResponse::successJSON(true, 'SQLite connection test successful', 200);
     234                    return;
    214235                }
    215236
     
    228249        if (defined('LINGUISE_OOBE_DONE') && LINGUISE_OOBE_DONE) {
    229250            $this->oobeRunError('Not allowed', 403);
     251            return;
    230252        } elseif (!defined('LINGUISE_OOBE_DONE')) {
    231253            // Missing data
    232254            $this->oobeRunError('Unknown status', 500);
     255            return;
    233256        }
    234257
    235258        if (!isset($_POST['_token'])) {
    236259            $this->oobeRunError('Missing CSRF token', 400);
     260            return;
    237261        }
    238262        $sess = Session::getInstance()->start();
    239263        if (!$sess->verifyCsrfToken('linguise_oobe_register', $_POST['_token'])) {
    240264            $this->oobeRunError('Invalid CSRF token', 403);
     265            return;
    241266        }
    242267
     
    244269        if (empty($new_pass)) {
    245270            $this->oobeRunError('Missing password', 400);
     271            return;
    246272        }
    247273
     
    250276        if (strlen($new_pass) < 10) {
    251277            $this->oobeRunError('Password must be at least 10 characters long', 400);
     278            return;
    252279        }
    253280
    254281        if ($sess->hasSession()) {
    255282            $this->oobeRunError('Already activated', 403);
     283            return;
    256284        }
    257285
     
    260288            if (!isset($_POST['token'])) {
    261289                $this->oobeRunError('Missing token', 400);
     290                return;
    262291            }
    263292
     
    265294            if ($token !== Configuration::getInstance()->get('token')) {
    266295                $this->oobeRunError('Invalid token provided in session', 401);
     296                return;
    267297            }
    268298
     
    288318                if ($sqlite_test !== true) {
    289319                    $this->oobeRunError($sqlite_test, 500);
     320                    return;
    290321                }
    291322            }
     
    341372            $sess->setSession($hashed_pass, true); // Set session with password mode
    342373            $this->run();
    343             die();
     374            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     375                die(); // @codeCoverageIgnore
     376            }
    344377        } else {
    345378            // This will automatically return error response
     
    364397                if ($sqlite_test !== true) {
    365398                    $this->oobeRunError($sqlite_test, 500);
     399                    return;
    366400                }
    367401            }
     
    376410            if ($existing_password) {
    377411                $this->oobeRunError('Password already set', 400);
     412                return;
    378413            }
    379414
     
    394429            $sess->setSession($hashed_pass, true); // Set session with password mode
    395430            $this->run();
    396             die();
    397         }
    398     }
    399 
    400     public function run($html_message = \null, $api_web_errors = []) {
     431            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     432                die(); // @codeCoverageIgnore
     433            }
     434        }
     435    }
     436
     437    public function run($html_message = \null, $api_web_errors = [])
     438    {
    401439        // Start session
    402440        $sess = Session::getInstance()->start();
     
    411449                case 'download-debug':
    412450                    $this->downloadDebug();
    413                     break;
     451                    return; // @codeCoverageIgnore
    414452                case 'update-config':
    415453                    break;
     
    420458                        HttpResponse::unknownGETAction();
    421459                    }
    422                     break;
     460                    return; // @codeCoverageIgnore
    423461            }
    424462        }
     
    449487        }
    450488        require_once LINGUISE_BASE_DIR . 'src' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'footer.php';
    451         die();
     489        if (!defined('LINGUISE_SCRIPT_TESTING')) {
     490            die(); // @codeCoverageIgnore
     491        }
    452492    }
    453493
     
    464504            // No session, we just redirect to login page
    465505            HttpResponse::successJSON(true, 'No session found', 200);
    466             exit;
    467506        }
    468507    }
     
    473512            $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Missing CSRF token</div>';
    474513            $this->oobeRun($message);
     514            return;
    475515        }
    476516        $sess = Session::getInstance()->start();
     
    478518            $message = '<div class="linguise-notification-popup"><span class="material-icons fail">check</span>Invalid CSRF token</div>';
    479519            $this->oobeRun($message);
     520            return;
    480521        }
    481522
     
    498539    }
    499540
     541    /**
     542     * @codeCoverageIgnore
     543     */
    500544    private function testMySQL($host, $user, $password, $name, $port = 3306, $prefix = '')
    501545    {
     546        if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     547            return LINGUISE_TESTING_SKIP_DB_CHECK;
     548        }
     549
    502550        // Check if MySQLi is enabled
    503551        if (!extension_loaded('mysqli')) {
     
    532580    }
    533581
     582    /**
     583     * @codeCoverageIgnore
     584     */
    534585    private function testSqlite()
    535586    {
     587        if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     588            return LINGUISE_TESTING_SKIP_DB_CHECK;
     589        }
     590
    536591        // Check if SQLite3 is enabled
    537592        if (!extension_loaded('sqlite3')) {
     
    557612    }
    558613
     614    /**
     615     * @codeCoverageIgnore
     616     */
    559617    private function prepareRootDatabaseSQLite()
    560618    {
     619        if (defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     620            return LINGUISE_TESTING_SKIP_DB_CHECK;
     621        }
     622
    561623        $databases_dir = LINGUISE_BASE_DIR . '.databases' . DIRECTORY_SEPARATOR;
    562624        if (!file_exists($databases_dir)) {
     
    596658        $sess = Session::getInstance()->start();
    597659        if (!$sess->hasSession()) {
    598             die('Unauthorized');
     660            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     661                die('Unauthorized'); // @codeCoverageIgnore
     662            } else {
     663                throw new \Exception('Unauthorized');
     664            }
    599665        }
    600666
    601667        $debug_file = LINGUISE_BASE_DIR . 'debug.php';
    602668        if (file_exists($debug_file)) {
     669            // @codeCoverageIgnoreStart
    603670            header('Content-Description: File Transfer');
    604671            header('Content-Type: application/octet-stream');
     
    617684            }
    618685
    619             die();
     686            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     687                die(); // @codeCoverageIgnore
     688            }
     689            // @codeCoverageIgnoreEnd
    620690        } else {
    621             die('No debug file found');
     691            if (!defined('LINGUISE_SCRIPT_TESTING')) {
     692                die('No debug file found'); // @codeCoverageIgnore
     693            } else {
     694                echo 'No debug file found';
     695            }
    622696        }
    623697    }
     
    650724
    651725        // Connect to database and install options
    652         Helper::prepareDataDir();
     726        if (!defined('LINGUISE_TESTING_SKIP_DB_CHECK')) {
     727            Helper::prepareDataDir(); // @codeCoverageIgnore
     728        }
    653729        $db = Database::getInstance(true);
    654730
    655731        if (!LINGUISE_OOBE_DONE) {
    656732            // Not yet ready
    657             return;
     733            return; // @codeCoverageIgnore
    658734        }
    659735
     
    694770        if (!$sess->hasSession()) {
    695771            HttpResponse::errorJSON('Unauthorized', 401);
     772            return;
    696773        }
    697774        if (!isset($_GET['nonce'])) {
    698775            HttpResponse::errorJSON('Missing nonce token', 400);
     776            return;
    699777        }
    700778        if (!$sess->verifyCsrfToken('linguise_clear_debug', $_GET['nonce'])) {
    701779            HttpResponse::errorJSON('Invalid nonce token', 403);
     780            return;
    702781        }
    703782
     
    721800        if (!$sess->hasSession()) {
    722801            HttpResponse::errorJSON('Unauthorized', 401);
     802            return;
    723803        }
    724804        if (!isset($_GET['nonce'])) {
    725805            HttpResponse::errorJSON('Missing nonce token', 400);
     806            return;
    726807        }
    727808        if (!$sess->verifyCsrfToken('linguise_clear_cache', $_GET['nonce'])) {
    728809            HttpResponse::errorJSON('Invalid nonce token', 403);
     810            return;
    729811        }
    730812
  • linguise/trunk/vendor/linguise/script-php/src/Session.php

    r3388557 r3479656  
    8080        }
    8181
    82         return Database::getInstance(true, true)->ensureConnection();
     82        return Database::getInstance(true, true)->ensureConnection(); // @codeCoverageIgnore
    8383    }
    8484
  • linguise/trunk/vendor/linguise/script-php/src/templates/Helper.php

    r3316993 r3479656  
    55use Linguise\Vendor\Linguise\Script\Core\Request;
    66
    7 defined('LINGUISE_SCRIPT_TRANSLATION') or die();
     7defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore
    88
    99class Helper {
  • linguise/trunk/vendor/linguise/script-php/src/templates/management-expert.php

    r3316993 r3479656  
    8989        return $root . '/' . AdminHelper::getManagementBase();
    9090    }
    91     return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action;
     91    return $root . '/' . AdminHelper::getManagementBase() . '?linguise_action=' . $action; // @codeCoverageIgnore
    9292}
    9393
  • linguise/trunk/vendor/linguise/script-php/src/templates/management.php

    r3321000 r3479656  
    8181    $nonce = Session::getInstance()->getCsrfToken($nonce_key);
    8282    if (empty($nonce)) {
    83         return make_action_url($action);
     83        return make_action_url($action); // @codeCoverageIgnore
    8484    }
    8585    return make_action_url($action) . '&nonce=' . $nonce;
     
    9898foreach ($global_options['enabled_languages'] as $language) {
    9999    if ($language === $global_options['default_language']) {
    100         continue;
     100        continue; // @codeCoverageIgnore
    101101    }
    102102    if (isset($languages_contents[$language])) {
Note: See TracChangeset for help on using the changeset viewer.