I'm getting a javascript error "class statement requires a name" when looking at /admin/content

this function is shown in the browser:
(function(e,i){'use strict';i.behaviors.views_bulk_operations={attach:function(e,t){once('vbo-init','.vbo-view-form',e).forEach(i.viewsBulkOperationsFrontUi)}};class;viewsBulkOperationsSelection{constructor(vbo_form){this.vbo_form=vbo_form;this.$actionSelect=e('select[name="action"]',vbo_form);this.view_id='';this.display_id='';this.$summary=null};bindEventHandlers($element,index){if($element.length){var t=this;$element.on('keypress',function(i){if(i.which===13){i.preventDefault();i.stopPropagation();t.update(!this.checked,index,e(this).val());e(this).trigger('click')};if(i.which===32){t.update(!this.checked,index,e(this).val())}});$element.on('click',function(i){if(i.which===1){t.update(this.checked,index,e(this).val())}})}};bindCheckboxes(){var t=this,f=e('.form-checkbox',this.vbo_form);f.on('change',function(e){t.toggleButtonsState()})};toggleButtonsState(){var r=e('.form-checkbox:checked',this.vbo_form),l=e('[id^="edit-actions"] input[type="submit"], [id^="edit-actions"] button[type="submit"]',this.vbo_form),v=e('.vbo-info-list-wrapper li',this.vbo_form),s=v.length||r.length;if(this.$actionSelect.length){var d=s&&this.$actionSelect.val()!=='';l.prop('disabled',!d)}

Drupal 9.4.6 with PHP 7.4

Comments

manarak created an issue. See original summary.

graber’s picture

Status: Active » Postponed (maintainer needs more info)

Please provide steps to reproduce.

drupaldope’s picture

I didn't do anything special, except update VBO to the latest version (using composer).

The problem went away when I downgraded back to 4.1.3

Happy to provide any further info you require.

graber’s picture

  1. Which browser are you using?
  2. On what page do you see the error?
  3. Are you using any js compression modules? If so, can you disable them and see if the error persists?
drupaldope’s picture

1. it happens on Firefox's and Chrome's newest version
2. the error occurs on the page /admin/content as described. the buttons on the right of the content (edit,duplicate,etc.) are not rendered properly
3. I first tested with core aggregation turned off. the buttons were rendered properly, but an error "Uncaught SyntaxError: Unexpected token ';' " appeared.
then I tested with both core aggregation and advagg off, and there was no error.

the error disappears when advagg is off.

graber’s picture

Interesting. Can you create an issue on advagg module? Let's hope its maintainers will be able to provide some more information on how can we solve this.

graber’s picture

I don't use advagg, but try something like

  let viewsBulkOperationsSelection = class {

with a semicolon after the class closing "}" instead, maybe advagg will not break it.

If it'll work patch welcome.

drupaldope’s picture

I'm still trying to nail the error, I also spotted this in my php error log, maybe it's related ?

[30-Sep-2022 01:58:06 Asia/Bangkok] Error: Call to a member function hasTranslation() on null in C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\ContentEntityBase.php on line 1431 #0 C:\wamp64\www\mywebsite\web\modules\contrib\entity_reference_revisions\src\Plugin\Field\FieldType\EntityReferenceRevisionsItem.php(272): Drupal\Core\Entity\ContentEntityBase->hasTranslationChanges()
#1 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Field\FieldItemList.php(233): Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem->preSave()
#2 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Field\FieldItemList.php(191): Drupal\Core\Field\FieldItemList->delegateMethod('preSave')
#3 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\ContentEntityStorageBase.php(941): Drupal\Core\Field\FieldItemList->preSave()
#4 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\ContentEntityStorageBase.php(891): Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('preSave', Object(Drupal\node\Entity\Node))
#5 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\EntityStorageBase.php(563): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object(Drupal\node\Entity\Node))
#6 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\ContentEntityStorageBase.php(756): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\node\Entity\Node))
#7 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\EntityStorageBase.php(517): Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object(Drupal\node\Entity\Node))
#8 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php(802): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\node\Entity\Node))
#9 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Entity\EntityBase.php(339): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\node\Entity\Node))
#10 C:\wamp64\www\mywebsite\web\modules\contrib\views_bulk_operations\src\Plugin\Action\EntityDeleteAction.php(28): Drupal\Core\Entity\EntityBase->save()
#11 C:\wamp64\www\mywebsite\web\modules\contrib\views_bulk_operations\src\Action\ViewsBulkOperationsActionBase.php(69): Drupal\views_bulk_operations\Plugin\Action\EntityDeleteAction->execute(Object(Drupal\node\Entity\Node))
#12 C:\wamp64\www\mywebsite\web\modules\contrib\views_bulk_operations\src\Service\ViewsBulkOperationsActionProcessor.php(483): Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase->executeMultiple(Array)
#13 C:\wamp64\www\mywebsite\web\modules\contrib\views_bulk_operations\src\ViewsBulkOperationsBatch.php(106): Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor->process()
#14 C:\wamp64\www\mywebsite\web\core\includes\batch.inc(295): Drupal\views_bulk_operations\ViewsBulkOperationsBatch::operation(Array, Array)
#15 C:\wamp64\www\mywebsite\web\core\includes\batch.inc(137): _batch_process()
#16 C:\wamp64\www\mywebsite\web\core\includes\batch.inc(93): _batch_do()
#17 C:\wamp64\www\mywebsite\web\core\modules\system\src\Controller\BatchController.php(55): _batch_page(Object(Symfony\Component\HttpFoundation\Request))
#18 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request))
#19 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#20 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\Render\Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#21 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#22 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#23 C:\wamp64\www\mywebsite\vendor\symfony\http-kernel\HttpKernel.php(159): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#24 C:\wamp64\www\mywebsite\vendor\symfony\http-kernel\HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#25 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\StackMiddleware\Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(48): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 C:\wamp64\www\mywebsite\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 C:\wamp64\www\mywebsite\web\core\lib\Drupal\Core\DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 C:\wamp64\www\mywebsite\web\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#32 {main}
jeslin.shaji’s picture

StatusFileSize
new471 bytes

I upgraded the module from 4.1.4 to 4.2.0 and got an error similar to #5 - "Uncaught SyntaxError: Unexpected token ';' "
I am also using advagg.
Adding a patch as mentioned by @Graber. This fixed the issue for me.

jeslin.shaji’s picture

Status: Postponed (maintainer needs more info) » Needs review
graber’s picture

Nice, thank you 🥳

If anyone else can test this we can get this to the next release.

Also created this issue in advagg, so they know class declarations are causing issues and will maybe help to find the correct approach if this is not it..

graber’s picture

Title: Javascript syntax error » Javascript syntax error when using advagg
rtdean93’s picture

This patch worked for me. Core 9.4.8. PHP 8.1

dineshreddymathuku’s picture

#9 patch is looks good for me core 9.4.7 Php 8.1
Thanks

graber’s picture

Version: 4.1.5 » 4.2.x-dev
Status: Needs review » Fixed

Fixed in 4.2.x, thank you.

  • Graber committed 399fed4 on 4.2.x
    Issue #3311881 by Jeslin.Shaji, Graber, manarak, dineshreddymathuku,...

Status: Fixed » Closed (fixed)

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

thidd’s picture

I think would be nice to create a release for this change.

graber’s picture

True, unfortunately I'm very bust currently and it's not the only thing there'll be to release. There's usually a Christmas release so I think it'll be then the latest. Santa Graber will come ;)