From 78a9655d102a8602feb0330837282e6aefe3cfba Mon Sep 17 00:00:00 2001 From: taoser Date: Wed, 2 Aug 2023 19:41:11 +0800 Subject: [PATCH] 2.3.10 --- composer.lock | 58 +- vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_static.php | 8 +- vendor/composer/installed.json | 92 +- vendor/composer/installed.php | 42 +- vendor/laravel/serializable-closure/README.md | 7 +- .../src/Support/ReflectionClosure.php | 5 +- vendor/services.php | 2 +- .../var-exporter/Internal/Exporter.php | 13 +- vendor/topthink/framework/README.md | 2 +- vendor/topthink/framework/src/think/App.php | 2 +- .../framework/src/think/Filesystem.php | 89 -- .../framework/src/think/cache/driver/File.php | 3 +- .../think/console/command/optimize/Schema.php | 5 + .../framework/src/think/facade/Filesystem.php | 33 - .../src/think/filesystem/CacheStore.php | 54 - .../framework/src/think/filesystem/Driver.php | 144 --- .../src/think/filesystem/driver/Local.php | 59 - .../framework/src/think/initializer/Error.php | 4 +- .../framework/src/think/route/RuleGroup.php | 3 +- .../framework/tests/FilesystemTest.php | 131 -- vendor/topthink/think-migration/composer.json | 2 +- .../src/Phinx/Db/Adapter/AdapterFactory.php | 1 + .../phinx/src/Phinx/Db/Adapter/DmAdapter.php | 1134 +++++++++++++++++ vendor/workerman/workerman/Events/Ev.php | 4 +- vendor/workerman/workerman/Events/Uv.php | 4 +- .../workerman/Protocols/Http/Request.php | 25 +- .../workerman/Protocols/Http/Response.php | 2 +- .../workerman/Protocols/Http/Session.php | 22 +- vendor/workerman/workerman/Worker.php | 26 +- 30 files changed, 1321 insertions(+), 657 deletions(-) delete mode 100644 vendor/topthink/framework/src/think/Filesystem.php delete mode 100644 vendor/topthink/framework/src/think/facade/Filesystem.php delete mode 100644 vendor/topthink/framework/src/think/filesystem/CacheStore.php delete mode 100644 vendor/topthink/framework/src/think/filesystem/Driver.php delete mode 100644 vendor/topthink/framework/src/think/filesystem/driver/Local.php delete mode 100644 vendor/topthink/framework/tests/FilesystemTest.php create mode 100644 vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/DmAdapter.php diff --git a/composer.lock b/composer.lock index 301ab4b..f155291 100644 --- a/composer.lock +++ b/composer.lock @@ -796,16 +796,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.3.0", + "version": "v1.3.1", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" + "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/e5a3057a5591e1cfe8183034b0203921abe2c902", + "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902", "shasum": "" }, "require": { @@ -852,7 +852,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2023-01-30T18:31:20+00:00" + "time": "2023-07-14T13:56:28+00:00" }, { "name": "league/flysystem", @@ -2106,16 +2106,16 @@ }, { "name": "symfony/var-exporter", - "version": "v5.4.21", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4" + "reference": "11401fe94f960249b3c63a488c63ba73091c1e4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/11401fe94f960249b3c63a488c63ba73091c1e4a", + "reference": "11401fe94f960249b3c63a488c63ba73091c1e4a", "shasum": "" }, "require": { @@ -2159,7 +2159,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v5.4.21" + "source": "https://github.com/symfony/var-exporter/tree/v5.4.26" }, "funding": [ { @@ -2175,7 +2175,7 @@ "type": "tidelift" } ], - "time": "2023-02-21T19:46:44+00:00" + "time": "2023-07-20T07:21:16+00:00" }, { "name": "taoser/think-addons", @@ -2383,16 +2383,16 @@ }, { "name": "topthink/framework", - "version": "v6.1.3", + "version": "v6.1.4", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041" + "reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/7c324e7011246f0064b055b62ab9c3921cf0a041", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041", + "url": "https://api.github.com/repos/top-think/framework/zipball/66eb9cf4d627df12911344cd328faf9bb596bf2c", + "reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c", "shasum": "" }, "require": { @@ -2442,9 +2442,9 @@ ], "support": { "issues": "https://github.com/top-think/framework/issues", - "source": "https://github.com/top-think/framework/tree/v6.1.3" + "source": "https://github.com/top-think/framework/tree/v6.1.4" }, - "time": "2023-05-22T03:02:08+00:00" + "time": "2023-07-11T15:16:03+00:00" }, { "name": "topthink/think-captcha", @@ -2592,20 +2592,20 @@ }, { "name": "topthink/think-migration", - "version": "v3.0.5", + "version": "v3.0.6", "source": { "type": "git", "url": "https://github.com/top-think/think-migration.git", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca" + "reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-migration/zipball/7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", + "url": "https://api.github.com/repos/top-think/think-migration/zipball/82c4226cb14f973b9377c7fc6e89c525cbb8b030", + "reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030", "shasum": "" }, "require": { - "topthink/framework": "^6.0", + "topthink/framework": "^6.0 || ^8.0", "topthink/think-helper": "^3.0.3" }, "require-dev": { @@ -2640,9 +2640,9 @@ ], "support": { "issues": "https://github.com/top-think/think-migration/issues", - "source": "https://github.com/top-think/think-migration/tree/v3.0.5" + "source": "https://github.com/top-think/think-migration/tree/v3.0.6" }, - "time": "2023-02-26T13:16:22+00:00" + "time": "2023-07-01T11:01:52+00:00" }, { "name": "topthink/think-multi-app", @@ -2958,16 +2958,16 @@ }, { "name": "workerman/workerman", - "version": "v4.1.10", + "version": "v4.1.13", "source": { "type": "git", "url": "https://github.com/walkor/workerman.git", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83" + "reference": "807780ff672775fcd08f89e573a2824e939021ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/workerman/zipball/e967b79f95b9251a72acb971be05623ec1a51e83", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83", + "url": "https://api.github.com/repos/walkor/workerman/zipball/807780ff672775fcd08f89e573a2824e939021ce", + "reference": "807780ff672775fcd08f89e573a2824e939021ce", "shasum": "" }, "require": { @@ -3017,7 +3017,7 @@ "type": "patreon" } ], - "time": "2023-05-01T02:12:20+00:00" + "time": "2023-07-31T05:57:25+00:00" }, { "name": "yansongda/pay", diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 5e85e55..09a75b3 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -14,7 +14,7 @@ return array( 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'), - 'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'), + 'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/framework/src/think'), 'taoser\\think\\' => array($vendorDir . '/taoser/think-auth/src'), 'taoser\\' => array($vendorDir . '/taoser/think-addons/src', $vendorDir . '/taoser/think-setarr/src'), 'phpspirit\\databackup\\' => array($vendorDir . '/lotofbadcode/phpspirit_databackup/src'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 3c638c2..ab45f3b 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -176,10 +176,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 ), 'think\\' => array ( - 0 => __DIR__ . '/..' . '/topthink/framework/src/think', - 1 => __DIR__ . '/..' . '/topthink/think-helper/src', - 2 => __DIR__ . '/..' . '/topthink/think-orm/src', - 3 => __DIR__ . '/..' . '/topthink/think-template/src', + 0 => __DIR__ . '/..' . '/topthink/think-helper/src', + 1 => __DIR__ . '/..' . '/topthink/think-orm/src', + 2 => __DIR__ . '/..' . '/topthink/think-template/src', + 3 => __DIR__ . '/..' . '/topthink/framework/src/think', ), 'taoser\\think\\' => array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9c34d1c..56b9137 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -850,17 +850,17 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.3.0", - "version_normalized": "1.3.0.0", + "version": "v1.3.1", + "version_normalized": "1.3.1.0", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" + "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/e5a3057a5591e1cfe8183034b0203921abe2c902", + "reference": "e5a3057a5591e1cfe8183034b0203921abe2c902", "shasum": "" }, "require": { @@ -872,7 +872,7 @@ "phpstan/phpstan": "^1.8.2", "symfony/var-dumper": "^5.4.11" }, - "time": "2023-01-30T18:31:20+00:00", + "time": "2023-07-14T13:56:28+00:00", "type": "library", "extra": { "branch-alias": { @@ -2289,24 +2289,18 @@ }, { "name": "symfony/var-exporter", - "version": "v5.4.21", - "version_normalized": "5.4.21.0", + "version": "v5.4.26", + "version_normalized": "5.4.26.0", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4" + "reference": "11401fe94f960249b3c63a488c63ba73091c1e4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/11401fe94f960249b3c63a488c63ba73091c1e4a", + "reference": "11401fe94f960249b3c63a488c63ba73091c1e4a", + "shasum": "" }, "require": { "php": ">=7.2.5", @@ -2315,7 +2309,7 @@ "require-dev": { "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" }, - "time": "2023-02-21T19:46:44+00:00", + "time": "2023-07-20T07:21:16+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2351,7 +2345,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v5.4.21" + "source": "https://github.com/symfony/var-exporter/tree/v5.4.26" }, "funding": [ { @@ -2599,24 +2593,18 @@ }, { "name": "topthink/framework", - "version": "v6.1.3", - "version_normalized": "6.1.3.0", + "version": "v6.1.4", + "version_normalized": "6.1.4.0", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041" + "reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/7c324e7011246f0064b055b62ab9c3921cf0a041", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/top-think/framework/zipball/66eb9cf4d627df12911344cd328faf9bb596bf2c", + "reference": "66eb9cf4d627df12911344cd328faf9bb596bf2c", + "shasum": "" }, "require": { "ext-json": "*", @@ -2635,7 +2623,7 @@ "mockery/mockery": "^1.2", "phpunit/phpunit": "^7.0" }, - "time": "2023-05-22T03:02:08+00:00", + "time": "2023-07-11T15:16:03+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2667,7 +2655,7 @@ ], "support": { "issues": "https://github.com/top-think/framework/issues", - "source": "https://github.com/top-think/framework/tree/v6.1.3" + "source": "https://github.com/top-think/framework/tree/v6.1.4" }, "install-path": "../topthink/framework" }, @@ -2844,21 +2832,21 @@ }, { "name": "topthink/think-migration", - "version": "v3.0.5", - "version_normalized": "3.0.5.0", + "version": "v3.0.6", + "version_normalized": "3.0.6.0", "source": { "type": "git", "url": "https://github.com/top-think/think-migration.git", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca" + "reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-migration/zipball/7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", + "url": "https://api.github.com/repos/top-think/think-migration/zipball/82c4226cb14f973b9377c7fc6e89c525cbb8b030", + "reference": "82c4226cb14f973b9377c7fc6e89c525cbb8b030", "shasum": "" }, "require": { - "topthink/framework": "^6.0", + "topthink/framework": "^6.0 || ^8.0", "topthink/think-helper": "^3.0.3" }, "require-dev": { @@ -2867,7 +2855,7 @@ "suggest": { "fzaninotto/faker": "Required to use the factory builder (^1.8)." }, - "time": "2023-02-26T13:16:22+00:00", + "time": "2023-07-01T11:01:52+00:00", "type": "library", "extra": { "think": { @@ -2895,7 +2883,7 @@ ], "support": { "issues": "https://github.com/top-think/think-migration/issues", - "source": "https://github.com/top-think/think-migration/tree/v3.0.5" + "source": "https://github.com/top-think/think-migration/tree/v3.0.6" }, "install-path": "../topthink/think-migration" }, @@ -3326,24 +3314,18 @@ }, { "name": "workerman/workerman", - "version": "v4.1.10", - "version_normalized": "4.1.10.0", + "version": "v4.1.13", + "version_normalized": "4.1.13.0", "source": { "type": "git", "url": "https://github.com/walkor/workerman.git", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83" + "reference": "807780ff672775fcd08f89e573a2824e939021ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/walkor/workerman/zipball/e967b79f95b9251a72acb971be05623ec1a51e83", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/walkor/workerman/zipball/807780ff672775fcd08f89e573a2824e939021ce", + "reference": "807780ff672775fcd08f89e573a2824e939021ce", + "shasum": "" }, "require": { "php": ">=7.0" @@ -3351,7 +3333,7 @@ "suggest": { "ext-event": "For better performance. " }, - "time": "2023-05-01T02:12:20+00:00", + "time": "2023-07-31T05:57:25+00:00", "type": "library", "installation-source": "dist", "autoload": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 3c23038..de4a46e 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'taoser/taoler', - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '4be45082e6e9bbe7fa38b4fca5566a08fe1a24a6', + 'pretty_version' => '2.3.10.x-dev', + 'version' => '2.3.10.9999999-dev', + 'reference' => '0c2f0154a81dd0a6268da627982d1bf41c0ef231', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -119,9 +119,9 @@ 'dev_requirement' => false, ), 'laravel/serializable-closure' => array( - 'pretty_version' => 'v1.3.0', - 'version' => '1.3.0.0', - 'reference' => 'f23fe9d4e95255dacee1bf3525e0810d1a1b0f37', + 'pretty_version' => 'v1.3.1', + 'version' => '1.3.1.0', + 'reference' => 'e5a3057a5591e1cfe8183034b0203921abe2c902', 'type' => 'library', 'install_path' => __DIR__ . '/../laravel/serializable-closure', 'aliases' => array(), @@ -338,18 +338,18 @@ 'dev_requirement' => false, ), 'symfony/var-exporter' => array( - 'pretty_version' => 'v5.4.21', - 'version' => '5.4.21.0', - 'reference' => 'be74908a6942fdd331554b3cec27ff41b45ccad4', + 'pretty_version' => 'v5.4.26', + 'version' => '5.4.26.0', + 'reference' => '11401fe94f960249b3c63a488c63ba73091c1e4a', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/var-exporter', 'aliases' => array(), 'dev_requirement' => false, ), 'taoser/taoler' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '4be45082e6e9bbe7fa38b4fca5566a08fe1a24a6', + 'pretty_version' => '2.3.10.x-dev', + 'version' => '2.3.10.9999999-dev', + 'reference' => '0c2f0154a81dd0a6268da627982d1bf41c0ef231', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -392,9 +392,9 @@ 'dev_requirement' => false, ), 'topthink/framework' => array( - 'pretty_version' => 'v6.1.3', - 'version' => '6.1.3.0', - 'reference' => '7c324e7011246f0064b055b62ab9c3921cf0a041', + 'pretty_version' => 'v6.1.4', + 'version' => '6.1.4.0', + 'reference' => '66eb9cf4d627df12911344cd328faf9bb596bf2c', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/framework', 'aliases' => array(), @@ -428,9 +428,9 @@ 'dev_requirement' => false, ), 'topthink/think-migration' => array( - 'pretty_version' => 'v3.0.5', - 'version' => '3.0.5.0', - 'reference' => '7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca', + 'pretty_version' => 'v3.0.6', + 'version' => '3.0.6.0', + 'reference' => '82c4226cb14f973b9377c7fc6e89c525cbb8b030', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/think-migration', 'aliases' => array(), @@ -509,9 +509,9 @@ 'dev_requirement' => false, ), 'workerman/workerman' => array( - 'pretty_version' => 'v4.1.10', - 'version' => '4.1.10.0', - 'reference' => 'e967b79f95b9251a72acb971be05623ec1a51e83', + 'pretty_version' => 'v4.1.13', + 'version' => '4.1.13.0', + 'reference' => '807780ff672775fcd08f89e573a2824e939021ce', 'type' => 'library', 'install_path' => __DIR__ . '/../workerman/workerman', 'aliases' => array(), diff --git a/vendor/laravel/serializable-closure/README.md b/vendor/laravel/serializable-closure/README.md index b1efef3..ee0d01a 100644 --- a/vendor/laravel/serializable-closure/README.md +++ b/vendor/laravel/serializable-closure/README.md @@ -51,9 +51,10 @@ echo $closure(); // james; ### Caveats -1. Creating **anonymous classes** within closures is not supported. -2. Using attributes within closures is not supported. -3. Serializing closures on REPL environments such as Laravel Tinker is not supported. +* Anonymous classes cannot be created within closures. +* Attributes cannot be used within closures. +* Serializing closures on REPL environments like Laravel Tinker is not supported. +* Serializing closures that reference objects with readonly properties is not supported. ## Contributing diff --git a/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php b/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php index a0d3707..d2a7010 100644 --- a/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php +++ b/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php @@ -511,8 +511,7 @@ class ReflectionClosure extends ReflectionFunction // named arguments... case ':': if ($lastState === 'closure' && $context === 'root') { - $state = 'ignore_next'; - $lastState = 'closure'; + $state = 'closure'; $code .= $id_start.$token; } @@ -651,7 +650,7 @@ class ReflectionClosure extends ReflectionFunction $state = 'id_name'; $context = 'extends'; $lastState = 'anonymous'; - break; + break; case '{': $state = 'closure'; if (! $inside_structure) { diff --git a/vendor/services.php b/vendor/services.php index 4426f92..f919862 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'taoser\\addons\\Service', diff --git a/vendor/symfony/var-exporter/Internal/Exporter.php b/vendor/symfony/var-exporter/Internal/Exporter.php index 6ee3ee7..b5ee88c 100644 --- a/vendor/symfony/var-exporter/Internal/Exporter.php +++ b/vendor/symfony/var-exporter/Internal/Exporter.php @@ -73,20 +73,29 @@ class Exporter $class = \get_class($value); $reflector = Registry::$reflectors[$class] ?? Registry::getClassReflector($class); + $properties = []; if ($reflector->hasMethod('__serialize')) { if (!$reflector->getMethod('__serialize')->isPublic()) { throw new \Error(sprintf('Call to %s method "%s::__serialize()".', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class)); } - if (!\is_array($properties = $value->__serialize())) { + if (!\is_array($serializeProperties = $value->__serialize())) { throw new \TypeError($class.'::__serialize() must return an array'); } + if ($reflector->hasMethod('__unserialize')) { + $properties = $serializeProperties; + } else { + foreach ($serializeProperties as $n => $v) { + $c = \PHP_VERSION_ID >= 80100 && $reflector->hasProperty($n) && ($p = $reflector->getProperty($n))->isReadOnly() ? $p->class : 'stdClass'; + $properties[$c][$n] = $v; + } + } + goto prepare_value; } - $properties = []; $sleep = null; $proto = Registry::$prototypes[$class]; diff --git a/vendor/topthink/framework/README.md b/vendor/topthink/framework/README.md index dd38e34..8781de0 100644 --- a/vendor/topthink/framework/README.md +++ b/vendor/topthink/framework/README.md @@ -77,7 +77,7 @@ ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 本项目包含的第三方源码和二进制文件之版权信息另行标注。 -版权所有Copyright © 2006-2021 by ThinkPHP (http://thinkphp.cn) All rights reserved。 +版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) All rights reserved。 ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 diff --git a/vendor/topthink/framework/src/think/App.php b/vendor/topthink/framework/src/think/App.php index 5aa4a87..597cf87 100644 --- a/vendor/topthink/framework/src/think/App.php +++ b/vendor/topthink/framework/src/think/App.php @@ -38,7 +38,7 @@ use think\initializer\RegisterService; */ class App extends Container { - const VERSION = '6.1.3'; + const VERSION = '6.1.4'; /** * 应用调试模式 diff --git a/vendor/topthink/framework/src/think/Filesystem.php b/vendor/topthink/framework/src/think/Filesystem.php deleted file mode 100644 index 0aee929..0000000 --- a/vendor/topthink/framework/src/think/Filesystem.php +++ /dev/null @@ -1,89 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think; - -use InvalidArgumentException; -use think\filesystem\Driver; -use think\filesystem\driver\Local; -use think\helper\Arr; - -/** - * Class Filesystem - * @package think - * @mixin Driver - * @mixin Local - */ -class Filesystem extends Manager -{ - protected $namespace = '\\think\\filesystem\\driver\\'; - - /** - * @param null|string $name - * @return Driver - */ - public function disk(string $name = null): Driver - { - return $this->driver($name); - } - - protected function resolveType(string $name) - { - return $this->getDiskConfig($name, 'type', 'local'); - } - - protected function resolveConfig(string $name) - { - return $this->getDiskConfig($name); - } - - /** - * 获取缓存配置 - * @access public - * @param null|string $name 名称 - * @param mixed $default 默认值 - * @return mixed - */ - public function getConfig(string $name = null, $default = null) - { - if (!is_null($name)) { - return $this->app->config->get('filesystem.' . $name, $default); - } - - return $this->app->config->get('filesystem'); - } - - /** - * 获取磁盘配置 - * @param string $disk - * @param null $name - * @param null $default - * @return array - */ - public function getDiskConfig($disk, $name = null, $default = null) - { - if ($config = $this->getConfig("disks.{$disk}")) { - return Arr::get($config, $name, $default); - } - - throw new InvalidArgumentException("Disk [$disk] not found."); - } - - /** - * 默认驱动 - * @return string|null - */ - public function getDefaultDriver() - { - return $this->getConfig('default'); - } -} diff --git a/vendor/topthink/framework/src/think/cache/driver/File.php b/vendor/topthink/framework/src/think/cache/driver/File.php index b36b069..70a4757 100644 --- a/vendor/topthink/framework/src/think/cache/driver/File.php +++ b/vendor/topthink/framework/src/think/cache/driver/File.php @@ -176,7 +176,8 @@ class File extends Driver } $data = "\n" . $data; - $result = file_put_contents($filename, $data); + + $result = file_put_contents($filename, $data, LOCK_EX); if ($result) { clearstatcache(); diff --git a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php index 6ce3e64..424daaf 100644 --- a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php +++ b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php @@ -67,7 +67,12 @@ class Schema extends Command if (0 === strpos($file, '.')) { continue; } + $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); + if (!class_exists($class)) { + continue; + } + $this->buildModelSchema($class); } } diff --git a/vendor/topthink/framework/src/think/facade/Filesystem.php b/vendor/topthink/framework/src/think/facade/Filesystem.php deleted file mode 100644 index 53706a8..0000000 --- a/vendor/topthink/framework/src/think/facade/Filesystem.php +++ /dev/null @@ -1,33 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\facade; - -use think\Facade; -use think\filesystem\Driver; - -/** - * Class Filesystem - * @package think\facade - * @mixin \think\Filesystem - * @method static Driver disk(string $name = null) ,null|string - * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取缓存配置 - * @method static array getDiskConfig(string $disk, null $name = null, null $default = null) 获取磁盘配置 - * @method static string|null getDefaultDriver() 默认驱动 - */ -class Filesystem extends Facade -{ - protected static function getFacadeClass() - { - return 'filesystem'; - } -} diff --git a/vendor/topthink/framework/src/think/filesystem/CacheStore.php b/vendor/topthink/framework/src/think/filesystem/CacheStore.php deleted file mode 100644 index 0a62399..0000000 --- a/vendor/topthink/framework/src/think/filesystem/CacheStore.php +++ /dev/null @@ -1,54 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem; - -use League\Flysystem\Cached\Storage\AbstractCache; -use Psr\SimpleCache\CacheInterface; - -class CacheStore extends AbstractCache -{ - protected $store; - - protected $key; - - protected $expire; - - public function __construct(CacheInterface $store, $key = 'flysystem', $expire = null) - { - $this->key = $key; - $this->store = $store; - $this->expire = $expire; - } - - /** - * Store the cache. - */ - public function save() - { - $contents = $this->getForStorage(); - - $this->store->set($this->key, $contents, $this->expire); - } - - /** - * Load the cache. - */ - public function load() - { - $contents = $this->store->get($this->key); - - if (!is_null($contents)) { - $this->setFromStorage($contents); - } - } -} diff --git a/vendor/topthink/framework/src/think/filesystem/Driver.php b/vendor/topthink/framework/src/think/filesystem/Driver.php deleted file mode 100644 index 0e61cf4..0000000 --- a/vendor/topthink/framework/src/think/filesystem/Driver.php +++ /dev/null @@ -1,144 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem; - -use League\Flysystem\AdapterInterface; -use League\Flysystem\Adapter\AbstractAdapter; -use League\Flysystem\Cached\CachedAdapter; -use League\Flysystem\Cached\Storage\Memory as MemoryStore; -use League\Flysystem\Filesystem; -use RuntimeException; -use think\Cache; -use think\File; - -/** - * Class Driver - * @package think\filesystem - * @mixin Filesystem - */ -abstract class Driver -{ - - /** @var Cache */ - protected $cache; - - /** @var Filesystem */ - protected $filesystem; - - /** - * 配置参数 - * @var array - */ - protected $config = []; - - public function __construct(Cache $cache, array $config) - { - $this->cache = $cache; - $this->config = array_merge($this->config, $config); - - $adapter = $this->createAdapter(); - $this->filesystem = $this->createFilesystem($adapter); - } - - protected function createCacheStore($config) - { - if (true === $config) { - return new MemoryStore; - } - - return new CacheStore( - $this->cache->store($config['store']), - $config['prefix'] ?? 'flysystem', - $config['expire'] ?? null - ); - } - - abstract protected function createAdapter(): AdapterInterface; - - protected function createFilesystem(AdapterInterface $adapter): Filesystem - { - if (!empty($this->config['cache'])) { - $adapter = new CachedAdapter($adapter, $this->createCacheStore($this->config['cache'])); - } - - $config = array_intersect_key($this->config, array_flip(['visibility', 'disable_asserts', 'url'])); - - return new Filesystem($adapter, count($config) > 0 ? $config : null); - } - - /** - * 获取文件完整路径 - * @param string $path - * @return string - */ - public function path(string $path): string - { - $adapter = $this->filesystem->getAdapter(); - - if ($adapter instanceof AbstractAdapter) { - return $adapter->applyPathPrefix($path); - } - - return $path; - } - - protected function concatPathToUrl($url, $path) - { - return rtrim($url, '/') . '/' . ltrim($path, '/'); - } - - public function url(string $path): string - { - throw new RuntimeException('This driver does not support retrieving URLs.'); - } - - /** - * 保存文件 - * @param string $path 路径 - * @param File $file 文件 - * @param null|string|\Closure $rule 文件名规则 - * @param array $options 参数 - * @return bool|string - */ - public function putFile(string $path, File $file, $rule = null, array $options = []) - { - return $this->putFileAs($path, $file, $file->hashName($rule), $options); - } - - /** - * 指定文件名保存文件 - * @param string $path 路径 - * @param File $file 文件 - * @param string $name 文件名 - * @param array $options 参数 - * @return bool|string - */ - public function putFileAs(string $path, File $file, string $name, array $options = []) - { - $stream = fopen($file->getRealPath(), 'r'); - $path = trim($path . '/' . $name, '/'); - - $result = $this->putStream($path, $stream, $options); - - if (is_resource($stream)) { - fclose($stream); - } - - return $result ? $path : false; - } - - public function __call($method, $parameters) - { - return $this->filesystem->$method(...$parameters); - } -} diff --git a/vendor/topthink/framework/src/think/filesystem/driver/Local.php b/vendor/topthink/framework/src/think/filesystem/driver/Local.php deleted file mode 100644 index 5749335..0000000 --- a/vendor/topthink/framework/src/think/filesystem/driver/Local.php +++ /dev/null @@ -1,59 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem\driver; - -use League\Flysystem\AdapterInterface; -use League\Flysystem\Adapter\Local as LocalAdapter; -use think\filesystem\Driver; - -class Local extends Driver -{ - /** - * 配置参数 - * @var array - */ - protected $config = [ - 'root' => '', - ]; - - protected function createAdapter(): AdapterInterface - { - $permissions = $this->config['permissions'] ?? []; - - $links = ($this->config['links'] ?? null) === 'skip' - ? LocalAdapter::SKIP_LINKS - : LocalAdapter::DISALLOW_LINKS; - - return new LocalAdapter( - $this->config['root'], - LOCK_EX, - $links, - $permissions - ); - } - - /** - * 获取文件访问地址 - * @param string $path 文件路径 - * @return string - */ - public function url(string $path): string - { - $path = str_replace('\\', '/', $path); - - if (isset($this->config['url'])) { - return $this->concatPathToUrl($this->config['url'], $path); - } - return parent::url($path); - } -} diff --git a/vendor/topthink/framework/src/think/initializer/Error.php b/vendor/topthink/framework/src/think/initializer/Error.php index 201d947..5018b1e 100644 --- a/vendor/topthink/framework/src/think/initializer/Error.php +++ b/vendor/topthink/framework/src/think/initializer/Error.php @@ -55,7 +55,9 @@ class Error if ($this->app->runningInConsole()) { $handler->renderForConsole(new ConsoleOutput, $e); } else { - $handler->render($this->app->request, $e)->send(); + $response = $handler->render($this->app->request, $e); + $response->send(); + $this->app->http->end($response); } } diff --git a/vendor/topthink/framework/src/think/route/RuleGroup.php b/vendor/topthink/framework/src/think/route/RuleGroup.php index f689dba..f8fbc1e 100644 --- a/vendor/topthink/framework/src/think/route/RuleGroup.php +++ b/vendor/topthink/framework/src/think/route/RuleGroup.php @@ -267,8 +267,7 @@ class RuleGroup extends Rule $regex = []; $items = []; - foreach ($rules as $key => $val) { - $item = $val[1]; + foreach ($rules as $key => $item) { if ($item instanceof RuleItem) { $rule = $depr . str_replace('/', $depr, $item->getRule()); if ($depr == $rule && $depr != $url) { diff --git a/vendor/topthink/framework/tests/FilesystemTest.php b/vendor/topthink/framework/tests/FilesystemTest.php deleted file mode 100644 index df5ffe2..0000000 --- a/vendor/topthink/framework/tests/FilesystemTest.php +++ /dev/null @@ -1,131 +0,0 @@ -app = m::mock(App::class)->makePartial(); - Container::setInstance($this->app); - $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); - $this->config = m::mock(Config::class); - $this->config->shouldReceive('get')->with('filesystem.default', null)->andReturn('local'); - $this->app->shouldReceive('get')->with('config')->andReturn($this->config); - $this->filesystem = new Filesystem($this->app); - - $this->root = vfsStream::setup('rootDir'); - } - - protected function tearDown(): void - { - m::close(); - } - - public function testDisk() - { - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - ]); - - $this->config->shouldReceive('get')->with('filesystem.disks.foo', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - ]); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk()); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk('foo')); - } - - public function testCache() - { - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - 'cache' => true, - ]); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk()); - - $this->config->shouldReceive('get')->with('filesystem.disks.cache', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $this->root->url(), - 'cache' => [ - 'store' => 'flysystem', - ], - ]); - - $cache = m::mock(Cache::class); - - $cacheDriver = m::mock(File::class); - - $cache->shouldReceive('store')->once()->with('flysystem')->andReturn($cacheDriver); - - $this->app->shouldReceive('make')->with(Cache::class)->andReturn($cache); - - $cacheDriver->shouldReceive('get')->with('flysystem')->once()->andReturn(null); - - $cacheDriver->shouldReceive('set')->withAnyArgs(); - - $this->filesystem->disk('cache')->put('test.txt', 'aa'); - } - - public function testPutFile() - { - $root = vfsStream::setup('rootDir', null, [ - 'foo.jpg' => 'hello', - ]); - - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $root->url(), - 'cache' => true, - ]); - - $file = m::mock(\think\File::class); - - $file->shouldReceive('hashName')->with(null)->once()->andReturn('foo.jpg'); - - $file->shouldReceive('getRealPath')->once()->andReturn($root->getChild('foo.jpg')->url()); - - $this->filesystem->putFile('test', $file); - } -} - -class NullDriver extends Driver -{ - protected function createAdapter(): AdapterInterface - { - return new NullAdapter(); - } -} diff --git a/vendor/topthink/think-migration/composer.json b/vendor/topthink/think-migration/composer.json index 78af31f..39980f7 100644 --- a/vendor/topthink/think-migration/composer.json +++ b/vendor/topthink/think-migration/composer.json @@ -21,7 +21,7 @@ } }, "require": { - "topthink/framework": "^6.0", + "topthink/framework": "^6.0 || ^8.0", "topthink/think-helper": "^3.0.3" }, "minimum-stability": "dev", diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterFactory.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterFactory.php index 90674f9..bf15880 100644 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterFactory.php +++ b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterFactory.php @@ -65,6 +65,7 @@ class AdapterFactory 'pgsql' => 'Phinx\Db\Adapter\PostgresAdapter', 'sqlite' => 'Phinx\Db\Adapter\SQLiteAdapter', 'sqlsrv' => 'Phinx\Db\Adapter\SqlServerAdapter', + 'dm' => 'Phinx\Db\Adapter\DmAdapter', ); /** diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/DmAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/DmAdapter.php new file mode 100644 index 0000000..5d8a8fc --- /dev/null +++ b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/DmAdapter.php @@ -0,0 +1,1134 @@ +quoteSchemaName($this->schemaTableName); + } + + /** + * {@inheritdoc} + */ + public function getVersionLog() + { + $result = array(); + $rows = $this->fetchAll(sprintf('SELECT * FROM %s ORDER BY "version" ASC', $this->getSchemaTableName())); + foreach ($rows as $version) { + $result[$version['version']] = $version; + } + + return $result; + } + + /** + * {@inheritdoc} + */ + public function createSchemaTable() + { + try { + $options = array( + 'id' => false, + 'primary_key' => 'version' + ); + + $table = new Table($this->schemaTableName, $options, $this); + + if ($this->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'mysql' + && version_compare($this->getConnection()->getAttribute(\PDO::ATTR_SERVER_VERSION), '5.6.0', '>=')) { + $table->addColumn('version', 'biginteger', array('limit' => 14)) + ->addColumn('migration_name', 'string', array('limit' => 100, 'default' => null, 'null' => true)) + ->addColumn('start_time', 'timestamp', array('default' => 'CURRENT_TIMESTAMP')) + ->addColumn('end_time', 'timestamp', array('default' => 'CURRENT_TIMESTAMP')) + ->addColumn('breakpoint', 'boolean', array('default' => false)) + ->save(); + } else { + $table->addColumn('version', 'biginteger') + ->addColumn('migration_name', 'string', array('limit' => 100, 'default' => null, 'null' => true)) + ->addColumn('start_time', 'timestamp') + ->addColumn('end_time', 'timestamp') + ->addColumn('breakpoint', 'boolean', array('default' => false)) + ->save(); + } + } catch (\Exception $exception) { + throw new \InvalidArgumentException('There was a problem creating the schema table: ' . $exception->getMessage()); + } + } + + /** + * {@inheritdoc} + */ + public function connect() + { + if (null === $this->connection) { + if (!class_exists('PDO') || !in_array('dm', \PDO::getAvailableDrivers(), true)) { + // @codeCoverageIgnoreStart + throw new \RuntimeException('You need to enable the PDO_DM extension for Phinx to run properly.'); + // @codeCoverageIgnoreEnd + } + + $db = null; + $options = $this->getOptions(); + + if (isset($options['port'])) { + $dsn = 'dm:host=' . $options['host'] . ';port=' . $options['port'] . ';dbname=' . $options['name']; + } else { + $dsn = 'dm:host=' . $options['host'] . ';dbname=' . $options['name']; + } + + try { + $db = new \PDO($dsn, $options['user'], $options['pass'], array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION)); + $this->connection = $db; + + if (!$this->hasDatabase($options['name'])) { + $this->createDatabase($options['name']); + } + $db->query("SET SCHEMA " . $options['name']); + + $this->setConnection($db); + } catch (\PDOException $exception) { + throw new \InvalidArgumentException(sprintf( + 'There was a problem connecting to the database: %s', + $exception->getMessage() + )); + } + } + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + $this->connection = null; + } + + /** + * {@inheritdoc} + */ + public function hasTransactions() + { + return true; + } + + /** + * {@inheritdoc} + */ + public function beginTransaction() + { + $this->execute('START TRANSACTION'); + } + + /** + * {@inheritdoc} + */ + public function commitTransaction() + { + $this->execute('COMMIT'); + } + + /** + * {@inheritdoc} + */ + public function rollbackTransaction() + { + $this->execute('ROLLBACK'); + } + + /** + * Quotes a schema name for use in a query. + * + * @param string $schemaName Schema Name + * @return string + */ + public function quoteSchemaName($schemaName) + { + return $this->quoteColumnName($schemaName); + } + + /** + * {@inheritdoc} + */ + public function quoteTableName($tableName) + { + return $this->quoteColumnName($tableName); + } + + /** + * {@inheritdoc} + */ + public function quoteColumnName($columnName) + { + return '"' . $columnName . '"'; + } + + /** + * {@inheritdoc} + */ + public function hasTable($tableName) + { + $options = $this->getOptions(); + + $sprintf = sprintf( + "SELECT COUNT(*) FROM all_tables WHERE OWNER='%s' AND TABLE_NAME = '%s'", + $options['name'], + trim($tableName, '"'), + ); + $result = $this->getConnection()->query($sprintf); + + $column = $result->fetchColumn(); + return $column > 0; + } + + /** + * {@inheritdoc} + */ + public function createTable(Table $table) + { + $this->startCommandTimer(); + try { + $this->writeCommand('createTable', array($table->getName())); + + // This method is based on the MySQL docs here: http://dev.mysql.com/doc/refman/5.1/en/create-index.html + $defaultOptions = array( + 'engine' => 'InnoDB', + 'collation' => 'utf8_general_ci' + ); + $options = array_merge($defaultOptions, $table->getOptions()); + + // Add the default primary key + $columns = $table->getPendingColumns(); + + if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) { + $options['id'] = 'id'; + } + + if (isset($options['id']) && is_string($options['id'])) { + // Handle id => "field_name" to support AUTO_INCREMENT + $column = new Column(); + $column->setName($options['id']) + ->setType('integer') + ->setSigned(isset($options['signed']) ? $options['signed'] : true) + ->setIdentity(true); + + array_unshift($columns, $column); + $options['primary_key'] = $options['id']; + } + + $optionsStr = ''; + + $sql = 'CREATE TABLE '; + $sql .= $this->quoteTableName($table->getName()) . ' ('; + foreach ($columns as $column) { + $sql .= sprintf( + "%s %s ,", + $this->quoteColumnName($column->getName()), + $this->getColumnSqlDefinition($column) + ); + } + + // set the primary key(s) + if (isset($options['primary_key'])) { + $sql = rtrim($sql); + $sql .= ' PRIMARY KEY ('; + if (is_string($options['primary_key'])) { // handle primary_key => 'id' + $sql .= $this->quoteColumnName($options['primary_key']); + } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id') + // PHP 5.4 will allow access of $this, so we can call quoteColumnName() directly in the + // anonymous function, but for now just hard-code the adapter quotes + $sql .= implode( + ',', + array_map( + function ($v) { + return '`' . $v . '`'; + }, + $options['primary_key'] + ) + ); + } + $sql .= ')'; + } else { + $sql = substr(rtrim($sql), 0, -1); // no primary keys + } + $sql .= ') ' . $optionsStr; + $this->execute($sql); + + // set the table comment + if (isset($options['comment'])) { + //todo +// $this->getConnection()->exec($sql); + } + + // set the indexes + $indexes = $table->getIndexes(); + if (!empty($indexes)) { + foreach ($indexes as $index) { + $sql = $this->getIndexSqlDefinition($index, $table->getName()); + $this->execute($sql); + } + } + + // set the foreign keys + $foreignKeys = $table->getForeignKeys(); + if (!empty($foreignKeys)) { + foreach ($foreignKeys as $foreignKey) { + $sql = $this->getForeignKeySqlDefinition($foreignKey); + $this->execute($sql); + } + } + } catch (\Exception $e) { + $string = $e->getMessage(); + $iconv = iconv("GBK", 'UTF-8', $string); + print_r($iconv); + throw new \RuntimeException($string . " \n sql: \n" . $sql); + } + + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function renameTable($tableName, $newTableName) + { + $this->startCommandTimer(); + $this->writeCommand('renameTable', array($tableName, $newTableName)); + $sql = sprintf( + 'ALTER TABLE %s RENAME TO %s', + $this->quoteTableName($tableName), + $this->quoteTableName($newTableName), + ); + $this->execute($sql); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function dropTable($tableName) + { + $this->startCommandTimer(); + $this->writeCommand('dropTable', array($tableName)); + $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tableName))); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function getColumns($tableName) + { + $columns = array(); + $sql = sprintf("SELECT column_name,data_type,nullable,data_default,data_precision,data_scale FROM USER_TAB_COLUMNS WHERE TABLE_NAME='%s'", $tableName); + $columnsInfo = $this->fetchAll($sql); + + foreach ($columnsInfo as $columnInfo) { + $column = new Column(); + $column->setName($columnInfo['column_name']) + ->setType($this->getPhinxType($columnInfo['data_type'])) + ->setNull($columnInfo['nullable'] === 'Y') + ->setDefault($columnInfo['data_default']) + // 达梦没有直接判断是否自增字段,通过 字段带有id,且不能为null 判断 + ->setIdentity(($columnInfo['nullable'] !== 'Y' && strpos(strtolower($columnInfo['column_name']), "id") !== false) === 'YES') + ->setLimit($columnInfo['data_length']) + ->setPrecision($columnInfo['data_precision']) + ->setScale($columnInfo['data_scale']); + + if (preg_match('/\bwith time zone$/', $columnInfo['data_type'])) { + $column->setTimezone(true); + } + + $columns[] = $column; + } + return $columns; + } + + /** + * {@inheritdoc} + */ + public function hasColumn($tableName, $columnName, $options = array()) + { + $sql = sprintf( + "SELECT count(*) as count FROM USER_TAB_COLUMNS WHERE TABLE_NAME='%s' AND COLUMN_NAME='%s'", + trim($tableName, '"'), + $columnName + ); + + $result = $this->fetchRow($sql); + return $result['COUNT'] > 0; + } + + /** + * {@inheritdoc} + */ + public function addColumn(Table $table, Column $column) + { + $this->startCommandTimer(); + $this->writeCommand('addColumn', array($table->getName(), $column->getName(), $column->getType())); + $sql = sprintf( + 'ALTER TABLE %s ADD %s %s', + $this->quoteTableName($table->getName()), + $this->quoteColumnName($column->getName()), + $this->getColumnSqlDefinition($column) + ); + + $this->execute($sql); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function renameColumn($tableName, $columnName, $newColumnName) + { + $this->startCommandTimer(); + $result = $this->fetchRow($sql); + if (!$this->hasColumn($tableName, $columnName)) { + throw new \InvalidArgumentException("The specified column does not exist: $columnName"); + } + $this->writeCommand('renameColumn', array($tableName, $columnName, $newColumnName)); + $this->execute( + sprintf( + 'ALTER TABLE %s RENAME COLUMN %s TO %s', + $this->quoteTableName($tableName), + $this->quoteColumnName($columnName), + $this->quoteColumnName($newColumnName), + ) + ); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function changeColumn($tableName, $columnName, Column $newColumn) + { + $this->startCommandTimer(); + $this->writeCommand('changeColumn', array($tableName, $columnName, $newColumn->getType())); + // todo after 没生效 +// $after = $newColumn->getAfter() ? ' AFTER ' . $this->quoteColumnName($newColumn->getAfter()) : ''; + + // sql + // ALTER TABLE student MODIFY age varchar(10) ; + $sql = sprintf( + 'ALTER TABLE %s MODIFY %s %s;', + $this->quoteTableName($tableName), + $this->quoteColumnName($columnName), + $this->getColumnSqlDefinition($newColumn), + ); + $this->execute($sql); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function dropColumn($tableName, $columnName) + { + $this->startCommandTimer(); + $this->writeCommand('dropColumn', array($tableName, $columnName)); + $this->execute( + sprintf( + 'ALTER TABLE %s DROP COLUMN %s', + $this->quoteTableName($tableName), + $this->quoteColumnName($columnName), + ) + ); + $this->endCommandTimer(); + } + + /** + * Get an array of indexes from a particular table. + * + * @param string $tableName Table Name + * @return array + */ + protected function getIndexes($tableName) + { + $indexes = array(); + $sql = sprintf("SELECT COLUMN_NAME ,INDEX_NAME from DBA_IND_COLUMNS WHERE TABLE_NAME='%s'", trim($tableName, '"')); + $rows = $this->fetchAll($sql); + $rows = array_map(function ($item) { + return array_change_key_case($item); + }, $rows); + + foreach ($rows as $row) { + if (!isset($indexes[$row['index_name']])) { + $indexes[$row['index_name']] = array('columns' => array()); + } + $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); + } + return $indexes; + } + + /** + * {@inheritdoc} + */ + public function hasIndex($tableName, $columns) + { + if (is_string($columns)) { + $columns = array($columns); + } + $columns = array_map('strtolower', $columns); + $indexes = $this->getIndexes($tableName); + foreach ($indexes as $index) { + if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) { + return true; + } + } + return false; + } + + /** + * {@inheritdoc} + */ + public function hasIndexByName($tableName, $indexName) + { + $indexes = $this->getIndexes($tableName); + foreach ($indexes as $name => $index) { + if ($name === $indexName) { + return true; + } + } + return false; + } + + /** + * {@inheritdoc} + */ + public function addIndex(Table $table, Index $index) + { + $this->startCommandTimer(); + $this->writeCommand('addIndex', array($table->getName(), $index->getColumns())); + $sql = $this->getIndexSqlDefinition($index, $table->getName()); + $this->execute($sql); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function dropIndex($tableName, $columns) + { + $this->startCommandTimer(); + if (is_string($columns)) { + $columns = array($columns); // str to array + } + + $this->writeCommand('dropIndex', array($tableName, $columns)); + $indexes = $this->getIndexes($tableName); + $columns = array_map('strtolower', $columns); + + foreach ($indexes as $indexName => $index) { + $a = array_diff($columns, $index['columns']); + if (empty($a)) { + $sql = sprintf( + 'DROP INDEX IF EXISTS %s', + $indexName + ); + $this->execute( + $sql + ); + $this->endCommandTimer(); + return; + } + } + } + + /** + * {@inheritdoc} + */ + public function dropIndexByName($tableName, $indexName) + { + $this->startCommandTimer(); + $this->writeCommand('dropIndexByName', array($tableName, $indexName)); + $sql = sprintf( + 'DROP INDEX IF EXISTS %s', + $indexName + ); + $this->execute($sql); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function hasForeignKey($tableName, $columns, $constraint = null) + { + if (is_string($columns)) { + $columns = array($columns); // str to array + } + $foreignKeys = $this->getForeignKeys($tableName); + if ($constraint) { + if (isset($foreignKeys[$constraint])) { + return !empty($foreignKeys[$constraint]); + } + return false; + } else { + foreach ($foreignKeys as $key) { + $a = array_diff($columns, $key['columns']); + if (empty($a)) { + return true; + } + } + return false; + } + } + + /** + * Get an array of foreign keys from a particular table. + * + * @param string $tableName Table Name + * @return array + */ + protected function getForeignKeys($tableName) + { + $foreignKeys = array(); + $rows = $this->fetchAll(sprintf( + "SELECT + a.constraint_name, + a.table_name as table_name, + b.table_name as referenced_table_name, + a.column_name as column_name, + b.column_name as referenced_column_name +FROM + user_cons_columns a +JOIN + user_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name +JOIN + user_cons_columns b ON c.r_owner = b.owner AND c.r_constraint_name = b.constraint_name +WHERE + c.constraint_type = 'R' AND a.table_name = '%s'; +", + $tableName + )); + foreach ($rows as $row) { + $foreignKeys[$row['constraint_name']]['table'] = $row['table_name']; + $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name']; + $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name']; + $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name']; + } + return $foreignKeys; + } + + /** + * {@inheritdoc} + */ + public function addForeignKey(Table $table, ForeignKey $foreignKey) + { + $this->startCommandTimer(); + $this->writeCommand('addForeignKey', array($table->getName(), $foreignKey->getColumns())); + $sql = sprintf( + 'ALTER TABLE %s ADD %s', + $table->getName(), + $this->getForeignKeySqlDefinition($foreignKey, $table->getName()) + ); + $this->execute($sql); + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function dropForeignKey($tableName, $columns, $constraint = null) + { + $this->startCommandTimer(); + if (is_string($columns)) { + $columns = array($columns); // str to array + } + $this->writeCommand('dropForeignKey', array($tableName, $columns)); + + if ($constraint) { + $this->execute( + sprintf( + 'ALTER TABLE %s DROP CONSTRAINT %s', + $this->quoteTableName($tableName), + $constraint + ) + ); + } else { + foreach ($columns as $column) { + $rows = $this->fetchAll(sprintf( + "SELECT + a.constraint_name, +FROM + user_cons_columns a +JOIN + user_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name +JOIN + user_cons_columns b ON c.r_owner = b.owner AND c.r_constraint_name = b.constraint_name +WHERE + c.constraint_type = 'R' AND a.table_name = '%s' AND column_name='%s'; +", + $tableName, + $column, + )); + + foreach ($rows as $row) { + $this->dropForeignKey($tableName, $columns, $row['constraint_name']); + } + } + } + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function getSqlType($type, $limit = null) + { + switch ($type) { + case static::PHINX_TYPE_STRING: + return array('name' => 'varchar', 'limit' => $limit ? $limit : 255); + break; + case static::PHINX_TYPE_CHAR: + return array('name' => 'char', 'limit' => $limit ? $limit : 255); + break; + case static::PHINX_TYPE_TEXT: + if ($limit) { + $sizes = array( + // Order matters! Size must always be tested from longest to shortest! + 'longtext' => static::TEXT_LONG, + 'mediumtext' => static::TEXT_MEDIUM, + 'text' => static::TEXT_REGULAR, + 'tinytext' => static::TEXT_SMALL, + ); + foreach ($sizes as $name => $length) { + if ($limit >= $length) { + return array('name' => $name); + } + } + } + return array('name' => 'text'); + break; + case static::PHINX_TYPE_BINARY: + return array('name' => 'binary', 'limit' => $limit ? $limit : 255); + break; + case static::PHINX_TYPE_VARBINARY: + return array('name' => 'varbinary', 'limit' => $limit ? $limit : 255); + break; + case static::PHINX_TYPE_BLOB: + if ($limit) { + $sizes = array( + // Order matters! Size must always be tested from longest to shortest! + 'longblob' => static::BLOB_LONG, + 'mediumblob' => static::BLOB_MEDIUM, + 'blob' => static::BLOB_REGULAR, + 'tinyblob' => static::BLOB_SMALL, + ); + foreach ($sizes as $name => $length) { + if ($limit >= $length) { + return array('name' => $name); + } + } + } + return array('name' => 'blob'); + break; + case static::PHINX_TYPE_INTEGER: + if ($limit && $limit >= static::INT_TINY) { + $sizes = array( + // Order matters! Size must always be tested from longest to shortest! + 'bigint' => static::INT_BIG, + 'int' => static::INT_REGULAR, + ); + $limits = array( + 'int' => 11, + 'bigint' => 20, + ); + foreach ($sizes as $name => $length) { + if ($limit >= $length) { + $def = array('name' => $name); + if (isset($limits[$name])) { + $def['limit'] = $limits[$name]; + } + return $def; + } + } + } elseif (!$limit) { + $limit = 11; + } + return array('name' => 'int', 'limit' => $limit); + break; + case static::PHINX_TYPE_BIG_INTEGER: + return array('name' => 'bigint', 'limit' => 20); + break; + case static::PHINX_TYPE_FLOAT: + return array('name' => 'float'); + break; + case static::PHINX_TYPE_DECIMAL: + return array('name' => 'decimal'); + break; + case static::PHINX_TYPE_DATETIME: + return array('name' => 'datetime'); + break; + case static::PHINX_TYPE_TIMESTAMP: + return array('name' => 'timestamp'); + break; + case static::PHINX_TYPE_TIME: + return array('name' => 'time'); + break; + case static::PHINX_TYPE_DATE: + return array('name' => 'date'); + break; + case static::PHINX_TYPE_BOOLEAN: + return array('name' => 'int', 'limit' => 1); + break; + case static::PHINX_TYPE_UUID: + return array('name' => 'char', 'limit' => 36); + // Geospatial database types + case static::PHINX_TYPE_GEOMETRY: + case static::PHINX_TYPE_POINT: + case static::PHINX_TYPE_LINESTRING: + case static::PHINX_TYPE_POLYGON: + return array('name' => $type); + case static::PHINX_TYPE_ENUM: + return array('name' => 'enum'); + break; + case static::PHINX_TYPE_SET: + return array('name' => 'set'); + break; + case static::TYPE_YEAR: + if (!$limit || in_array($limit, array(2, 4))) { + $limit = 4; + } + return array('name' => 'year', 'limit' => $limit); + break; + case static::PHINX_TYPE_JSON: + return array('name' => 'json'); + break; + default: + throw new \RuntimeException('The type: "' . $type . '" is not supported.'); + } + } + + /** + * Returns Phinx type by SQL type + * + * @param string $sqlType SQL type + * @returns string Phinx type + */ + public function getPhinxType($sqlType) + { + switch ($sqlType) { + case 'character varying': + case 'varchar': + return static::PHINX_TYPE_STRING; + case 'character': + case 'char': + return static::PHINX_TYPE_CHAR; + case 'text': + return static::PHINX_TYPE_TEXT; + case 'json': + return static::PHINX_TYPE_JSON; + case 'jsonb': + return static::PHINX_TYPE_JSONB; + case 'smallint': + return array( + 'name' => 'smallint', + 'limit' => static::INT_SMALL + ); + case 'int': + case 'int4': + case 'integer': + return static::PHINX_TYPE_INTEGER; + case 'decimal': + case 'numeric': + return static::PHINX_TYPE_DECIMAL; + case 'bigint': + case 'int8': + return static::PHINX_TYPE_BIG_INTEGER; + case 'real': + case 'float4': + return static::PHINX_TYPE_FLOAT; + case 'bytea': + return static::PHINX_TYPE_BINARY; + break; + case 'time': + case 'timetz': + case 'time with time zone': + case 'time without time zone': + return static::PHINX_TYPE_TIME; + case 'date': + return static::PHINX_TYPE_DATE; + case 'timestamp': + case 'timestamptz': + case 'timestamp with time zone': + case 'timestamp without time zone': + return static::PHINX_TYPE_DATETIME; + case 'bool': + case 'boolean': + return static::PHINX_TYPE_BOOLEAN; + case 'uuid': + return static::PHINX_TYPE_UUID; + default: + throw new \RuntimeException('The type: "' . $sqlType . '" is not supported'); + } + } + + /** + * {@inheritdoc} + */ + public function createDatabase($name, $options = array()) + { + $this->startCommandTimer(); + $this->writeCommand('createDatabase', array($name)); + $this->execute(sprintf("CREATE SCHEMA %s", $name)); + + $this->endCommandTimer(); + } + + /** + * {@inheritdoc} + */ + public function hasDatabase($databaseName) + { + $sql = sprintf("select COUNT(1) from sysobjects where NAME='%s' and SUBTYPE$ is null", $databaseName); + $result = $this->getConnection()->query($sql); + return $result->fetchColumn(0) > 0; + } + + /** + * {@inheritdoc} + */ + public function dropDatabase($name) + { + $this->startCommandTimer(); + $this->writeCommand('dropDatabase', array($name)); + $this->disconnect(); + $this->execute(sprintf('DROP DATABASE IF EXISTS %s', $name)); + $this->connect(); + $this->endCommandTimer(); + } + + /** + * Get the defintion for a `DEFAULT` statement. + * + * @param mixed $default + * @return string + */ + protected function getDefaultValueDefinition($default) + { + if (is_string($default) && 'CURRENT_TIMESTAMP' !== $default) { + $default = $this->getConnection()->quote($default); + } elseif (is_bool($default)) { + $default = $this->castToBool($default); + } + return isset($default) ? 'DEFAULT ' . $default : ''; + } + + /** + * Gets the Column Definition for a Column object. + * + * @param Column $column Column + * @return string + */ + protected function getColumnSqlDefinition(Column $column) + { + $buffer = array(); + if ($column->isIdentity()) { + $buffer[] = $column->getType() == 'biginteger' ? 'bigint IDENTITY' : 'int IDENTITY'; + } else { + $sqlType = $this->getSqlType($column->getType(), $column->getLimit()); + $buffer[] = strtoupper($sqlType['name']); + // integers cant have limits in postgres + if (static::PHINX_TYPE_DECIMAL === $sqlType['name'] && ($column->getPrecision() || $column->getScale())) { + $buffer[] = sprintf( + '(%s, %s)', + $column->getPrecision() ? $column->getPrecision() : $sqlType['precision'], + $column->getScale() ? $column->getScale() : $sqlType['scale'] + ); + } elseif ($column->getType() == static::PHINX_TYPE_STRING) { + $buffer[] = sprintf("(%s)", $sqlType['limit']); + } + } + + $buffer[] = $column->isNull() ? 'NULL' : 'NOT NULL'; + + if (!is_null($column->getDefault())) { + $buffer[] = $this->getDefaultValueDefinition($column->getDefault()); + } + + return implode(' ', $buffer); + } + + /** + * Gets the Index Definition for an Index object. + * + * @param Index $index Index + * @param string $tableName Table name + * @return string + */ + protected function getIndexSqlDefinition(Index $index, $tableName) + { + if (is_string($index->getName())) { + $indexName = $index->getName(); + } else { + $columnNames = $index->getColumns(); + if (is_string($columnNames)) { + $columnNames = array($columnNames); + } + $indexName = sprintf('%s_%s', $tableName, implode('_', $columnNames)); + } + + $fieldName = function ($cols) { + $tmp = []; + foreach ($cols as $col) { + $tmp[] = $this->quoteColumnName($col); + } + return implode(",", $tmp); + }; + $def = sprintf( + "CREATE %s INDEX %s ON %s (%s);", + ($index->getType() === Index::UNIQUE ? 'UNIQUE' : ''), + $indexName, + $this->quoteTableName($tableName), + $fieldName($index->getColumns()) + ); + return $def; + } + + /** + * Gets the MySQL Foreign Key Definition for an ForeignKey object. + * + * @param ForeignKey $foreignKey + * @param string $tableName Table name + * @return string + */ + protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) + { + $constraintName = $foreignKey->getConstraint() ?: $this->quoteTableName($tableName) . '_' . implode('_', $foreignKey->getColumns()); + $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; + $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; + if ($foreignKey->getOnDelete()) { + $def .= " ON DELETE {$foreignKey->getOnDelete()}"; + } + if ($foreignKey->getOnUpdate()) { + $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; + } + return $def; + } + + /** + * {@inheritdoc} + */ + public function getColumnTypes() + { + return array_merge(parent::getColumnTypes(), array('json', 'jsonb')); + } + + /** + * {@inheritdoc} + */ + public function isValidColumnType(Column $column) + { + // If not a standard column type, maybe it is array type? + return (parent::isValidColumnType($column) || $this->isArrayType($column->getType())); + } + + /** + * Check if the given column is an array of a valid type. + * + * @param string $columnType + * @return bool + */ + protected function isArrayType($columnType) + { + if (!preg_match('/^([a-z]+)(?:\[\]){1,}$/', $columnType, $matches)) { + return false; + } + + $baseType = $matches[1]; + return in_array($baseType, $this->getColumnTypes()); + } + + /** + * Gets the schema name. + * + * @return string + */ + private function getSchemaName() + { +// return ''; +// $options = $this->getOptions(); +// return empty($options['schema']) ? 'public' : $options['schema']; + } + + /** + * Cast a value to a boolean appropriate for the adapter. + * + * @param mixed $value The value to be cast + * + * @return mixed + */ + public function castToBool($value) + { + return (bool) $value ? 'TRUE' : 'FALSE'; + } +} diff --git a/vendor/workerman/workerman/Events/Ev.php b/vendor/workerman/workerman/Events/Ev.php index 82c9bdf..8e21bc3 100644 --- a/vendor/workerman/workerman/Events/Ev.php +++ b/vendor/workerman/workerman/Events/Ev.php @@ -174,9 +174,7 @@ class Ev implements EventInterface */ public function destroy() { - foreach ($this->_allEvents as $event) { - $event->stop(); - } + \Ev::stop(\Ev::BREAK_ALL); } /** diff --git a/vendor/workerman/workerman/Events/Uv.php b/vendor/workerman/workerman/Events/Uv.php index 6efe16b..49f0ddd 100644 --- a/vendor/workerman/workerman/Events/Uv.php +++ b/vendor/workerman/workerman/Events/Uv.php @@ -109,8 +109,8 @@ class Uv implements EventInterface $repeat = $flag === self::EV_TIMER_ONCE ? 0 : (int)($fd * 1000); $param = array($func, (array)$args, $flag, $fd, self::$_timerId); $timerWatcher = \uv_timer_init(); - \uv_timer_start($timerWatcher, 1, $repeat, function($watcher)use($param){ - call_user_func_array([$this, 'timerCallback'], [$param]); + \uv_timer_start($timerWatcher, ($flag === self::EV_TIMER_ONCE ? (int)($fd * 1000) :1), $repeat, function($watcher)use($param){ + call_user_func_array([$this, 'timerCallback'], [$param]); }); $this->_eventTimer[self::$_timerId] = $timerWatcher; return self::$_timerId++; diff --git a/vendor/workerman/workerman/Protocols/Http/Request.php b/vendor/workerman/workerman/Protocols/Http/Request.php index 4744d9e..d544ac0 100644 --- a/vendor/workerman/workerman/Protocols/Http/Request.php +++ b/vendor/workerman/workerman/Protocols/Http/Request.php @@ -46,7 +46,7 @@ class Request public $properties = array(); /** - * @var int + * @var int */ public static $maxFileUploads = 1024; @@ -71,6 +71,13 @@ class Request */ protected static $_enableCache = true; + /** + * Is safe. + * + * @var bool + */ + protected $_isSafe = true; + /** * Request constructor. @@ -208,8 +215,8 @@ class Request public function host($without_port = false) { $host = $this->header('host'); - if ($host && $without_port && $pos = \strpos($host, ':')) { - return \substr($host, 0, $pos); + if ($host && $without_port) { + return preg_replace('/:\d{1,5}$/', '', $host); } return $host; } @@ -656,6 +663,16 @@ class Request return $this->_buffer; } + /** + * __wakeup. + * + * @return void + */ + public function __wakeup() + { + $this->_isSafe = false; + } + /** * __destruct. * @@ -663,7 +680,7 @@ class Request */ public function __destruct() { - if (isset($this->_data['files'])) { + if (isset($this->_data['files']) && $this->_isSafe) { \clearstatcache(); \array_walk_recursive($this->_data['files'], function($value, $key){ if ($key === 'tmp_name') { diff --git a/vendor/workerman/workerman/Protocols/Http/Response.php b/vendor/workerman/workerman/Protocols/Http/Response.php index a71cefa..6e2fc69 100644 --- a/vendor/workerman/workerman/Protocols/Http/Response.php +++ b/vendor/workerman/workerman/Protocols/Http/Response.php @@ -427,7 +427,7 @@ class Response if (!isset($headers['Transfer-Encoding'])) { $head .= "Content-Length: $body_len\r\n\r\n"; } else { - return "$head\r\n".dechex($body_len)."\r\n{$this->_body}\r\n"; + return $body_len ? "$head\r\n" . dechex($body_len) . "\r\n{$this->_body}\r\n" : "$head\r\n"; } // The whole http package diff --git a/vendor/workerman/workerman/Protocols/Http/Session.php b/vendor/workerman/workerman/Protocols/Http/Session.php index 45735ce..a0c2417 100644 --- a/vendor/workerman/workerman/Protocols/Http/Session.php +++ b/vendor/workerman/workerman/Protocols/Http/Session.php @@ -134,6 +134,13 @@ class Session */ protected $_sessionId = null; + /** + * Is safe. + * + * @var bool + */ + protected $_isSafe = true; + /** * Session constructor. * @@ -402,6 +409,16 @@ class Session static::$_handler->gc(static::$lifetime); } + /** + * __wakeup. + * + * @return void + */ + public function __wakeup() + { + $this->_isSafe = false; + } + /** * __destruct. * @@ -409,6 +426,9 @@ class Session */ public function __destruct() { + if (!$this->_isSafe) { + return; + } $this->save(); if (\random_int(1, static::$gcProbability[1]) <= static::$gcProbability[0]) { $this->gc(); @@ -422,7 +442,7 @@ class Session */ protected static function checkSessionId($session_id) { - if (!\preg_match('/^[a-zA-Z0-9]+$/', $session_id)) { + if (!\preg_match('/^[a-zA-Z0-9"]+$/', $session_id)) { throw new SessionException("session_id $session_id is invalid"); } } diff --git a/vendor/workerman/workerman/Worker.php b/vendor/workerman/workerman/Worker.php index a0f926d..3fec884 100644 --- a/vendor/workerman/workerman/Worker.php +++ b/vendor/workerman/workerman/Worker.php @@ -34,7 +34,7 @@ class Worker * * @var string */ - const VERSION = '4.1.10'; + const VERSION = '4.1.13'; /** * Status starting. @@ -272,7 +272,7 @@ class Worker * @var string */ public static $statusFile = ''; - + /** * Log file. * @@ -663,7 +663,7 @@ class Worker if (static::$_OS !== \OS_TYPE_LINUX) { return; } - + static::$_statisticsFile = static::$statusFile ? static::$statusFile : __DIR__ . '/../workerman-' .posix_getpid().'.status'; foreach (static::$_workers as $worker) { @@ -782,10 +782,10 @@ class Worker return; } if (static::$_OS !== \OS_TYPE_LINUX) { - static::safeEcho("----------------------- WORKERMAN -----------------------------\r\n"); + static::safeEcho("---------------------------------------------- WORKERMAN -----------------------------------------------\r\n"); static::safeEcho('Workerman version:'. static::VERSION. ' PHP version:'. \PHP_VERSION. "\r\n"); - static::safeEcho("------------------------ WORKERS -------------------------------\r\n"); - static::safeEcho("worker listen processes status\r\n"); + static::safeEcho("----------------------------------------------- WORKERS ------------------------------------------------\r\n"); + static::safeEcho("worker listen processes status\r\n"); return; } @@ -1060,8 +1060,11 @@ class Worker } $status_str = ''; $current_total_request = array(); - $worker_info = \unserialize($info[0]); - \ksort($worker_info, SORT_NUMERIC); + $workerInfo = []; + try { + $workerInfo = unserialize($info[0], ['allowed_classes' => false]); + } catch (Throwable $exception) {} + \ksort($workerInfo, SORT_NUMERIC); unset($info[0]); $data_waiting_sort = array(); $read_process_status = false; @@ -1096,7 +1099,7 @@ class Worker } } } - foreach($worker_info as $pid => $info) { + foreach($workerInfo as $pid => $info) { if (!isset($data_waiting_sort[$pid])) { $status_str .= "$pid\t" . \str_pad('N/A', 7) . " " . \str_pad($info['listen'], static::$_maxSocketNameLength) . " " @@ -1472,8 +1475,11 @@ class Worker \restore_error_handler(); + // Add an empty timer to prevent the event-loop from exiting. + Timer::add(1000000, function (){}); + // Display UI. - static::safeEcho(\str_pad($worker->name, 21) . \str_pad($worker->getSocketName(), 36) . \str_pad('1', 10) . "[ok]\n"); + static::safeEcho(\str_pad($worker->name, 48) . \str_pad($worker->getSocketName(), 36) . \str_pad('1', 10) . " [ok]\n"); $worker->listen(); $worker->run(); static::$globalEvent->loop();