Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Thinkphp LoadMiddleware middleware.php file more Load #68

Closed

Conversation

645418484
Copy link
Contributor

No description provided.

@645418484
Copy link
Contributor Author

I tried to connect with thinkphp and found that the first request worked and subsequent requests always got an error

image

@645418484
Copy link
Contributor Author

When you trace the code, you see that each request is loaded into the middleware.php file.So I changed it to only load once.
/ #68

@645418484
Copy link
Contributor Author

relevance Issue think文件报错 #38

@joanhey
Copy link
Owner

joanhey commented Feb 22, 2024

@yangguangwuwu Could you check it ??
Thanks

@645418484
Copy link
Contributor Author

你能检查一下吗? 谢谢

ok, hold on.

@645418484
Copy link
Contributor Author

I need help , check works fine in my local area , but in online check always stop on "it delete COOKIES " and "it check $_FILES with composer.json with dataset file_composer " , see other issue #59

vscode ➜ /workspaces/php/AdapterMan (fix-thinkphp-load-middleware) $ vendor/bin/pest --colors=always

   PASS  Tests\Feature\ConvertExtVarToUnderscoreTest
  ✓ it converts GET Query var name to underscore with ('a b', 'a_b')                                                          0.02s  
  ✓ it converts GET Query var name to underscore with ('a.b', 'a_b')
  ✓ it converts GET Query var name to underscore with ('a[b', 'a_b')
  ✓ it converts GET Query var name to underscore with ('a_b', 'a_b')
  ✓ it converts GET Query var name to underscore with ('a]b', 'a]b')
  ✓ it converts GET Query var name to underscore with ('a-b', 'a-b')
  ✓ it converts GET Query var name to underscore with ('a/b', 'a/b')
  ✓ it converts GET Query var name to underscore with ('a\b', 'a\b')
  ✓ it converts GET Query var name to underscore with ('a,b', 'a,b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a b', 'a_b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a.b', 'a_b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a[b', 'a_b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a_b', 'a_b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a]b', 'a]b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a-b', 'a-b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a/b', 'a/b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a\b', 'a\b')
  ✓ it convert POST "application/x-www-form-urlencoded" var name to underscore with ('a,b', 'a,b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a b', 'a_b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a.b', 'a_b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a[b', 'a_b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a_b', 'a_b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a]b', 'a]b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a-b', 'a-b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a/b', 'a/b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a\b', 'a\b')
  ✓ it convert POST "multipart/form-data" var name to underscore with ('a,b', 'a,b')

   PASS  Tests\Feature\CookiesTest
  ✓ it set COOKIES                                                                                                            0.01s  
  ✓ it delete COOKIES

   PASS  Tests\Feature\GetTest
  ✓ it tests GET
  ✓ it tests GET Query string with dataset "empty"
  ✓ it tests GET Query string with dataset "one var"
  ✓ it tests GET Query string with dataset "two vars"
  ✓ it tests GET Query string with dataset "indexed-array"
  ✓ it tests GET Query string with dataset "associative-array"
  ✓ it tests GET Query string with dataset "all mixed"
  ✓ it tests GET Query string with dataset "10k body"
  ✓ it tests GET Query string with complex array with ([['Bob Smith', '47', 'M', …], ['golf', 'opera', 'poker', …], [['12', 'M'], ['8', 'F']], …])

   PASS  Tests\Feature\HttpMethodsTest
  ✓ it get HTTP method with ('GET')
  ✓ it get HTTP method with ('POST')
  ✓ it get HTTP method with ('PUT')
  ✓ it get HTTP method with ('DELETE')
  ✓ it get HTTP method with ('OPTIONS')
  ✓ it get HTTP method with ('PATCH')
  ✓ it get HTTP HEAD method and not return body
  ✓ it get HTTP BAD method return 400
  ✓ it get HTTP lowercase method return 400 with ('get')
  ✓ it get HTTP lowercase method return 400 with ('Get')
  ✓ it get HTTP lowercase method return 400 with ('post')
  ✓ it get HTTP lowercase method return 400 with ('Post')
  ✓ it get HTTP lowercase method return 400 with ('put')
  ✓ it get HTTP lowercase method return 400 with ('Put')
  ✓ it get HTTP lowercase method return 400 with ('delete')
  ✓ it get HTTP lowercase method return 400 with ('Delete')
  ✓ it get HTTP lowercase method return 400 with ('patch')
  ✓ it get HTTP lowercase method return 400 with ('Patch')
  ✓ it get HTTP lowercase method return 400 with ('head')
  ✓ it get HTTP lowercase method return 400 with ('Head')
  ✓ it get HTTP lowercase method return 400 with ('options')
  ✓ it get HTTP lowercase method return 400 with ('Options')

   PASS  Tests\Feature\IpPortTest
  ✓ it get client IP                                                                                                          0.01s  
  ✓ it get server IP

   PASS  Tests\Feature\PostTest
  ✓ it get POST "application/x-www-form-urlencoded" with dataset "empty"
  ✓ it get POST "application/x-www-form-urlencoded" with dataset "one var"
  ✓ it get POST "application/x-www-form-urlencoded" with dataset "two vars"
  ✓ it get POST "application/x-www-form-urlencoded" with dataset "indexed-array"
  ✓ it get POST "application/x-www-form-urlencoded" with dataset "associative-array"
  ✓ it get POST "application/x-www-form-urlencoded" with dataset "all mixed"
  ✓ it get POST "application/x-www-form-urlencoded" with dataset "10k body"
  ✓ it get POST "application/json" with dataset "empty"
  ✓ it get POST "application/json" with dataset "one var"
  ✓ it get POST "application/json" with dataset "two vars"
  ✓ it get POST "application/json" with dataset "indexed-array"
  ✓ it get POST "application/json" with dataset "associative-array"
  ✓ it get POST "application/json" with dataset "all mixed"
  ✓ it get POST "application/json" with dataset "10k body"
  ✓ it get POST "multipart/form-data" with dataset "empty"
  ✓ it get POST "multipart/form-data" with dataset "one var"
  ✓ it get POST "multipart/form-data" with dataset "two vars"
  ✓ it get POST "multipart/form-data" with dataset "indexed-array"
  ✓ it get POST "multipart/form-data" with dataset "associative-array"
  ✓ it get POST "multipart/form-data" with dataset "all mixed"
  ✓ it get POST "multipart/form-data" with dataset "10k body"

   PASS  Tests\Feature\RequestHeadersTest
  ✓ it get Request Headers with dataset "empty"                                                                               0.01s  
  ✓ it get Request Headers with dataset "one var"
  ✓ it get Request Headers with dataset "two vars"
  ✓ it get Request Headers with dataset "numerically index"
  ✓ it get Request Headers with dataset "referer"
  ✓ it get Request Headers with dataset "key start with X"
  ✓ it get headers with ('Host', '127.0.0.1:8080')
  ✓ it get headers with ('User-Agent', 'Testing/1.0')

   PASS  Tests\Feature\StatusTest
  ✓ it tests 200 GET
  ✓ it tests 404 GET

   PASS  Tests\Feature\UploadTest
  ✓ it check $_FILES with composer.json with dataset "file_composer"
  ✓ it get POST Multipart with files with dataset "empty"
  ✓ it get POST Multipart with files with dataset "one var"
  ✓ it get POST Multipart with files with dataset "two vars"
  ✓ it get POST Multipart with files with dataset "indexed-array"
  ✓ it get POST Multipart with files with dataset "associative-array"
  ✓ it get POST Multipart with files with dataset "all mixed"
  ✓ it get POST Multipart with files with dataset "10k body"

   TODO  Tests\Unit\ExampleTest - 1 todo
  ↓ example

  Tests:    1 todo, 101 passed (492 assertions)
  Duration: 1.23s


   INFO  Adapterman/0.6.1 (Workerman/4.1.15) OK

Workerman[/workspaces/php/AdapterMan/tests/AdaptermanServer.php] start in DEBUG mode
-------------------------------------------- WORKERMAN --------------------------------------------
Workerman version:4.1.15          PHP version:8.2.14           Event-Loop:\Workerman\Events\Select
--------------------------------------------- WORKERS ---------------------------------------------
proto   user            worker              listen                 processes    status           
tcp     vscode          Adapterman Tests    http://0.0.0.0:8080    1             [OK]            
---------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
vscode ➜ /workspaces/php/AdapterMan (fix-thinkphp-load-middleware) $ 

@645418484
Copy link
Contributor Author

php version:
PHP 8.2.14 (cli) (built: Jan 11 2024 08:05:03) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.14, Copyright (c) Zend Technologies

@645418484
Copy link
Contributor Author

Some of my friends were having trouble using it, so I added thinkphp recipes. at commit 0bcd997

@joanhey
Copy link
Owner

joanhey commented Feb 23, 2024

Hi @645418484

Thinkphp

I can't test it with it.
It's for that, than it'll be better than another dev using Thinkphp check-it or help with the fix (4 eyes principle) before merge it.

Recipe

Thank you for the recipe.
Check also the adapterman shell command (undocumented & WIP) .
https://github.com/joanhey/AdapterMan/blob/master/adapterman
https://github.com/joanhey/AdapterMan/blob/master/src/start.php
https://github.com/joanhey/AdapterMan/blob/master/src/frameworks/index.php

That start automatically a server, and detect the framework in use.

Tests

I need help , check works fine in my local area , but in online check always stop on "it delete COOKIES " and "it check $_FILES with composer.json with dataset file_composer "

Perhaps you are testing Workerman, and not Adapterman, because that 2 errors occur only in Workerman.
https://github.com/joanhey/AdapterMan/actions/runs/7998764983/job/21855468859

Check the output, that you are testing Adapterman:

   INFO  Adapterman/0.6.1 (Workerman/4.1.15) OK

Workerman[/workspaces/php/AdapterMan/tests/AdaptermanServer.php] start in DEBUG mode

Workerman fail the tests, because the Workerman tests are not finished yet. Not because fail.

Initially I wanted to create the functional tests for both Adapterman and Workerman.
But they are useful for more projects: php own server, ngx-php, reactphp, swoole, ... almost any php-runtime.
But it'll be very difficult to maintain the tests in all the repos, and I created a new repo only for the tests (work in progress) so that any php-runtime can include it in composer dev to test it easily in local or GH actions.

https://github.com/joanhey/TestMan

As any issue in one runtime, also it can exist in others runtimes, then with the time it will have enough feedback to have a solid functional test.
It is only necessary to create a server, for each runtime.
https://github.com/joanhey/TestMan/tree/main/tests/Servers

Thanks for your comments.

PD: please try to separate the topics in PRs and Issues, so it'll be easier to find it to others devs.

@645418484
Copy link
Contributor Author

Hi @645418484

Thinkphp

I can't test it with it. It's for that, than it'll be better than another dev using Thinkphp check-it or help with the fix (4 eyes principle) before merge it.

Recipe

Thank you for the recipe. Check also the adapterman shell command (undocumented & WIP) . https://github.com/joanhey/AdapterMan/blob/master/adapterman https://github.com/joanhey/AdapterMan/blob/master/src/start.php https://github.com/joanhey/AdapterMan/blob/master/src/frameworks/index.php

That start automatically a server, and detect the framework in use.

Tests

I need help , check works fine in my local area , but in online check always stop on "it delete COOKIES " and "it check $_FILES with composer.json with dataset file_composer "

Perhaps you are testing Workerman, and not Adapterman, because that 2 errors occur only in Workerman. https://github.com/joanhey/AdapterMan/actions/runs/7998764983/job/21855468859

Check the output, that you are testing Adapterman:

   INFO  Adapterman/0.6.1 (Workerman/4.1.15) OK

Workerman[/workspaces/php/AdapterMan/tests/AdaptermanServer.php] start in DEBUG mode

Workerman fail the tests, because the Workerman tests are not finished yet. Not because fail.

Initially I wanted to create the functional tests for both Adapterman and Workerman. But they are useful for more projects: php own server, ngx-php, reactphp, swoole, ... almost any php-runtime. But it'll be very difficult to maintain the tests in all the repos, and I created a new repo only for the tests (work in progress) so that any php-runtime can include it in composer dev to test it easily in local or GH actions.

https://github.com/joanhey/TestMan

As any issue in one runtime, also it can exist in others runtimes, then with the time it will have enough feedback to have a solid functional test. It is only necessary to create a server, for each runtime. https://github.com/joanhey/TestMan/tree/main/tests/Servers

Thanks for your comments.

PD: please try to separate the topics in PRs and Issues, so it'll be easier to find it to others devs.

Hello, @joanhey

Recipe

I will delete the newly added Recipe file and then I will provide a separate issue to deal with it

Tests

I have taken a look at the pest unit test code and perhaps we should test the standard functionality of the http protocol to satisfy most scenarios with less effort. That's just a little thought hahaha

other

For this pr, I will also create an issue to associate with

Thank you very much

@joanhey
Copy link
Owner

joanhey commented Feb 27, 2024

Added in PR

@joanhey joanhey closed this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants