v17development / flarum-seo

Perfect SEO for your Flarum forum
https://discuss.flarum.org/d/18316-flarum-seo
MIT License
43 stars 22 forks source link

Error: Call to a member function getAttribute() #11

Closed doweis closed 5 years ago

doweis commented 5 years ago

The extension causes on some but not all discussions the Flarum error page if the discussion-page gets reloaded or gets opened via direct link.

Flarum log:


[2019-02-12 10:38:46] production.ERROR: Error: Call to a member function getAttribute() on null in /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Managers/QADiscussion.php:121
Stack trace:
#0 /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Managers/QADiscussion.php(59): V17Development\FlarumSeo\Managers\QADiscussion->createTags()
#1 /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Listeners/PageListener.php(149): V17Development\FlarumSeo\Managers\QADiscussion->__construct(Object(V17Development\FlarumSeo\Listeners\PageListener), Object(Flarum\Discussion\DiscussionRepository), '1737-neues-foru...')
#2 /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Listeners/PageListener.php(112): V17Development\FlarumSeo\Listeners\PageListener->determine()
#3 /srv/web/breitband.bz.it/vendor/flarum/core/src/Frontend/Frontend.php(65): V17Development\FlarumSeo\Listeners\PageListener->__invoke(Object(Flarum\Frontend\Document), Object(Zend\Diactoros\ServerRequest))
#4 /srv/web/breitband.bz.it/vendor/flarum/core/src/Frontend/Frontend.php(57): Flarum\Frontend\Frontend->populate(Object(Flarum\Frontend\Document), Object(Zend\Diactoros\ServerRequest))
#5 /srv/web/breitband.bz.it/vendor/flarum/core/src/Frontend/Controller.php(34): Flarum\Frontend\Frontend->document(Object(Zend\Diactoros\ServerRequest))
#6 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/RouteHandlerFactory.php(40): Flarum\Frontend\Controller->handle(Object(Zend\Diactoros\ServerRequest))
#7 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php(67): Flarum\Http\RouteHandlerFactory->Flarum\Http\{closure}(Object(Zend\Diactoros\ServerRequest), Array)
#8 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\DispatchRoute->process(Object(Zend\Diactoros\ServerRequest), Object(Closure))
#9 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/ShareErrorsFromSession.php(58): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#10 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\ShareErrorsFromSession->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#11 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#12 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\SetLocale->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#13 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(34): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#14 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\AuthenticateWithSession->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#15 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(52): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#16 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\RememberFromCookie->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#17 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/StartSession.php(62): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#18 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\StartSession->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#19 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/CollectGarbage.php(48): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#20 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\CollectGarbage->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#21 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(29): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#22 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\ParseJsonBody->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#23 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/HandleErrorsWithView.php(67): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#24 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\HandleErrorsWithView->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#25 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(83): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#26 /srv/web/breitband.bz.it/vendor/middlewares/request-handler/src/RequestHandler.php(84): Zend\Stratigility\MiddlewarePipe->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#27 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Middlewares\RequestHandler->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#28 /srv/web/breitband.bz.it/vendor/middlewares/base-path-router/src/BasePathRouter.php(97): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#29 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Middlewares\BasePathRouter->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#30 /srv/web/breitband.bz.it/vendor/middlewares/base-path/src/BasePath.php(53): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#31 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Middlewares\BasePath->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))
#32 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(83): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))
#33 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(72): Zend\Stratigility\MiddlewarePipe->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\EmptyPipelineHandler))
#34 /srv/web/breitband.bz.it/vendor/zendframework/zend-httphandlerrunner/src/RequestHandlerRunner.php(95): Zend\Stratigility\MiddlewarePipe->handle(Object(Zend\Diactoros\ServerRequest))
#35 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Server.php(46): Zend\HttpHandlerRunner\RequestHandlerRunner->run()
#36 /srv/web/breitband.bz.it/public/index.php(22): Flarum\Http\Server->listen()
#37 {main}```
doweis commented 5 years ago

Hi, I manually changed the code to your fixed code, https://github.com/v17development/flarum-seo/commit/b9455162a56993a8dc534d46c3cb5024f806614c unfortunately the error still exists... But is the only post as far as I have tested, which is way better than before.

The site on which the error occures is : https://www.breitband.bz.it/d/1643-fibra-fttc-in-lana/23 Log: `[2019-05-11 18:04:01] production.ERROR: InvalidArgumentException: Cannot load XML: Premature end of data in tag r line 1 in /srv/web/breitband.bz.it/vendor/s9e/text-formatter/src/Renderer.php:23 Stack trace:

0 /srv/web/breitband.bz.it/vendor/s9e/text-formatter/src/Renderers/PHP.php(127): s9e\TextFormatter\Renderer->loadXML('

<QUOTE...')

1 /srv/web/breitband.bz.it/vendor/s9e/text-formatter/src/Renderer.php(31): s9e\TextFormatter\Renderers\PHP->renderRichText('

<QUOTE...')

2 /srv/web/breitband.bz.it/vendor/flarum/core/src/Formatter/Formatter.php(80): s9e\TextFormatter\Renderer->render('

<QUOTE...')

3 /srv/web/breitband.bz.it/vendor/flarum/core/src/Post/CommentPost.php(173): Flarum\Formatter\Formatter->render('

<QUOTE...', Object(Flarum\Post\CommentPost))

4 /srv/web/breitband.bz.it/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php(438): Flarum\Post\CommentPost->getContentHtmlAttribute(NULL)

5 /srv/web/breitband.bz.it/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php(340): Illuminate\Database\Eloquent\Model->mutateAttribute('contentHtml', NULL)

6 /srv/web/breitband.bz.it/vendor/illuminate/database/Eloquent/Concerns/HasAttributes.php(313): Illuminate\Database\Eloquent\Model->getAttributeValue('contentHtml')

7 /srv/web/breitband.bz.it/vendor/flarum/core/src/Database/AbstractModel.php(118): Illuminate\Database\Eloquent\Model->getAttribute('contentHtml')

8 /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Managers/QADiscussion.php(165): Flarum\Database\AbstractModel->getAttribute('contentHtml')

9 /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Managers/QADiscussion.php(59): V17Development\FlarumSeo\Managers\QADiscussion->createTags()

10 /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Listeners/PageListener.php(149): V17Development\FlarumSeo\Managers\QADiscussion->__construct(Object(V17Development\FlarumSeo\Listeners\PageListener), Object(Flarum\Discussion\DiscussionRepository), '1643-fibra-fttc...')

11 /srv/web/breitband.bz.it/vendor/v17development/flarum-seo/src/Listeners/PageListener.php(112): V17Development\FlarumSeo\Listeners\PageListener->determine()

12 /srv/web/breitband.bz.it/vendor/flarum/core/src/Frontend/Frontend.php(65): V17Development\FlarumSeo\Listeners\PageListener->__invoke(Object(Flarum\Frontend\Document), Object(Zend\Diactoros\ServerRequest))

13 /srv/web/breitband.bz.it/vendor/flarum/core/src/Frontend/Frontend.php(57): Flarum\Frontend\Frontend->populate(Object(Flarum\Frontend\Document), Object(Zend\Diactoros\ServerRequest))

14 /srv/web/breitband.bz.it/vendor/flarum/core/src/Frontend/Controller.php(34): Flarum\Frontend\Frontend->document(Object(Zend\Diactoros\ServerRequest))

15 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/RouteHandlerFactory.php(40): Flarum\Frontend\Controller->handle(Object(Zend\Diactoros\ServerRequest))

16 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php(67): Flarum\Http\RouteHandlerFactory->Flarum\Http{closure}(Object(Zend\Diactoros\ServerRequest), Array)

17 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\DispatchRoute->process(Object(Zend\Diactoros\ServerRequest), Object(Closure))

18 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/ShareErrorsFromSession.php(58): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

19 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\ShareErrorsFromSession->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

20 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

21 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\SetLocale->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

22 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(34): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

23 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\AuthenticateWithSession->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

24 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(52): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

25 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\RememberFromCookie->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

26 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/StartSession.php(62): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

27 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\StartSession->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

28 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/CollectGarbage.php(48): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

29 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\CollectGarbage->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

30 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(29): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

31 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\ParseJsonBody->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

32 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Middleware/HandleErrorsWithView.php(67): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

33 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Flarum\Http\Middleware\HandleErrorsWithView->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

34 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(83): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

35 /srv/web/breitband.bz.it/vendor/middlewares/request-handler/src/RequestHandler.php(84): Zend\Stratigility\MiddlewarePipe->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

36 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Middlewares\RequestHandler->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

37 /srv/web/breitband.bz.it/vendor/middlewares/base-path-router/src/BasePathRouter.php(97): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

38 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Middlewares\BasePathRouter->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

39 /srv/web/breitband.bz.it/vendor/middlewares/base-path/src/BasePath.php(53): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

40 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/Next.php(52): Middlewares\BasePath->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\Next))

41 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(83): Zend\Stratigility\Next->handle(Object(Zend\Diactoros\ServerRequest))

42 /srv/web/breitband.bz.it/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php(72): Zend\Stratigility\MiddlewarePipe->process(Object(Zend\Diactoros\ServerRequest), Object(Zend\Stratigility\EmptyPipelineHandler))

43 /srv/web/breitband.bz.it/vendor/zendframework/zend-httphandlerrunner/src/RequestHandlerRunner.php(95): Zend\Stratigility\MiddlewarePipe->handle(Object(Zend\Diactoros\ServerRequest))

44 /srv/web/breitband.bz.it/vendor/flarum/core/src/Http/Server.php(46): Zend\HttpHandlerRunner\RequestHandlerRunner->run()

45 /srv/web/breitband.bz.it/public/index.php(22): Flarum\Http\Server->listen()

46 {main}

`

jaspervriends commented 5 years ago

Hello @doweis ! Thanks for trying the updated code!

This seems to be a different error then before. The other one was a Call to a member function getAttribute() on null in error. This one is a text rendering error.

Someone else did have the same issue as you have, way before this extension: https://discuss.flarum.org/d/829-admin-content-not-showing/4

So, I think that one post in that discussion is corrupt somehow. It may be a Flarum bug. Did you see this on more discussions?

jaspervriends commented 5 years ago

Just investigated the topic by navigating through it. At first I see it's a topic of 2017, so I think you used a migrator that converted the posts to flarum readable posts?

When I am looking at that topic (and browse through it), I indeed see that Flarum cannot load one of the posts.

This one results into an 500 error, and I think that error is the one you mentioned above: https://www.breitband.bz.it/api/posts?filter[id]=15680,15681,15682,15683,15684,15685,15687,15688,15689,15690,15692,15697,15699,15700,15701,15704,15705,15706,15716,15717

This is the post that will give an error: https://www.breitband.bz.it/api/posts?filter[id]=15690

Post ID 15690. I think an XML tag may be missing somewhere. But I am not too sure about that.

So, for this topic, it's not the plugin, but one of the posts that prevent the page from loading.

doweis commented 5 years ago

Thanks for your reply, indeed it was the only disussion, which caused that issue. But the strange thing is, that only when Flarum-SEO is enabeld the whole discussion is not loading. Normally it was loading the disussion, but only this post was not loading.

I deleted now that post, so everything works again.

Thanks for fixing the issue! Great extension!