- Issue created by @cboyden
- Status changed to Needs review
4 months ago 3:22pm 23 July 2024 - πΊπΈUnited States dsnopek USA
Here's a patch that fixes this in my limited testing - please let me know if it works for you!
And here's a test build which will hopefully show no regressions: https://gitlab.com/dsnopek/panopoly/-/jobs/7408713134
- Status changed to Needs work
4 months ago 11:33pm 23 July 2024 - πΊπΈUnited States cboyden
The patch fixes things when the operator is not exposed, but if it's exposed, there are JS errors in the console. It looks like the states that control the appearance of the single date field vs. the min/max fields used for Between operators are broken.
Steps to reproduce:
- Download the latest version of Panopoly 3.0.x and apply the patch.
- Install the site with demo content.
- Log in as an administrator.
- Create a new Content page.
- Edit the Panopoly Demo view to add an exposed date filter: Filter on the Authored On date of the content item. Choose the operator "greater or equal" as the default. Also expose the operator.
- Save the view.
- In the Views UI preview, set the exposed sorts to Post date, Desc. You should see your new content item at the top of the list, followed by 2 of the 3 demo items.
- Change the operator in the Views UI preview to "Is between."
- Note the single date field disappears and is replaced by a set of Min and Max fields.
- In the Min filter field, enter the date "2024-06-01"; in the Max filter field, enter "2024-08-01" (or a date later than today's) and click Apply.
- Because the authored on dates of the demo content are quite old (2012), you will only see the item you just created in the preview. This is the expected behavior.
- Save the View.
- Clear caches.
- Create a new Landing page.
- Customize the page, adding the Demo view to the layout.
- Make sure the operator dropdown shows "Is greater than"
- Note the "Authored on" fieldset shows the operator dropdown and also three fields: one unlabeled, one labeled Min, and one labeled Max.
- Open the browser's JS console.
- In the block config, change the Sort order control back and forth between Ascending and Descending a few times.
- Note there is a JS error in the console each time you change the sort order.
- Change the operator to "Is between."
- Clear the browser JS console.
- In the block config, change the Sort order control back and forth between Ascending and Descending a few times.
- Note there are no JS errors this time.
- Note there is no content displayed in the Preview.
- In the Min filter field, enter the date "2024-06-01"; in the Max filter field, enter "2024-08-01" (or a date later than today's) and click Preview.
- Note there is still no content displayed in the Preview.
The JS error is:
message: "An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /layout_builder/add/block/overrides/node.6/0/contentmain/views_block%3Apanopoly_demo-demo_listing?_wrapper_format=drupal_dialog&ajax_form=1 StatusText: parsererror ResponseText: TypeError: strtotime(): Argument #1 ($datetime) must be of type string, array given in strtotime() (line 185 of /var/www/html/web/core/modules/views/src/Plugin/views/filter/Date.php)." name: "AjaxError" stack: "Error at https://panopoly.localhost/core/misc/ajax.js?v=10.3.0:196:32 at https://panopoly.localhost/core/misc/ajax.js?v=10.3.0:1921:3"
- πΊπΈUnited States cboyden
See screenshot of fieldset with three date fields where only one should be available:
- Status changed to Needs review
4 months ago 3:22pm 26 July 2024 - Status changed to Needs work
4 months ago 4:44pm 26 July 2024 - πΊπΈUnited States cboyden
The latest patch fixes the states and the JS error, but there's one more thing. Depending on which operator is chosen, the view is filtered, but I wouldn't expect any filter to take effect until you enter a date.
Steps to reproduce:
- Download the latest version of Panopoly 3.0.x and apply the latest patch.
- Install the site with demo content.
- Log in as an administrator.
- Edit the Panopoly Demo view to add an exposed date filter: Filter on the Authored On date of the content item. Choose the operator "Is less than" as the default. Also expose the operator.
- Save the view.
- In the Views UI preview, note that there are three items displayed.
- Change the operator in the Views UI preview to "Is between" and click Apply.
- Note that there are still three items displayed. This is the expected behavior; you haven't entered a date for the filter, so all content is still showing.
- Clear caches.
- Create a new Landing page.
- Customize the page, adding the Demo view to the layout.
- Make sure the operator dropdown shows "Is less than."
- Note the preview shows no items.
- Change the operator to "Is greater than."
- Note the preview shows 3 items.
- Change the operator to "Is less than or equal to."
- Note the preview shows no items.
- Save the block and save the layout.
- Note there are no items displayed in the view.
Expected behavior: Regardless of the operator dropdown, the block preview should show all otherwise-unfiltered items until the editor puts in their date(s).
- Status changed to Needs review
4 months ago 8:54pm 30 July 2024 - Status changed to Needs work
4 months ago 5:20pm 2 August 2024 - πΊπΈUnited States cboyden
I think this is almost there. When following the steps in #6 while using the previous patch, the initial preview in the choose block dialog and in the configure dialog doesn't show any items. When you make any change to the config that causes preview to fire again, the items display as expected.
Starting just after step 10 above:
- Click the Layout tab.
- Click Add block.
- Select the Demo category.
- Click List of demo items, to show the preview in the "Choose a block" dialog.
- Note there are no items displayed.
- Click Add.
- In the Configure dialog preview, note there are no items displayed.
- Select the "Featured" radio button from the "View mode" section.
- Note there are three items displayed in the preview.
- πΊπΈUnited States cboyden
Also, there are a bunch of PHP warnings in the log.
For example:
Warning: Undefined array key "created_op" in Drupal\views\Plugin\views\filter\Date->acceptExposedInput() (line 144 of /var/www/html/web/core/modules/views/src/Plugin/views/filter/Date.php) #0 /var/www/html/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/w...', 144) #1 /var/www/html/web/core/modules/views/src/Plugin/views/filter/Date.php(144): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/w...', 144) #2 /var/www/html/web/profiles/contrib/panopoly/modules/panopoly/panopoly_magic/src/Plugin/views/display/MagicBlock.php(626): Drupal\views\Plugin\views\filter\Date->acceptExposedInput(Array) #3 /var/www/html/web/profiles/contrib/panopoly/modules/panopoly/panopoly_magic/src/Plugin/Block/MagicViewsBlock.php(21): Drupal\panopoly_magic\Plugin\views\display\MagicBlock->preBlockBuild(Object(Drupal\panopoly_magic\Plugin\Block\MagicViewsBlock)) #4 /var/www/html/web/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php(106): Drupal\panopoly_magic\Plugin\Block\MagicViewsBlock->build() #5 [internal function]: Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #6 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #7 /var/www/html/web/core/modules/layout_builder/src/SectionComponent.php(90): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...') #8 /var/www/html/web/modules/contrib/page_manager/src/Plugin/DisplayVariant/LayoutBuilderDisplayVariant.php(107): Drupal\layout_builder\SectionComponent->toRenderArray(Array, false) #9 /var/www/html/web/modules/contrib/page_manager/src/Entity/PageVariantViewBuilder.php(29): Drupal\page_manager\Plugin\DisplayVariant\LayoutBuilderDisplayVariant->build() #10 /var/www/html/web/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php(134): Drupal\page_manager\Entity\PageVariantViewBuilder->view(Object(Drupal\page_manager\Entity\PageVariant), 'full') #11 [internal function]: Drupal\Core\Entity\Controller\EntityViewController->view(Object(Drupal\page_manager\Entity\PageVariant), 'full') #12 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #13 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #14 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #15 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #16 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #17 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #29 {main}
There are 4 other PHP warnings about the same function
Drupal\views\Plugin\views\filter\Date->acceptExposedInput()
, and then there's a deprecated function notice:Deprecated function: strtotime(): Passing null to parameter #1 ($datetime) of type string is deprecated in Drupal\views\Plugin\views\filter\Date->opSimple() (line 185 of /var/www/html/web/core/modules/views/src/Plugin/views/filter/Date.php) #0 /var/www/html/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real(8192, 'strtotime(): Pa...', '/var/www/html/w...', 185) #1 [internal function]: _drupal_error_handler(8192, 'strtotime(): Pa...', '/var/www/html/w...', 185) #2 /var/www/html/web/core/modules/views/src/Plugin/views/filter/Date.php(185): strtotime(NULL, 0) #3 /var/www/html/web/core/modules/views/src/Plugin/views/filter/NumericFilter.php(339): Drupal\views\Plugin\views\filter\Date->opSimple('node_field_data...') #4 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1432): Drupal\views\Plugin\views\filter\NumericFilter->query(false) #5 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1321): Drupal\views\ViewExecutable->_build('filter') #6 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1450): Drupal\views\ViewExecutable->build(NULL) #7 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1513): Drupal\views\ViewExecutable->execute(NULL) #8 /var/www/html/web/core/modules/views/src/Plugin/views/display/Block.php(133): Drupal\views\ViewExecutable->render() #9 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1689): Drupal\views\Plugin\views\display\Block->execute() #10 /var/www/html/web/core/modules/views/src/Element/View.php(81): Drupal\views\ViewExecutable->executeDisplay('demo_listing', Array) #11 /var/www/html/web/profiles/contrib/panopoly/modules/panopoly/panopoly_magic/src/Plugin/Block/MagicViewsBlock.php(78): Drupal\views\Element\View::preRenderViewElement(Array) #12 /var/www/html/web/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php(106): Drupal\panopoly_magic\Plugin\Block\MagicViewsBlock->build() #13 [internal function]: Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #14 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #15 /var/www/html/web/core/modules/layout_builder/src/SectionComponent.php(90): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...') #16 /var/www/html/web/modules/contrib/page_manager/src/Plugin/DisplayVariant/LayoutBuilderDisplayVariant.php(107): Drupal\layout_builder\SectionComponent->toRenderArray(Array, false) #17 /var/www/html/web/modules/contrib/page_manager/src/Entity/PageVariantViewBuilder.php(29): Drupal\page_manager\Plugin\DisplayVariant\LayoutBuilderDisplayVariant->build() #18 /var/www/html/web/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php(134): Drupal\page_manager\Entity\PageVariantViewBuilder->view(Object(Drupal\page_manager\Entity\PageVariant), 'full') #19 [internal function]: Drupal\Core\Entity\Controller\EntityViewController->view(Object(Drupal\page_manager\Entity\PageVariant), 'full') #20 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #21 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #22 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #23 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #24 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #25 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #31 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #32 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #33 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #34 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #35 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #36 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #37 {main}
- Status changed to Needs review
3 months ago 9:42pm 14 August 2024 - πΊπΈUnited States dsnopek USA
Here's a patch that I think should fix the PHP warnings.
However, related to this bit:
When following the steps in #6 while using the previous patch, the initial preview in the choose block dialog and in the configure dialog doesn't show any items. When you make any change to the config that causes preview to fire again, the items display as expected.
Unfortunately, I wasn't able to reproduce this: I'm seeing the preview with items in the choose block dialog, and in the configure dialog before making any changes.
- πΊπΈUnited States cboyden
Thanks, the patch is working and not creating any PHP notices. There is some extra stuff in it though, there are some panopoly_media files included in the patch.
- Status changed to RTBC
3 months ago 8:08pm 15 August 2024 - πΊπΈUnited States dsnopek USA
There is some extra stuff in it though, there are some panopoly_media files included in the patch.
Eep! Sorry about that. It looks like some changes related to #3467225: Switch back to checkboxes on media library β snuck in there.
Here's a clean patch.
-
dsnopek β
committed 5039fca1 on 3.0.x
Issue #3457964: Date filters on Views don't work
-
dsnopek β
committed 5039fca1 on 3.0.x
- Status changed to Fixed
3 months ago 8:15pm 15 August 2024 Automatically closed - issue fixed for 2 weeks with no activity.