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

Doesn't handle prefixed tables #2

Closed
clarkwinkelmann opened this issue Aug 18, 2021 · 1 comment
Closed

Doesn't handle prefixed tables #2

clarkwinkelmann opened this issue Aug 18, 2021 · 1 comment
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@clarkwinkelmann
Copy link

clarkwinkelmann commented Aug 18, 2021

This line will cause an error on Flarum installations that use table prefixes

->selectRaw('tags.*')

I think this can be fixed just by using select instead of selectRaw. If that doesn't help there is a function from Laravel to retrieve the table prefix when building raw statements, though I don't remember its name.

Here's an extract from the error message reported by a user on the Flarum Discord server:

[2021-08-18 19:19:30] flarum.ERROR: PDOException: SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'tags' in /home/gramoly/public_html/forum/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:79
Stack trace:
#0 /home/gramoly/public_html/forum/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(79): PDO->prepare('select tags.* f...', Array)
#1 /home/gramoly/public_html/forum/vendor/illuminate/database/Connection.php(352): Doctrine\DBAL\Driver\PDOConnection->prepare('select tags.* f...')
#2 /home/gramoly/public_html/forum/vendor/illuminate/database/Connection.php(685): Illuminate\Database\Connection->Illuminate\Database\{closure}('select tags.* f...', Array)
#3 /home/gramoly/public_html/forum/vendor/illuminate/database/Connection.php(652): Illuminate\Database\Connection->runQueryCallback('select tags.* f...', Array, Object(Closure))
#4 /home/gramoly/public_html/forum/vendor/illuminate/database/Connection.php(360): Illuminate\Database\Connection->run('select tags.* f...', Array, Object(Closure))
#5 /home/gramoly/public_html/forum/vendor/illuminate/database/Query/Builder.php(2350): Illuminate\Database\Connection->select('select tags.* f...', Array, true)
#6 /home/gramoly/public_html/forum/vendor/illuminate/database/Query/Builder.php(2338): Illuminate\Database\Query\Builder->runSelect()
#7 /home/gramoly/public_html/forum/vendor/illuminate/database/Query/Builder.php(2872): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#8 /home/gramoly/public_html/forum/vendor/illuminate/database/Query/Builder.php(2339): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#9 /home/gramoly/public_html/forum/vendor/illuminate/database/Eloquent/Builder.php(602): Illuminate\Database\Query\Builder->get(Array)
#10 /home/gramoly/public_html/forum/vendor/illuminate/database/Eloquent/Builder.php(586): Illuminate\Database\Eloquent\Builder->getModels(Array)
#11 /home/gramoly/public_html/forum/vendor/acpl/my-tags/src/LoadForumTagsRelationship.php(29): Illuminate\Database\Eloquent\Builder->get()
#12 /home/gramoly/public_html/forum/vendor/flarum/core/src/Foundation/ContainerUtil.php(30): Acpl\MyTags\LoadForumTagsRelationship->__invoke(Object(Flarum\Api\Controller\ShowForumController), Array, Object(Laminas\Diactoros\ServerRequest), Object(Tobscure\JsonApi\Document))
#13 /home/gramoly/public_html/forum/vendor/flarum/core/src/Api/Controller/AbstractSerializeController.php(115): Flarum\Foundation\ContainerUtil::Flarum\Foundation\{closure}(Object(Flarum\Api\Controller\ShowForumController), Array, Object(Laminas\Diactoros\ServerRequest), Object(Tobscure\JsonApi\Document))
#14 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/RouteHandlerFactory.php(41): Flarum\Api\Controller\AbstractSerializeController->handle(Object(Laminas\Diactoros\ServerRequest))
#15 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ExecuteRoute.php(27): Flarum\Http\RouteHandlerFactory->Flarum\Http\{closure}(Object(Laminas\Diactoros\ServerRequest), Array)
#16 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ExecuteRoute->process(Object(Laminas\Diactoros\ServerRequest), Object(Closure))
#17 /home/gramoly/public_html/forum/vendor/malago/flarum-achievements/src/Middlewares/MiddlewarePosted.php(27): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#18 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Malago\Achievements\Middlewares\MiddlewarePosted->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#19 /home/gramoly/public_html/forum/vendor/flarum/core/src/Api/Middleware/ThrottleApi.php(33): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#20 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Api\Middleware\ThrottleApi->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#21 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ResolveRoute.php(67): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#22 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ResolveRoute->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#23 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#24 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\SetLocale->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#25 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(52): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#26 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\RememberFromCookie->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#27 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#28 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\HandleErrors->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#29 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(76): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#30 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(65): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\EmptyPipelineHandler))
#31 /home/gramoly/public_html/forum/vendor/flarum/core/src/Api/Client.php(144): Laminas\Stratigility\MiddlewarePipe->handle(Object(Laminas\Diactoros\ServerRequest))
#32 /home/gramoly/public_html/forum/vendor/flarum/core/src/Api/Client.php(95): Flarum\Api\Client->send('GET', '/')
#33 /home/gramoly/public_html/forum/vendor/flarum/core/src/Frontend/Frontend.php(69): Flarum\Api\Client->get('/')
#34 /home/gramoly/public_html/forum/vendor/flarum/core/src/Frontend/Frontend.php(50): Flarum\Frontend\Frontend->getForumDocument(Object(Laminas\Diactoros\ServerRequest))
#35 /home/gramoly/public_html/forum/vendor/flarum/core/src/Frontend/Controller.php(32): Flarum\Frontend\Frontend->document(Object(Laminas\Diactoros\ServerRequest))
#36 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/RouteHandlerFactory.php(41): Flarum\Frontend\Controller->handle(Object(Laminas\Diactoros\ServerRequest))
#37 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ExecuteRoute.php(27): Flarum\Http\RouteHandlerFactory->Flarum\Http\{closure}(Object(Laminas\Diactoros\ServerRequest), Array)
#38 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ExecuteRoute->process(Object(Laminas\Diactoros\ServerRequest), Object(Closure))
#39 /home/gramoly/public_html/forum/vendor/kilowhat/flarum-ext-audit-free/src/Middlewares/SetLoggerActor.php(28): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#40 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Kilowhat\Audit\Middlewares\SetLoggerActor->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#41 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ContentTypeOptionsHeader.php(21): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#42 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ContentTypeOptionsHeader->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#43 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ReferrerPolicyHeader.php(30): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#44 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ReferrerPolicyHeader->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#45 /home/gramoly/public_html/forum/vendor/flarum/core/src/Admin/Middleware/RequireAdministrateAbility.php(24): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#46 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Admin\Middleware\RequireAdministrateAbility->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#47 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php(36): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#48 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\CheckCsrfToken->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#49 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ResolveRoute.php(67): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#50 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ResolveRoute->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#51 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#52 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\SetLocale->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#53 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(31): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#54 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\AuthenticateWithSession->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#55 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(52): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#56 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\RememberFromCookie->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#57 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/StartSession.php(61): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#58 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\StartSession->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#59 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(28): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#60 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ParseJsonBody->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#61 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#62 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\HandleErrors->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#63 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/InjectActorReference.php(25): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#64 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\InjectActorReference->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#65 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(76): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#66 /home/gramoly/public_html/forum/vendor/middlewares/request-handler/src/RequestHandler.php(84): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#67 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Middlewares\RequestHandler->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#68 /home/gramoly/public_html/forum/vendor/middlewares/base-path-router/src/BasePathRouter.php(101): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#69 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Middlewares\BasePathRouter->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#70 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Middleware/OriginalMessages.php(36): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#71 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Laminas\Stratigility\Middleware\OriginalMessages->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#72 /home/gramoly/public_html/forum/vendor/middlewares/base-path/src/BasePath.php(73): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#73 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Middlewares\BasePath->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#74 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Middleware/ProcessIp.php(24): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#75 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/Next.php(51): Flarum\Http\Middleware\ProcessIp->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\Next))
#76 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(76): Laminas\Stratigility\Next->handle(Object(Laminas\Diactoros\ServerRequest))
#77 /home/gramoly/public_html/forum/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(65): Laminas\Stratigility\MiddlewarePipe->process(Object(Laminas\Diactoros\ServerRequest), Object(Laminas\Stratigility\EmptyPipelineHandler))
#78 /home/gramoly/public_html/forum/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(96): Laminas\Stratigility\MiddlewarePipe->handle(Object(Laminas\Diactoros\ServerRequest))
#79 /home/gramoly/public_html/forum/vendor/flarum/core/src/Http/Server.php(44): Laminas\HttpHandlerRunner\RequestHandlerRunner->run()
#80 /home/gramoly/public_html/forum/public/index.php(27): Flarum\Http\Server->listen()
#81 {main}
@rafaucau rafaucau self-assigned this Aug 18, 2021
@rafaucau rafaucau added bug Something isn't working good first issue Good for newcomers labels Aug 18, 2021
rafaucau added a commit that referenced this issue Aug 19, 2021
@rafaucau
Copy link
Member

Fixed in 1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants