joomla-projects / plg_content_joomlarrssb

Social sharing plugin for the joomla.org websites using Ridiculously Responsive Social Sharing Buttons
10 stars 19 forks source link

Enabling this plugin breaks the articles api endpoint in 4.0.3 #34

Closed multizone-uk closed 2 years ago

multizone-uk commented 3 years ago

I like this little plugin and it works well for me. I realise it has limited scope but it does break the API for me.

Steps to reproduce

  1. Clone, build and install this plugin in a Joomla 4.0.3 site
  2. Enable it
  3. Call the articles API endpoint for your site using postman - /api/index.php/v1/content/articles with a correctly set token
  4. Expected result a list of articles in JSON
  5. Actual result 500 error
  6. Disable the plugin and run the query again
  7. Actual result a list of articles in JSON

everything.php log `#

<?php die('Forbidden.'); ?>

Date: 2021-10-04 21:14:48 UTC

Software: Joomla! 4.0.3 Stable [ Furaha ] 12-September-2021 10:39 GMT

Fields: datetime priority clientip category message

2021-10-04T21:14:48+00:00 CRITICAL 86.27.156.11 error Uncaught Throwable of type ArgumentCountError thrown with message "Too few arguments to function PlgContentJoomlarrssb::onContentPrepare(), 3 passed in [...]libraries/src/Plugin/CMSPlugin.php on line 285 and exactly 4 expected". Stack trace: #0 [...]libraries/src/Plugin/CMSPlugin.php(285): PlgContentJoomlarrssb->onContentPrepare('com_content.art...', Object(stdClass), NULL)

1 [...]libraries/vendor/joomla/event/src/Dispatcher.php(486): Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin{closure}(Object(Joomla\Event\Event))

2 [...]libraries/src/Application/EventAware.php(111): Joomla\Event\Dispatcher->dispatch('onContentPrepar...', Object(Joomla\Event\Event))

3 [...]api/components/com_content/src/View/Articles/JsonapiView.php(196): Joomla\CMS\Application\WebApplication->triggerEvent('onContentPrepar...', Array)

4 [...]libraries/src/MVC/View/JsonApiView.php(128): Joomla\Component\Content\Api\View\Articles\JsonapiView->prepareItem(Object(stdClass))

5 [...]api/components/com_content/src/View/Articles/JsonapiView.php(151): Joomla\CMS\MVC\View\JsonApiView->displayList()

6 [...]libraries/src/MVC/Controller/ApiController.php(275): Joomla\Component\Content\Api\View\Articles\JsonapiView->displayList()

7 [...]api/components/com_content/src/Controller/ArticlesController.php(78): Joomla\CMS\MVC\Controller\ApiController->displayList()

8 [...]libraries/src/MVC/Controller/BaseController.php(730): Joomla\Component\Content\Api\Controller\ArticlesController->displayList()

9 [...]libraries/src/Dispatcher/ApiDispatcher.php(59): Joomla\CMS\MVC\Controller\BaseController->execute('displaylist')

10 [...]libraries/src/Component/ComponentHelper.php(389): Joomla\CMS\Dispatcher\ApiDispatcher->dispatch()

11 [...]libraries/src/Application/ApiApplication.php(423): Joomla\CMS\Component\ComponentHelper::renderComponent('com_content')

12 [...]libraries/src/Application/ApiApplication.php(110): Joomla\CMS\Application\ApiApplication->dispatch()

13 [...]libraries/src/Application/CMSApplication.php(278): Joomla\CMS\Application\ApiApplication->doExecute()

14 [...]api/includes/app.php(54): Joomla\CMS\Application\CMSApplication->execute()

15 [...]api/index.php(31): require_once('[...]...')

16 {main}`

alexandreelise commented 2 years ago

Hi @multizone-uk here is a quick fix which should get you up and going. #36 I am not a maintainer of this project nor a joomla core developer but I know Joomla! enough as a developer and fixed the exact same error for a friend yesterday. It should work for you as well. Take care and have a great day.

multizone-uk commented 2 years ago

Thank you so much! A simple fix and its working again! I hope someone accepts it into the code.