OleVik / grav-plugin-imgsrcset

Grav ImgSrcset Plugin
MIT License
12 stars 1 forks source link

Server Error on 2nd page load - mb_strpos() expects parameter 1 to be string #8

Closed n3tman closed 5 years ago

n3tman commented 5 years ago

Somehow I get this error after installing/activating the plugin on secondary page load (after cache is generated):

Server Error
Sorry, something went terribly wrong!
E_WARNING - mb_strpos() expects parameter 1 to be string, object given

Log:

grav.CRITICAL: mb_strpos() expects parameter 1 to be string, object given
Trace: 
#0 D:\Projects\project\system\src\Grav\Common\Debugger.php(314): Whoops\Run->handleError(2, 'mb_strpos() exp...', 'D:\\Projects\\pro...', 684) 
#1 [internal function]: Grav\Common\Debugger->deprecatedErrorHandler(2, 'mb_strpos() exp...', 'D:\\Projects\\pro...', 684, Array) 
#2 D:\Projects\project\system\src\Grav\Common\Page\Page.php(684): mb_strpos(Object(__PHP_Incomplete_Class), '<p>===</p>') 
#3 D:\Projects\project\system\src\Grav\Common\Twig\Twig.php(360): Grav\Common\Page\Page->content() 
#4 D:\Projects\project\system\src\Grav\Common\Service\OutputServiceProvider.php(27): Grav\Common\Twig\Twig->processSite('html') 
#5 D:\Projects\project\vendor\pimple\pimple\src\Pimple\Container.php(118): Grav\Common\Service\OutputServiceProvider->Grav\Common\Service\{closure}(Object(Grav\Common\Grav)) 
#6 D:\Projects\project\system\src\Grav\Common\Processors\RenderProcessor.php(19): Pimple\Container->offsetGet('output') 
#7 D:\Projects\project\system\src\Grav\Common\Grav.php(131): Grav\Common\Processors\RenderProcessor->process() 
#8 D:\Projects\project\system\src\Grav\Common\Grav.php(370): Grav\Common\Grav->Grav\Common\{closure}() 
#9 [internal function]: Grav\Common\Grav::Grav\Common\{closure}('render', 'Render', Object(Closure)) 
#10 D:\Projects\project\system\src\Grav\Common\Grav.php(346): call_user_func_array(Object(Closure), Array) 
#11 D:\Projects\project\system\src\Grav\Common\Grav.php(132): Grav\Common\Grav->__call('measureTime', Array) 
#12 D:\Projects\project\index.php(54): Grav\Common\Grav->process() 
#13 {main} [] []

twig_first is set to true (both system-wise and page-wise)

Disabling the plugin solves the issue.

Grav version: v1.5.10

Theme: inherited from Quark v1.2.6

Installed plugins:

OleVik commented 5 years ago

Given the truncated paths, I can't tell if this is thrown from an error in this plugin specifically. Can you provide more details to clarify how you know this plugin is causing this?

n3tman commented 5 years ago

I think plugin is the reason since disabling it fixes the issue.

Attaching an image of a full backtrace log. I guess plugin somehow replaces $page->content() with a Dom object, thus generating an error. Can't tell more since I don't know PHP..

2019-03-24_182553

MelleNi commented 5 years ago

I think plugin is the reason since disabling it fixes the issue.

I get the exact same error, in the exact same manner: after second page load. Disabling the plug-in 'resolves' the bug.

OleVik commented 5 years ago

I cannot replicate this with the newest release candidates. The plugin does manipulate the DOM of the content, but even using a summary separator the error does not throw. Could either or both of you share the Markdown or Twig that causes the error?

MelleNi commented 5 years ago

Could either or both of you share the Markdown or Twig that causes the error?

Alright, the markdown doesn't seem to matter, as it also occurs on pages with no markdown.

I've uploaded some twig files and added you as collaborator. (I don't know if it works, as I've never used this functionality, here's an invitation link: https://github.com/MelleNi/twigfiles/invitations)

Perhaps I should note that setting Caching to No in the system settings bypasses (?) the issue. I tried to see if changing the subsettings would do anything, but to no avail. Twig caching can be turned on. So, for now my site functions, but without caching.

Tusen takk fra Trondheim

OleVik commented 5 years ago

I managed to provoke the error with both caches enabled, and I think I have a fix. Please test v1.1.1-beta.1 to see if that resolves the issue. Cache has to be cleared after update, which Grav will do automatically if installed with Admin or the GPM.

OleVik commented 5 years ago

@n3tman, @MelleNi, does that beta work for you? If so I'll release it as stable.

MelleNi commented 5 years ago

@OleVik Sorry for the late response > wasn't able to open my laptop for a while.

I think I just successfully managed to update to the beta version, and everything seems to work fine now. I have re-enabled caching and there's been no problems so far.

Amazing job, very much appreciated!

OleVik commented 5 years ago

Great to hear, released v1.1.1 as stable.