Undefined array key "back_to_top_speed" in back_to_top_page_attachments()

Created on 18 October 2024, 3 months ago

After upgrade to 3.0.1 I get the following error:

Warning: Undefined array key "back_to_top_speed" in back_to_top_page_attachments() (line 35 of /app/web/modules/contrib/back_to_top/back_to_top.module)

#0 /app/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real(2, 'Undefined array...', '/app/web/module...', 35)
#1 /app/web/modules/contrib/back_to_top/back_to_top.module(35): _drupal_error_handler(2, 'Undefined array...', '/app/web/module...', 35)
#2 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(311): back_to_top_page_attachments(Array)
#3 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}(Object(Closure), 'back_to_top')
#4 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(308): Drupal\Core\Extension\ModuleHandler->invokeAllWith('page_attachment...', Object(Closure))
#5 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(285): Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array)
#6 /app/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#7 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(284): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#8 /app/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#9 /app/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#10 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#11 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#12 /app/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#13 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /app/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /app/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#27 {main}

๐Ÿ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States adrianm6254

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @adrianm6254
  • ๐Ÿ‡ธ๐Ÿ‡ชSweden acke

    The warning will disappear if you add a value at:
    /admin/config/user-interface/back_to_top

    But I think this update hook should set a default value, but it don't seem to work:

    /**
     * Implements hook_update_N().
     * 
     * Add default value to the speed config field.
     */
    function back_to_top_update_91001() {
      $config = \Drupal::configFactory()->getEditable('back_to_top.settings');
      $config->set('back_to_top_speed', 1200);
      $config->save();
    }
    

    Fortunately there is a default in the javascript so it does not bug out and at installation the value is set via yml.

    Any ideas why the update hook is not working? Otherwise, it may just be a matter of adding an empty check to that particular line of code and accepting that the field is empty initially when updating

    • acke โ†’ committed 04822e8a on 3.0.x
      Issue #3481821 by acke, adrianm6254: Undefined array key "...
  • ๐Ÿ‡ธ๐Ÿ‡ชSweden acke

    Okay, the code was correct but should be in back_to_top.install. Thanks to Peter Tรถrnstrand for the information.

    Numbering the hook is quite tricky but it works for me.

    This will go into a 3.0.2 release next week.

  • ๐Ÿ‡ธ๐Ÿ‡ชSweden acke
  • ๐Ÿ‡ช๐Ÿ‡ธSpain Carlos Romero

    carlos romero โ†’ made their first commit to this issueโ€™s fork.

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

  • ๐Ÿ‡ช๐Ÿ‡ธSpain alvolvfdez

    If you come from a previous version and you already have the module installed, the hook install will not be launched. For this you have to uninstall and reinstall the module.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Ben25

    If uninstalling the module is not possible. Simply go to `admin/config/user-interface/back_to_top` input speed (or not) and hit save.

    The error shows it was looking for the speed...

Production build 0.71.5 2024