inetis-ch / oc-richeditorsnippets-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript error when used in multisite setup

chocolata opened this issue · comments

Hi guys,

When activating the October CMS multisite feature, intermittently the JavaScript console shows the following error:

GET https://domain.com/inetis/snippets/list?vb4c7a36d net::ERR_ABORTED 500

The issue appears when trying to edit a static page for example. A hard refresh sometimes rectifies the issue, but it reappears soon enough.

I'm using the last version of October CMS v 3.3.1 (for some reason 3.3.2 doesn't install yet) and Richeditor Snippets v2.1.9.

We are using the Richeditor Snippets plugin in the context of a custom pagebuilder that is built with nested repeaters. Being able to use the plugin there means that our clients can add components to richeditors inside snippets, something that is essential to their content management workflow.

Please note that if this were to become a premium plugin, we'd definitely sign up for that. We understand that open source plugin development is low priority.

Could you kindly look into this?

commented

Hi, I was not able to reproduce the issue using a similar environment: October 3.3.1 (same issue here with 3.3.2) multisite enabled with 2 sites, using static pages and trying to switch between two pages (very simple ones, I don't have a layout with nested repeaters to test with right now).

Do you have some entries in your error log ? Or maybe in the network tab of your browser devtools, do you get any message in the response of the failing http request ?

Also, these kind of random errors reminds me that on some Windows development stacks (Laragon/Wamp/Xampp), I often encounter issues when multiple requests are made simultaneously. If you are using a combination of Windows and Apache's mod_php module, this is likely to cause trouble at some point. If you are in this situation, do you have a Linux server to try with ?

Hi, thanks so much for your speedy response, really appreciate it.

The error seems to be thrown inside framework-bundlemin.js:
image

In the error log, I see the following:

Error: Call to a member function getDirName() on null in /var/www/vhosts/domain.com/httpdocs/modules/cms/classes/CmsObject.php:190
Stack trace:
#0 /var/www/vhosts/domain.com/httpdocs/modules/cms/classes/CmsObject.php(129): Cms\Classes\CmsObject::inTheme()
#1 /var/www/vhosts/domain.com/httpdocs/plugins/rainlab/pages/classes/SnippetManager.php(231): Cms\Classes\CmsObject::listInTheme()
#2 /var/www/vhosts/domain.com/httpdocs/plugins/rainlab/pages/classes/SnippetManager.php(35): RainLab\Pages\Classes\SnippetManager->listThemeSnippets()
#3 /var/www/vhosts/domain.com/httpdocs/plugins/inetis/richeditorsnippets/routes.php(15): RainLab\Pages\Classes\SnippetManager->listSnippets()
#4 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/CallableDispatcher.php(40): System\Classes\PluginManager->{closure}()
#5 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Route.php(237): Illuminate\Routing\CallableDispatcher->dispatch()
#6 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Route.php(208): Illuminate\Routing\Route->runCallable()
#7 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(798): Illuminate\Routing\Route->run()
#8 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#9 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#10 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Routing\Middleware\SubstituteBindings->handle()
#11 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#12 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#13 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#14 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest()
#15 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Session\Middleware\StartSession->handle()
#16 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#17 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#18 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#19 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Cookie\Middleware\EncryptCookies->handle()
#20 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#21 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(799): Illuminate\Pipeline\Pipeline->then()
#22 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(776): Illuminate\Routing\Router->runRouteWithinStack()
#23 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Routing/Router.php(740): Illuminate\Routing\Router->runRoute()
#24 /var/www/vhosts/domain.com/httpdocs/vendor/october/rain/src/Router/CoreRouter.php(32): Illuminate\Routing\Router->dispatchToRoute()
#25 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(190): October\Rain\Router\CoreRouter->dispatch()
#26 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#27 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#28 /var/www/vhosts/domain.com/httpdocs/vendor/october/rain/src/Foundation/Http/Middleware/CheckForMaintenanceMode.php(23): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
#29 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): October\Rain\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#30 /var/www/vhosts/domain.com/httpdocs/plugins/vdlp/redirect/classes/RedirectMiddleware.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#31 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Vdlp\Redirect\Classes\RedirectMiddleware->handle()
#32 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#33 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\Pipeline\Pipeline->then()
#34 /var/www/vhosts/domain.com/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(134): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#35 /var/www/vhosts/domain.com/httpdocs/index.php(43): Illuminate\Foundation\Http\Kernel->handle()
#36 {main}

The site is on a staging environment on a Linux server (not locally served), with nginx and FastCGI.

In my multisite setup, I'm using one global theme (which I make changes to) and two child themes. The subsites each have a different child theme. Maybe that is causing the issue.

I could send over backend credentials if you wish (as it's just a testing environment at the moment)... Which email could I send it to if you'd like that?

Just wanted to let you know that the issue persists if I disable the nested repeater based pagebuilder. I guess it has to something to do with the child themes that differ between sites...

commented

Ok, thank you for the info. Doing a bit of digging into this, I could reproduce the issue and it is as you suggested because of the multisite.

According the stacktrace, the theme we provide to the SnippetManager is null. The only way for this to occur is to have a theme set in the config cms.active_theme but no theme with that name installed (maybe there is a reason why, but it seems me weird that October does not throw an exception about that).
In your case, I assume that you have this config set to the default demo value but you have uninstalled the demo theme, which is causing this error.

Anyway, the multisite support was broken because we were always using the default theme from the config, so people using theme partials as snippets (if there is any) were not seeing the right ones. So I've made a fix in the new 2.1.10 version to address this.

Thanks so much for the great support. This solves it for me. Thanks!