An error has occurred. 0 Call to undefined method Joomla\Event\Dispatcher::regis

Started by extonjaez, June 01, 2023, 15:21:33 PM

Previous topic - Next topic

extonjaez

Hello

I have this error with VM 4.22 or 4.20

An error has occurred.
0 Call to undefined method Joomla\Event\Dispatcher::register()

I use LITESPEED and error happens when i enable "LiteSpeed Cache" Plugin

Thanks for your help
Arnaud

System Information
com_virtuemart.4.0.22.10864_package
PHP Built On Linux s22095112 4.19.0-17-amd64 #1 SMP Debian 4.19.194-2 (2021-06-21) x86_64
Database Type mysql
Database Version 10.3.38-MariaDB-0+deb10u1
Database Collation utf8mb4_general_ci
Database Connection Collation utf8mb4_general_ci
Database Connection Encryption None
Database Server Supports Connection Encryption No
PHP Version 8.2.6
Web Server LiteSpeed
WebServer to PHP Interface litespeed
Joomla! Version Joomla! 4.2.9 Stable [ Uaminifu ] 14-March-2023 15:00 GMT
User Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36

extonjaez

WITH DEBUG AND ERRORS TO MAXIMUM

Call to undefined method Joomla\Event\Dispatcher::register()
.../plugins/system/lscache/components/com_virtuemart.php:15
10 class LSCacheComponentVirtueMart extends LSCacheComponentBase
11 {
12
13 public function onRegisterEvents()
14 {
15 $this->dispatcher->register("plgVmOnAddToCart", $this);
16 $this->dispatcher->register("plgVmOnRemoveFromCart", $this);
17 $this->dispatcher->register("plgVmOnUpdateCart", $this);
18 $this->dispatcher->register("plgVmAfterStoreProduct", $this);
19 $this->dispatcher->register("plgVmOnDeleteProduct", $this);
20 $this->dispatcher->register("plgVmAfterVendorStore", $this);
LSCacheComponentVirtueMart->onRegisterEvents()
LSCacheComponentsHelper->registerEvents()
plgSystemLSCache->onAfterRoute()
Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}()
Joomla\Event\Dispatcher->dispatch()
Joomla\CMS\Application\WebApplication->triggerEvent()
Joomla\CMS\Application\AdministratorApplication->route()
Joomla\CMS\Application\AdministratorApplication->doExecute()
Joomla\CMS\Application\CMSApplication->execute()
require_once()
LSCacheComponentVirtueMart->onRegisterEvents()
.../plugins/system/lscache/components/helper.php:89
84 if($com_name!=null){
85 $com_instance = $this->getInstance($com_name);
86 if($com_instance==null){
87 return;
88 }
89 $com_instance->onRegisterEvents();
90 }
91 }
92
93 public function onPurgeContent($com_name, $context, $row){
94 $com_instance = $this->getInstance($com_name);
LSCacheComponentsHelper->registerEvents()
.../plugins/system/lscache/lscache.php:161
156 //$this->debug(__FUNCTION__ . var_export($this->pageElements,true));
157
158
159 if (isset($this->pageElements["option"])) {
160 $option = $this->pageElements["option"];
161 $this->componentHelper->registerEvents($option);
162 } else {
163 $this->pageCachable = false;
164 return;
165 }
166
plgSystemLSCache->onAfterRoute()
.../libraries/src/Plugin/CMSPlugin.php:279
274 }
275
276 // Convert to indexed array for unpacking.
277 $arguments = \array_values($arguments);
278
279 $result = $this->{$methodName}(...$arguments);
280
281 // Ignore null results
282 if ($result === null) {
283 return;
284 }
Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}()
.../libraries/vendor/joomla/event/src/Dispatcher.php:486
481 if ($event->isStopped())
482 {
483 return $event;
484 }
485
486 $listener($event);
487 }
488 }
489
490 return $event;
491 }
Joomla\Event\Dispatcher->dispatch()
.../libraries/src/Application/EventAware.php:107
102 $event = new $className($eventName, $args);
103 } else {
104 throw new \InvalidArgumentException('The arguments must either be an event or an array');
105 }
106
107 $result = $dispatcher->dispatch($eventName, $event);
108
109 // @todo - There are still test cases where the result isn't defined, temporarily leave the isset check in place
110 return !isset($result['result']) || \is_null($result['result']) ? [] : $result['result'];
111 }
112 }
Joomla\CMS\Application\WebApplication->triggerEvent()
.../libraries/src/Application/AdministratorApplication.php:446
441
442 $this->isHandlingMultiFactorAuthentication();
443
444 // Trigger the onAfterRoute event.
445 PluginHelper::importPlugin('system');
446 $this->triggerEvent('onAfterRoute');
447 }
448
449 /**
450 * Return the application option string [main component].
451 *
Joomla\CMS\Application\AdministratorApplication->route()
.../libraries/src/Application/AdministratorApplication.php:171
166
167 // Mark afterInitialise in the profiler.
168 JDEBUG ? $this->profiler->mark('afterInitialise') : null;
169
170 // Route the application
171 $this->route();
172
173 // Mark afterRoute in the profiler.
174 JDEBUG ? $this->profiler->mark('afterRoute') : null;
175
176 /*
Joomla\CMS\Application\AdministratorApplication->doExecute()
.../libraries/src/Application/CMSApplication.php:294
289 $this->sanityCheckSystemVariables();
290 $this->setupLogging();
291 $this->createExtensionNamespaceMap();
292
293 // Perform application routines.
294 $this->doExecute();
295
296 // If we have an application document object, render it.
297 if ($this->document instanceof \Joomla\CMS\Document\Document) {
298 // Render the application output.
299 $this->render();
Joomla\CMS\Application\CMSApplication->execute()
.../administrator/includes/app.php:61
56
57 // Set the application as global app
58 \Joomla\CMS\Factory::$application = $app;
59
60 // Execute the application.
61 $app->execute();
require_once()
.../administrator/index.php:32
27 * define() is used rather than "const" to not error for PHP 5.2 and lower
28 */
29 define('_JEXEC', 1);
30
31 // Run the application - All executable code should be triggered through this file
32 require_once dirname(__FILE__) . '/includes/app.php';
Arguments
0
string(79) "/var/www/vhosts/xxx/httpdocs/xxx/administrator/includes/app.php"

Ghost

LS Cache plugin is not compatible with Joomla 4. This issue has been fixed in codebase but no release has been made yet. There is a "latest" package available containing latest fixes but it should not be used in production. Use at your own risk https://github.com/litespeedtech/lscache-joomla/blob/master/Joomla4/package/lscache-latest.zip.

extonjaez

Hello

Ok, I will try this latest Litespeed plugin version you gave me the Github link

Thanks for your help
Best regards
Arnaud

extonjaez

With this latest version, i have this error


Too few arguments to function LSCacheComponentVirtueMart::onContentPrepare(), 1 passed in /var/www/vhosts/xxx/httpdocs/xxx/libraries/vendor/joomla/event/src/Dispatcher.php on line 486 and at least 3 expected
.../plugins/system/lscache/components/com_virtuemart.php:284
279         }
280         return $comUrls;
281     }
282     
283     
284     public function onContentPrepare($context, &$row, &$params, $page = 0) {
285         $productModel = VmModel::getModel('Product');
286         $total = $productModel->getTotal();
287         $limitstart = $productModel->_limitStart;
288         $limit = $productModel->_limit;
289         $app = JFactory::getApplication();
LSCacheComponentVirtueMart->onContentPrepare()
Joomla\Event\Dispatcher->dispatch()
Joomla\CMS\Application\WebApplication->triggerEvent()
vDispatcher::trigger()
shopFunctionsF::triggerContentPlugin()
VirtuemartViewCategory->display()
VirtueMartControllerCategory->display()
Joomla\CMS\MVC\Controller\BaseController->execute()
require_once()
Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}()
Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch()
Joomla\CMS\Component\ComponentHelper::renderComponent()
Joomla\CMS\Application\SiteApplication->dispatch()
Joomla\CMS\Application\SiteApplication->doExecute()
Joomla\CMS\Application\CMSApplication->execute()
require_once()
LSCacheComponentVirtueMart->onContentPrepare()
.../libraries/vendor/joomla/event/src/Dispatcher.php:486
481             if ($event->isStopped())
482             {
483                return $event;
484             }
485
486             $listener($event);
487          }
488       }
489
490       return $event;
491    }
Joomla\Event\Dispatcher->dispatch()
.../libraries/src/Application/EventAware.php:111
106             $event     = new $className($eventName, $args);
107         } else {
108             throw new \InvalidArgumentException('The arguments must either be an event or an array');
109         }
110
111         $result = $dispatcher->dispatch($eventName, $event);
112
113         // @todo - There are still test cases where the result isn't defined, temporarily leave the isset check in place
114         return !isset($result['result']) || \is_null($result['result']) ? [] : $result['result'];
115     }
116 }
Joomla\CMS\Application\WebApplication->triggerEvent()
.../administrator/components/com_virtuemart/helpers/vdispatcher.php:41
36       }
37
38       if(JVM_VERSION<4){
39          return self::$dispatcher->trigger($name, $params);
40       } else {
41          return self::$dispatcher->triggerEvent($name, $params);
42       }
43    }
44
45    static function setDispatcher() {
46
vDispatcher::trigger()
.../components/com_virtuemart/helpers/shopfunctionsf.php:1160
1155       jimport ('joomla.registry.registry');
1156       $params = new JRegistry('');
1157       if (!isset($article->event)) {
1158          $article->event = new stdClass();
1159       }
1160       $results = vDispatcher::trigger ('onContentPrepare', array('com_virtuemart.'.$context, &$article, &$params, 0));
1161       // More events for 3rd party content plugins
1162       // This do not disturb actual plugins, because we don't modify $vendor->text
1163       $res = vDispatcher::trigger ('onContentAfterTitle', array('com_virtuemart.'.$context, &$article, &$params, 0));
1164       $article->event->afterDisplayTitle = trim (implode ("\n", $res));
1165
shopFunctionsF::triggerContentPlugin()
.../components/com_virtuemart/views/category/view.html.php:369
364       } else {
365          $this->category->children = false;
366       }
367
368       if (VmConfig::get('enable_content_plugin', 0)) {
369          shopFunctionsF::triggerContentPlugin($this->category, 'category','category_description');
370       }
371
372       if(empty($this->category->category_template)){
373          $this->category->category_template = VmConfig::get('categorytemplate');
374       }
VirtuemartViewCategory->display()
.../components/com_virtuemart/controllers/category.php:61
56
57          $view = $this->getView($viewName, $viewType, '', array('layout' => $viewLayout));
58
59          $view->assignRef('document', $document);
60
61          $view->display();
62       //}
63       if($categoryId = vRequest::getInt('virtuemart_category_id',0)){
64          shopFunctionsF::setLastVisitedCategoryId($categoryId);
65       }
66       return $this;
VirtueMartControllerCategory->display()
.../libraries/src/MVC/Controller/BaseController.php:678
673         }
674
675         // Record the actual task being fired
676         $this->doTask = $doTask;
677
678         return $this->$doTask();
679     }
680
681     /**
682      * Method to get a model object, loading it if required.
683      *
Joomla\CMS\MVC\Controller\BaseController->execute()
.../components/com_virtuemart/virtuemart.php:123
118
119
120 if (class_exists($_class)) {
121     $controller = new $_class();
122
123     $controller->execute($task);
124
125    if(class_exists('vmrouterHelper') and vmrouterHelper::$updateCache and VmConfig::get('useCacheVmGetCategoryRoute',1)){
126       vmrouterHelper::updateCache();
127    }
128
require_once()
.../libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
66         // Load common and local language files.
67         $lang->load($this->app->scope, JPATH_BASE) || $lang->load($this->app->scope, JPATH_COMPONENT);
68
69         // Execute the component
70         $loader = static function ($path) {
71             require_once $path;
72         };
73         $loader($path);
74     }
75 }
Arguments
0   
string(89) "/var/www/vhosts/xxx/httpdocs/xxx/components/com_virtuemart/virtuemart.php"
Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}()
.../libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
68
69         // Execute the component
70         $loader = static function ($path) {
71             require_once $path;
72         };
73         $loader($path);
74     }
75 }
Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch()
.../libraries/src/Component/ComponentHelper.php:361
356         if (!static::isEnabled($option)) {
357             throw new MissingComponentException(Text::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
358         }
359
360         ob_start();
361         $app->bootComponent($option)->getDispatcher($app)->dispatch();
362         $contents = ob_get_clean();
363
364         // Revert the scope
365         $app->scope = $scope;
366
Joomla\CMS\Component\ComponentHelper::renderComponent()
.../libraries/src/Application/SiteApplication.php:208
203             $document->setGenerator('Joomla! - Open Source Content Management - Version ' . JVERSION);
204         } else {
205             $document->setGenerator('Joomla! - Open Source Content Management');
206         }
207
208         $contents = ComponentHelper::renderComponent($component);
209         $document->setBuffer($contents, 'component');
210
211         // Trigger the onAfterDispatch event.
212         PluginHelper::importPlugin('system');
213         $this->triggerEvent('onAfterDispatch');
Joomla\CMS\Application\SiteApplication->dispatch()
.../libraries/src/Application/SiteApplication.php:249
244              */
245             $this->checkUserRequireReset('com_users', 'profile', 'edit', 'com_users/profile.save,com_users/profile.apply,com_users/user.logout');
246         }
247
248         // Dispatch the application
249         $this->dispatch();
250
251         // Mark afterDispatch in the profiler.
252         JDEBUG ? $this->profiler->mark('afterDispatch') : null;
253     }
254
Joomla\CMS\Application\SiteApplication->doExecute()
.../libraries/src/Application/CMSApplication.php:293
288             $this->sanityCheckSystemVariables();
289             $this->setupLogging();
290             $this->createExtensionNamespaceMap();
291
292             // Perform application routines.
293             $this->doExecute();
294
295             // If we have an application document object, render it.
296             if ($this->document instanceof \Joomla\CMS\Document\Document) {
297                 // Render the application output.
298                 $this->render();
Joomla\CMS\Application\CMSApplication->execute()
.../includes/app.php:61
56
57 // Set the application as global app
58 \Joomla\CMS\Factory::$application = $app;
59
60 // Execute the application.
61 $app->execute();
require_once()
.../index.php:32
27  * define() is used rather than "const" to not error for PHP 5.2 and lower
28  */
29 define('_JEXEC', 1);
30
31 // Run the application - All executable code should be triggered through this file
32 require_once dirname(__FILE__) . '/includes/app.php';
Arguments
0   
string(65) "/var/www/vhosts/xxx/httpdocs/xxx/includes/app.php"

extonjaez

Have you an idea please ?
Many Thanks for your help  ;)
Best regards
Arnaud

jenkinhill

This is not a VirtueMart problem. It's a Litespeed Cache plugin compatibility issue with Joomla 4. Try the Joomla forum.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

extonjaez

No, sorry, i think it's really a Virtuemart problem !
The issue here is IN the Virtuemart category products and products (others pages work well !!)

Perhaps you're not using Litespeed...

But Virtuemart is presented like INTEGRATED IN CORE with Litespeed since many years. 
This is an argument given from the beginning by the Virtuemart team to highlight their extension and its speed of execution.
:)

jenkinhill

No, I don't use Litespeed. My server can be configured with Litespeed but is plenty fast for me without it.

Your issue was described here - https://www.litespeedtech.com/support/forum/threads/joomla-4-2-8-lscache-latest-problems-with-virtuemart-administration.21495/  but there is no further info. Also found this:  https://github.com/litespeedtech/lscache-joomla/issues/57
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

extonjaez

Quote from: Ghost on June 02, 2023, 09:01:48 AM
LS Cache plugin is not compatible with Joomla 4. This issue has been fixed in codebase but no release has been made yet. There is a "latest" package available containing latest fixes but it should not be used in production. Use at your own risk https://github.com/litespeedtech/lscache-joomla/blob/master/Joomla4/package/lscache-latest.zip.

There was a NEW version of the litespeed plugin from 13 july 2023 [/b]

We have this error with this new version
Too few arguments to function LSCacheComponentVirtueMart::onContentPrepare(), 1 passed in /var/www/vhosts/xxx/httpdocs/xxx/libraries/vendor/joomla/event/src/Dispatcher.php on line 486 and at least 3 expected

nehakakar

Caching that could be causing the conflict. You might need to adjust these settings or disable caching for VirtueMart pages.

extonjaez

Quote from: nehakakar on August 06, 2023, 22:01:50 PM
Caching that could be causing the conflict. You might need to adjust these settings or disable caching for VirtueMart pages.

Caching is disabled in my site
(see srceeen capture)
regards

GJC Web Design

In J4 the function is

function prepareContent($text, $params = null, Result $item = null)

but in Litespeed \lscache_plugin\components\com_virtuemart.php

they are already using

public function onContentPrepare($context, &$row, &$params, $page = 0)

so u need to provide a full trace to know where in LS its being called from



GJC Web Design
VirtueMart and Joomla Developers - php developers [url="https://www.gjcwebdesign.com"]https://www.gjcwebdesign.com[/url]
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
[url="https://extensions.joomla.org/profile/profile/details/67210"]https://extensions.joomla.org/profile/profile/details/67210[/url]
Contact for any VirtueMart or Joomla development & customisation