FriendsOfFlarum / pages

Create custom static pages in Flarum
https://discuss.flarum.org/d/18301
MIT License
23 stars 12 forks source link

HTTP error 500 on /api/pages: "instance of __PHP_Incomplete_Class given" #25

Closed hvanmegen closed 4 years ago

hvanmegen commented 4 years ago

I'm experiencing an error 500 without direct evidence what's causing it

When I load the admin pages and it tries to request /api/pages?page[offset]=0&page[limit]=20&sort=-time it's returning an error 500 with {"errors":[{"status":"500","code":"unknown"}]} as the response error code.

I distinctly remember it working and me making a first 'Privacy information' page with it, and I can see that page in the database under tables pages. It looks ok, about 2500 characters of content.. no idea whats going wrong.

I'm kinda new to Flarum; what can I do to debug the issue better?

luceos commented 4 years ago

Have you enabled debug in your config.php? Maybe that throws a better error.

Otherwise look at storage/logs for the latest flarum.log.

hvanmegen commented 4 years ago

Thnx @luceos for the tips.. I've looked into the logs and I've enabled the debug, this is what I'm getting: (the error_log is clean)

[2020-10-14 09:26:34] production.ERROR: TypeError: Argument 1 passed to Flarum\Formatter\Event\Rendering::__construct() must be an instance of s9e\TextFormatter\Renderer, instance of __PHP_Incomplete_Class given, called in /domains/mydomain.tld/vendor/flarum/core/src/Formatter/Formatter.php on line 78 and defined in /domains/mydomain.tld/vendor/flarum/core/src/Formatter/Event/Rendering.php:43
Stack trace:
#0 /domains/mydomain.tld/vendor/flarum/core/src/Formatter/Formatter.php(78): Flarum\Formatter\Event\Rendering->__construct()
#1 /domains/mydomain.tld/vendor/fof/pages/src/Page.php(124): Flarum\Formatter\Formatter->render()
#2 /domains/mydomain.tld/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php(444): FoF\Pages\Page->getContentHtmlAttribute()
#3 /domains/mydomain.tld/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php(344): Illuminate\Database\Eloquent\Model->mutateAttribute()
#4 /domains/mydomain.tld/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php(317): Illuminate\Database\Eloquent\Model->getAttributeValue()
#5 /domains/mydomain.tld/vendor/flarum/core/src/Database/AbstractModel.php(128): Illuminate\Database\Eloquent\Model->getAttribute()
#6 /domains/mydomain.tld/vendor/illuminate/database/Eloquent/Model.php(1515): Flarum\Database\AbstractModel->getAttribute()
#7 /domains/mydomain.tld/vendor/fof/pages/src/Api/Serializer/PageSerializer.php(38): Illuminate\Database\Eloquent\Model->__get()
#8 /domains/mydomain.tld/vendor/flarum/core/src/Api/Serializer/AbstractSerializer.php(84): FoF\Pages\Api\Serializer\PageSerializer->getDefaultAttributes()
#9 /domains/mydomain.tld/vendor/tobscure/json-api/src/Resource.php(169): Flarum\Api\Serializer\AbstractSerializer->getAttributes()
#10 /domains/mydomain.tld/vendor/tobscure/json-api/src/Resource.php(75): Tobscure\JsonApi\Resource->getAttributes()
#11 /domains/mydomain.tld/vendor/tobscure/json-api/src/Collection.php(123): Tobscure\JsonApi\Resource->toArray()
#12 [internal function]: Tobscure\JsonApi\Collection->Tobscure\JsonApi\{closure}()
#13 /domains/mydomain.tld/vendor/tobscure/json-api/src/Collection.php(124): array_map()
#14 /domains/mydomain.tld/vendor/tobscure/json-api/src/Document.php(181): Tobscure\JsonApi\Collection->toArray()
#15 /domains/mydomain.tld/vendor/tobscure/json-api/src/Document.php(224): Tobscure\JsonApi\Document->toArray()
#16 /domains/mydomain.tld/vendor/flarum/core/src/Api/JsonApiResponse.php(27): Tobscure\JsonApi\Document->jsonSerialize()
#17 /domains/mydomain.tld/vendor/flarum/core/src/Api/Controller/AbstractSerializeController.php(111): Flarum\Api\JsonApiResponse->__construct()
#18 /domains/mydomain.tld/vendor/flarum/core/src/Http/RouteHandlerFactory.php(38): Flarum\Api\Controller\AbstractSerializeController->handle()
#19 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php(65): Flarum\Http\RouteHandlerFactory->Flarum\Http\{closure}()
#20 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\DispatchRoute->process()
#21 /domains/mydomain.tld/vendor/alexanderomara/flarum-gravatar/src/Middleware/Intercept.php(51): Laminas\Stratigility\Next->handle()
#22 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): AlexanderOMara\FlarumGravatar\Middleware\Intercept->process()
#23 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/SetLocale.php(50): Laminas\Stratigility\Next->handle()
#24 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\SetLocale->process()
#25 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php(37): Laminas\Stratigility\Next->handle()
#26 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\CheckCsrfToken->process()
#27 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/AuthenticateWithHeader.php(55): Laminas\Stratigility\Next->handle()
#28 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\AuthenticateWithHeader->process()
#29 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(32): Laminas\Stratigility\Next->handle()
#30 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\AuthenticateWithSession->process()
#31 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(51): Laminas\Stratigility\Next->handle()
#32 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\RememberFromCookie->process()
#33 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/StartSession.php(61): Laminas\Stratigility\Next->handle()
#34 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\StartSession->process()
#35 /domains/mydomain.tld/vendor/flarum/core/src/Api/Middleware/FakeHttpMethods.php(29): Laminas\Stratigility\Next->handle()
#36 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Api\Middleware\FakeHttpMethods->process()
#37 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(28): Laminas\Stratigility\Next->handle()
#38 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\ParseJsonBody->process()
#39 /domains/mydomain.tld/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\Stratigility\Next->handle()
#40 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Flarum\Http\Middleware\HandleErrors->process()
#41 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(84): Laminas\Stratigility\Next->handle()
#42 /domains/mydomain.tld/vendor/middlewares/request-handler/src/RequestHandler.php(84): Laminas\Stratigility\MiddlewarePipe->process()
#43 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\RequestHandler->process()
#44 /domains/mydomain.tld/vendor/middlewares/base-path-router/src/BasePathRouter.php(97): Laminas\Stratigility\Next->handle()
#45 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\BasePathRouter->process()
#46 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Middleware/OriginalMessages.php(42): Laminas\Stratigility\Next->handle()
#47 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Laminas\Stratigility\Middleware\OriginalMessages->process()
#48 /domains/mydomain.tld/vendor/middlewares/base-path/src/BasePath.php(53): Laminas\Stratigility\Next->handle()
#49 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/Next.php(61): Middlewares\BasePath->process()
#50 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(84): Laminas\Stratigility\Next->handle()
#51 /domains/mydomain.tld/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(73): Laminas\Stratigility\MiddlewarePipe->process()
#52 /domains/mydomain.tld/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(96): Laminas\Stratigility\MiddlewarePipe->handle()
#53 /domains/mydomain.tld/vendor/flarum/core/src/Http/Server.php(42): Laminas\HttpHandlerRunner\RequestHandlerRunner->run()
#54 /domains/mydomain.tld/public/index.php(26): Flarum\Http\Server->listen()
#55 {main}
luceos commented 4 years ago

This happens when a cache file inside storage is no longer available, eg manually deleted without flushing the Flarum cache.

Try to see if running this command helps:

php flarum cache:clear
hvanmegen commented 4 years ago

Hmm, I tried clearing the cache, but it's still giving me the same stack trace..

EDIT: it came down to file permission problems.. removed everything in storage/cache and the issue was solved :)