Overview

@hooroomoo reported this bug in #3519634-16: Modifying a XB config entity's `status` or `label` should update the auto-save entry too, rather than delete it

  1. Create and add a code component to your library (using top right Add to components button in code editor)
  2. Add component to your page preview
  3. Make an edit to the code from the library
  4. Exit out of the code editor
  5. All the styling (CSS) is gone from the component in the page preview.

They where getting this error in the logs

Warning: file_get_contents(xb/api/auto-saves/css/js_component/foo1): Failed to open stream: No such file or directory in Drupal\system\Controller\CssAssetController->generateHash() (line 43 of /var/www/html/web/core/lib/Drupal/Core/Asset/AssetGroupSetHashTrait.php)
#0 /var/www/html/web/core/includes/bootstrap.inc(108): _drupal_error_handler_real()
#1 [internal function]: _drupal_error_handler()
#2 /var/www/html/web/core/lib/Drupal/Core/Asset/AssetGroupSetHashTrait.php(43): file_get_contents()
#3 /var/www/html/web/core/modules/system/src/Controller/AssetControllerBase.php(184): Drupal\system\Controller\CssAssetController->generateHash()
#4 [internal function]: Drupal\system\Controller\AssetControllerBase->deliver()
#5 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#6 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#8 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#9 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#11 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#12 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#14 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#15 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#16 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#19 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#21 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#22 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#23 {main}

xb/api/auto-saves/css/js_component/foo1 is the auto-save URL we put in .draft library we create in experience_builder_library_info_build()

Turning off CSS aggregation fixes the problem

Proposed resolution

I don't know this part of core well but I think setting preprocess = false for the draft css auto-save requests might work.

User interface changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Assigned: Unassigned » tedbow

going to give it a try

tedbow’s picture

Issue summary: View changes

tedbow’s picture

Assigned: tedbow » Unassigned
Status: Active » Needs work
Issue tags: +Needs tests

Manually testing this fixes the problem. I only test with adding global CSS and it also fixes the similar problem in 0.x

Not sure if there is a better way to solve this but it seems logical that the .draft libraries where the CSS and JS files point to URL that dynamically send back the contents should not be aggregated.

Unassigning myself since it I am not working on it. I see a couple tests that have @covers \experience_builder_library_info_build() we should probably up them to assert the preprocess change(if that is indeed the correct fix

wim leers’s picture

Great find! Thanks for doing all that detective work together! 🙏

MR looks solid, too — preprocess: FALSE is the only sane approach I can think of.

I'd personally be fine with deferring test coverage to #3520484: [META] Production-ready ComponentSource plugins, because this seems like such an obvious fix. Plus, it's safe: I don't see how this could introduce regressions. RTBC'ing to reflect that.

  • wim leers committed 54c816bf on 0.x authored by tedbow
    Issue #3521072 by tedbow, hooroomoo, wim leers: Auto-saved Javascript...
wim leers’s picture

Component: Page builder » Theme builder
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs tests

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.