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

[Bug] TypeError: $key must be of type int #413

Closed
ismaail opened this issue Jul 24, 2021 · 5 comments
Closed

[Bug] TypeError: $key must be of type int #413

ismaail opened this issue Jul 24, 2021 · 5 comments

Comments

@ismaail
Copy link
Contributor

ismaail commented Jul 24, 2021

using branch master with commit c363b6a, i get this type error:

TypeError: PHPCensor\Store\BuildStore::getByPrimaryKey(): Argument #1 ($key) must be of type int, string given, called in <PHP_CENSOR_PATH>/src/Store.php on line 181 (uncaught exception) at <PHP_CENSOR_PATH>/src/Store/BuildStore.php line 37
ErrorException: 1: Uncaught TypeError: PHPCensor\Store\BuildStore::getByPrimaryKey(): Argument #1 ($key) must be of type int, string given, called in <PHP_CENSOR_PATH>/src/Store.php on line 181 and defined in <PHP_CENSOR_PATH>/src/Store/BuildStore.php:37
Stack trace:
#0 <PHP_CENSOR_PATH>/src/Store.php(181): PHPCensor\Store\BuildStore->getByPrimaryKey('115', 'write')
#1 <PHP_CENSOR_PATH>/src/Store.php(137): PHPCensor\Store->saveByUpdate(Object(PHPCensor\Model\Build\GitlabBuild), false)
#2 <PHP_CENSOR_PATH>/src/Logging/BuildDBLogHandler.php(67): PHPCensor\Store->save(Object(PHPCensor\Model\Build\GitlabBuild))
#3 <PHP_CENSOR_PATH>/src/Logging/BuildDBLogHandler.php(87): PHPCensor\Logging\BuildDBLogHandler->flushData()
#4 <PHP_CENSOR_PATH>/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(42): PHPCensor\Logging\BuildDBLogHandler->write(Array)
#5 <PHP_CENSOR_PATH>/vendor/monolog/monolog/src/Monolog/Logger.php(317): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#6 <PHP_CENSOR_PATH>/vendor/monolog/monolog/src/Monolog/Logger.php(539): Monolog\Logger->addRecord(400, 'TypeError: PHPC...', Array)
#7 <PHP_CENSOR_PATH>/src/Logging/Handler.php(126): Monolog\Logger->error('TypeError: PHPC...', Array)
#8 <PHP_CENSOR_PATH>/src/Logging/Handler.php(112): PHPCensor\Logging\Handler->log(Object(TypeError))
#9 [internal function]: PHPCensor\Logging\Handler->handleException(Object(TypeError))
#10 {main}
  thrown in <PHP_CENSOR_PATH>/src/Store/BuildStore.php line 37 (uncaught exception) at <PHP_CENSOR_PATH>/src/Store/BuildStore.php line 37

Environment

  • PHP Censor version: branch master, commit c363b6a
  • Operating System: Docker
  • PHP version: 8.0.8
  • MySQL version: 5.7
@corpsee
Copy link
Member

corpsee commented Jul 25, 2021

@ismaail Thank you for the report! I guess error appears only on MySQL installations. Could you check your case on branch 2.1-types-fix-413 please?

corpsee added a commit that referenced this issue Jul 25, 2021
@ismaail
Copy link
Contributor Author

ismaail commented Jul 25, 2021

@corpsee tested the branch 2.1-types-fix-413,

build success ✔️ thank you

Tested on both php 8.0 & 7.4

@ismaail
Copy link
Contributor Author

ismaail commented Jul 25, 2021

similar error shows up in the home page (screenshot) and in project page http://www.phpci.localhost/project/view/4 (but not all projects!)

image

Manual (from Web) — Errors: 145
Fatal error: Uncaught TypeError: PHPCensor\Store\BuildStore::getById(): Argument #1 ($id) must be of type int, string given, called in /home/docker/src/Model/Base/Build.php on line 630 and defined in /home/docker/src/Store/BuildStore.php:52 Stack trace: #0 /home/docker/src/Model/Base/Build.php(630): PHPCensor\Store\BuildStore->getById('109') #1 /home/docker/src/Model/Build.php(673): PHPCensor\Model\Base\Build->getErrorsTotalPrevious() #2 /home/docker/src/View/WidgetLastBuilds/update.phtml(98): PHPCensor\Model\Build->getErrorsTrend() #3 /home/docker/src/View.php(85): require('/home/docker/sr...') #4 /home/docker/src/Controller/WidgetLastBuildsController.php(47): PHPCensor\View->render() #5 /home/docker/src/Controller.php(63): PHPCensor\Controller\WidgetLastBuildsController->index() #6 /home/docker/src/WebController.php(89): PHPCensor\Controller->handleAction('index', Array) #7 /home/docker/src/Application.php(131): PHPCensor\WebController->handleAction('index', Array) #8 /home/docker/src/Application.php(163): PHPCensor\Application->handleRequestInner() #9 /home/docker/public/index.php(18): PHPCensor\Application->handleRequest() #10 {main} thrown in /home/docker/src/Store/BuildStore.php on line 52

corpsee added a commit that referenced this issue Jul 25, 2021
@corpsee
Copy link
Member

corpsee commented Jul 25, 2021

@ismaail Could you check again please?

@ismaail
Copy link
Contributor Author

ismaail commented Jul 25, 2021

The commit 1eeddfd8 solves the issue, thanks 👍

@corpsee corpsee closed this as completed Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants