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

Recent changes block gives an error - demo-dev #3726

Closed
melizaa opened this issue Feb 16, 2021 · 3 comments
Closed

Recent changes block gives an error - demo-dev #3726

melizaa opened this issue Feb 16, 2021 · 3 comments

Comments

@melizaa
Copy link
Contributor

melizaa commented Feb 16, 2021

My page of the moderator.

Argument 1 passed to Fisharebest\Webtrees\Services\UserService::find() must be of the type int or null, string given, called in …/app/Module/RecentChangesModule.php on line 320 …/app/Services/UserService.php:53
#0 …/app/Module/RecentChangesModule.php(320): Fisharebest\Webtrees\Services\UserService->find()
#1 [internal function]: Fisharebest\Webtrees\Module\RecentChangesModule->Fisharebest\Webtrees\Module{closure}()
#2 …/vendor/illuminate/support/Collection.php(1120): array_map()
#3 …/app/Module/RecentChangesModule.php(322): Illuminate\Support\Collection->map()
#4 …/app/Module/RecentChangesModule.php(122): Fisharebest\Webtrees\Module\RecentChangesModule->getRecentChangesFromDatabase()
#5 …/app/Http/RequestHandlers/UserPageBlock.php(72): Fisharebest\Webtrees\Module\RecentChangesModule->getBlock()
#6 …/app/Http/Middleware/WrapHandler.php(83): Fisharebest\Webtrees\Http\RequestHandlers\UserPageBlock->handle()
#7 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\WrapHandler->process()
#8 …/app/Module/HitCountFooterModule.php(157): Middleland\Dispatcher->handle()
#9 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Module\HitCountFooterModule->process()
#10 …/app/Http/Middleware/AuthLoggedIn.php(50): Middleland\Dispatcher->handle()
#11 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\AuthLoggedIn->process()
#12 …/app/Http/Middleware/CheckCsrf.php(75): Middleland\Dispatcher->handle()
#13 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CheckCsrf->process()
#14 …/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle()
#15 …/app/Http/Middleware/Router.php(166): Middleland\Dispatcher->dispatch()
#16 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\Router->process()
#17 …/app/Http/Middleware/BootModules.php(62): Middleland\Dispatcher->handle()
#18 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BootModules->process()
#19 …/app/Http/Middleware/LoadRoutes.php(76): Middleland\Dispatcher->handle()
#20 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\LoadRoutes->process()
#21 …/app/Http/Middleware/UseTransaction.php(45): Middleland\Dispatcher->handle()
#22 …/vendor/illuminate/database/Concerns/ManagesTransactions.php(29): Fisharebest\Webtrees\Http\Middleware\UseTransaction::Fisharebest\Webtrees\Http\Middleware{closure}()
#23 …/app/Http/Middleware/UseTransaction.php(46): Illuminate\Database\Connection->transaction()
#24 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseTransaction->process()
#25 …/app/Http/Middleware/DoHousekeeping.php(74): Middleland\Dispatcher->handle()
#26 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\DoHousekeeping->process()
#27 …/app/Http/Middleware/UseTheme.php(70): Middleland\Dispatcher->handle()
#28 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseTheme->process()
#29 …/app/Http/Middleware/CheckForMaintenanceMode.php(51): Middleland\Dispatcher->handle()
#30 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CheckForMaintenanceMode->process()
#31 …/app/Http/Middleware/UseLanguage.php(70): Middleland\Dispatcher->handle()
#32 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseLanguage->process()
#33 …/app/Http/Middleware/UseSession.php(71): Middleland\Dispatcher->handle()
#34 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseSession->process()
#35 …/app/Http/Middleware/UpdateDatabaseSchema.php(58): Middleland\Dispatcher->handle()
#36 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UpdateDatabaseSchema->process()
#37 …/app/Http/Middleware/UseDebugbar.php(67): Middleland\Dispatcher->handle()
#38 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseDebugbar->process()
#39 …/app/Http/Middleware/UseDatabase.php(117): Middleland\Dispatcher->handle()
#40 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseDatabase->process()
#41 …/app/Http/Middleware/BadBotBlocker.php(217): Middleland\Dispatcher->handle()
#42 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BadBotBlocker->process()
#43 …/app/Http/Middleware/RegisterFactories.php(74): Middleland\Dispatcher->handle()
#44 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\RegisterFactories->process()
#45 …/vendor/middlewares/client-ip/src/ClientIp.php(81): Middleland\Dispatcher->handle()
#46 …/app/Http/Middleware/ClientIp.php(47): Middlewares\ClientIp->process()
#47 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ClientIp->process()
#48 …/app/Http/Middleware/HandleExceptions.php(90): Middleland\Dispatcher->handle()
#49 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\HandleExceptions->process()
#50 …/app/Http/Middleware/BaseUrl.php(77): Middleland\Dispatcher->handle()
#51 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BaseUrl->process()
#52 …/app/Http/Middleware/ReadConfigIni.php(69): Middleland\Dispatcher->handle()
#53 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ReadConfigIni->process()
#54 …/app/Http/Middleware/SecurityHeaders.php(47): Middleland\Dispatcher->handle()
#55 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\SecurityHeaders->process()
#56 …/app/Http/Middleware/EmitResponse.php(57): Middleland\Dispatcher->handle()
#57 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\EmitResponse->process()
#58 …/app/Http/Middleware/PhpEnvironment.php(49): Middleland\Dispatcher->handle()
#59 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\PhpEnvironment->process()
#60 …/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle()
#61 …/index.php(57): Middleland\Dispatcher->dispatch()
#62 {main}

@FrankWarius
Copy link

FrankWarius commented Feb 16, 2021

This seems to be a bug in PHP, middleware or elsewhere.

Although the user_id is declared correct as an integer in the database, a text is passed to find(), e.g. '1' instead of 1.

The error disappears sometimes, if you insert debug code before the call.

A quick fix is ​​to encapsulate the argument of find() with intval()
320 'user' => $this->user_service->find(intval($row->user_id)),
and wait for a new PHP release.

Tested with Dev / PHP version 7.4.15 on IIS 10, Windows NT 10.0 build 17763 (Windows Server 2019) AMD64

@fisharebest
Copy link
Owner

@FrankWarius - some database drivers will always provide strings (e.g. Postgres and SQLite).
Others will (optionally) provide the correct type (e.g. MySQL), depending on connection options.

So, for cross-platform compatibility, we tell the database driver to always return strings - and we convert them to integers when needed.

@FrankWarius
Copy link

@fisharebest - I see. First when I add debug code to a function, I disable strict mode - and the error disapeared.

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

No branches or pull requests

3 participants