Problem/Motivation

Views Natural Sort causes HTTP errors when uploading files or running AJAX processes on a Drupal 11 site.

Steps to reproduce

Drupal 11 site with Views Natural Sort installed and configured on at least one view.

Navigate to Administration > Structure > Views > Views Settings > View Natural Sort Configuration.

Select In case of Emergency > Rebuild Index.

This can also be reproduced when uploading files or running AJAX operations unrelated to Views Natural Sort. This AJAX HTTP error prevents these operations from completing. When Views Natural Sort is uninstalled, no errors occur.

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=98&op=do_nojs&op=do
StatusText: error
ResponseText: The website encountered an unexpected error. Try again later.TypeError: Cannot access offset of type array on array in Drupal\Core\Database\Query\Merge->key() (line 331 of core/lib/Drupal/Core/Database/Query/Merge.php). Drupal\views_natural_sort\IndexRecord->save() (Line: 329)
Drupal\views_natural_sort\ViewsNaturalSortService->storeIndexRecordsFromEntity(Object) (Line: 61)
Drupal\views_natural_sort\Plugin\QueueWorker\EntityIndexer->processItem(Array) (Line: 210)
views_natural_sort_rebuild_index('views_natural_sort_entity_index', Array) (Line: 297)
_batch_process() (Line: 139)
_batch_do() (Line: 95)
_batch_page(Object) (Line: 52)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 44)
Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
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

caldenjacobs created an issue. See original summary.

caldenjacobs’s picture

Issue summary: View changes
caldenjacobs’s picture

Issue summary: View changes
caldenjacobs’s picture

Title: TypeError: Cannot access offset of type array on array in Drupal\Core\Database\Query\Merge->key() (line 331 of core/lib/Drupal/Core/Database/Query/Merge.php). » Array support removed from function Merge::keys in Drupal 11

Update issue name

caldenjacobs’s picture

Title: Array support removed from function Merge::keys in Drupal 11 » Array support removed from function Merge::key in Drupal 11
caldenjacobs’s picture

Status: Active » Needs review
StatusFileSize
new779 bytes
byrond’s picture

We were getting the following error just trying to enable this module on a Drupal 11 site:

Unable to decode output into JSON: Syntax error                              
                                                                               
  AssertionError: assert(is_string($field)) in assert() (line 330 of /var/www  
  /html/web/core/lib/Drupal/Core/Database/Query/Merge.php).                    

Installing the patch here fixes that issue.

kushagra.goyal made their first commit to this issue’s fork.

mark_fullmer’s picture

I can confirm that the patch in #6 resolves the issue.

joelpittet changed the visibility of the branch 3500675-array-support-removed to hidden.

joelpittet’s picture

Version: 8.x-2.0-alpha9 » 8.x-2.x-dev

joelpittet’s picture

Status: Needs review » Fixed

Thank you all for fixing that issue and making this work with Drupal 11!

Status: Fixed » Closed (fixed)

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