Open Graph Content does not work on Joomla 4.1.2

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
DimRus
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 20 Apr 2022, 14:18

Open Graph Content does not work on Joomla 4.1.2

Post by DimRus »

Hello!

After the installation, without any additional configuration, it breaks entire site, with message "Call to undefined method Joomla\CMS\Factory::getURI()".

I would appreciate any help.
  • Joomla v 4.1.2
  • Phoca Open Graph Content Plugin v.3.1.10
The information in logs:

Code: Select all

2022-04-20T12:36:14+00:00       CRITICAL 194.44.191.61  error   Uncaught Throwable of type Error thrown with message "Call to undefined method Joomla\CMS\Factory::getURI()". Stack trace: #0 [ROOT]/libraries/src/Plugin/CMSPlugin.php(285): plgContentPhocaOpenGraph->onContentAfterDisplay('com_content.cat...', Object(stdClass), Object(Joomla\Registry\Registry), 0)
#1 [ROOT]/libraries/vendor/joomla/event/src/Dispatcher.php(486): Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}(Object(Joomla\Event\Event))
#2 [ROOT]/libraries/src/Application/EventAware.php(111): Joomla\Event\Dispatcher->dispatch('onContentAfterD...', Object(Joomla\Event\Event))
#3 [ROOT]/components/com_content/src/View/Category/HtmlView.php(119): Joomla\CMS\Application\WebApplication->triggerEvent('onContentAfterD...', Array)
#4 [ROOT]/libraries/src/MVC/Controller/BaseController.php(697): Joomla\Component\Content\Site\View\Category\HtmlView->display()
#5 [ROOT]/components/com_content/src/Controller/DisplayController.php(124): Joomla\CMS\MVC\Controller\BaseController->display(false, Array)
#6 [ROOT]/libraries/src/MVC/Controller/BaseController.php(735): Joomla\Component\Content\Site\Controller\DisplayController->display()
#7 [ROOT]/libraries/src/Dispatcher/ComponentDispatcher.php(146): Joomla\CMS\MVC\Controller\BaseController->execute('display')
#8 [ROOT]/components/com_content/src/Dispatcher/Dispatcher.php(55): Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch()
#9 [ROOT]/libraries/src/Component/ComponentHelper.php(389): Joomla\Component\Content\Site\Dispatcher\Dispatcher->dispatch()
#10 [ROOT]/libraries/src/Application/SiteApplication.php(204): Joomla\CMS\Component\ComponentHelper::renderComponent('com_content')
#11 [ROOT]/libraries/src/Application/SiteApplication.php(243): Joomla\CMS\Application\SiteApplication->dispatch()
#12 [ROOT]/libraries/src/Application/CMSApplication.php(278): Joomla\CMS\Application\SiteApplication->doExecute()
#13 [ROOT]/includes/app.php(63): Joomla\CMS\Application\CMSApplication->execute()
#14 [ROOT]/index.php(32): require_once('/var/www/html_x...')
#15 {main}
DimRus
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 20 Apr 2022, 14:18

Re: Open Graph Content does not work on Joomla 4.1.2

Post by DimRus »

It looks, like a compatibility issue with Joomla 4.

I fixed the code:
File phocaopengraph.php, line 366:

Code: Select all

//$uri	= JFactory::getURI();
$uri	= Uri::getInstance();
Plus adding import on top of the file:

Code: Select all

use Joomla\CMS\Uri\Uri;
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47810
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Open Graph Content does not work on Joomla 4.1.2

Post by Jan »

Hi, you still use the plugin for Joomla 3 (version 3.1.10). For Joomla 4, use the Joomla 4 version:
https://www.phoca.cz/download/category/ ... aph-plugin - version 4.0.2

Jan
If you find Phoca extensions useful, please support the project
Post Reply