joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.73k stars 3.64k forks source link

[4.0] API Error #36003

Closed xhorizont closed 2 years ago

xhorizont commented 2 years ago

System information (as much as possible)

J4.0.3 PHP 8.0.11 (cli) (built: Sep 23 2021 21:26:24) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.11, Copyright (c) Zend Technologies with Zend OPcache v8.0.11, Copyright (c), by Zend Technologies

Additional comments

Testing API in Postman and when I GET {{base_path}}/api/index.php/v1/content/articles/66 (it exists), I get response:

{ "errors": { "code": 500, "title": "Internal server error" }

In apache2/error.log I get: PHP Warning: Undefined property: Joomla\CMS\Table\Update::$targetplatform in /var/www/html/libraries/src/Updater/Adapter/ExtensionAdapter.php on line 112 PHP Warning: Trying to access array offset on value of type null in /var/www/html/libraries/src/Updater/Adapter/ExtensionAdapter.php on line 112 PHP Warning: Attempt to read property "id" on null in /var/www/html/libraries/src/Updater/Adapter/ExtensionAdapter.php on line 333

I am using administrators API key

But when I GET {{base_path}}/api/index.php/v1/banners I get correct response 200 OK

{ "links": { "self": "http://SERVERNAME/api/index.php/v1/banners" }, "data": [ { "type": "banners", "id": "1", "attributes": { "id": 1, "name": "Test pasica", "alias": "test-pasica", "checked_out": null, "checked_out_time": null, "catid": 3, "clicks": 0, "metakey": "", "sticky": 0, "impmade": 0, "imptotal": 0, "state": 1, "ordering": 1, "purchase_type": -1, "language": "*", "publish_up": null, "publish_down": null, "language_image": null, "editor": null, "category_title": "Uncategorised", "client_name": null, "client_purchase_type": null } } ], "meta": { "total-pages": 1 } }

It only works on banners

bato3 commented 2 years ago
  1. Can you update Joomla to 4.0.4 and test again?
  2. Is article 66 exists? (If not, I'm thinking, that should be 404)
  3. What's to happen when you change error reporting in Joomla to NONE?
xhorizont commented 2 years ago

66 exists Joomla to NONE returns same error I will make the update on friday night (already in production)

alikon commented 2 years ago

you souldn't do a POST {{base_path}}/api/index.php/v1/content/articles/66 on a existing resource,

a correct post should be {{base_path}}/api/index.php/v1/content/articles to create a new article

xhorizont commented 2 years ago

you souldn't do a POST {{base_path}}/api/index.php/v1/content/articles/66 on a existing resource,

a correct post should be {{base_path}}/api/index.php/v1/content/articles to create a new article

Sorry I meant GET. I'll edit post

Quy commented 2 years ago

I am unable to reproduce the error. The error in your log appears to be unrelated to this issue.

xhorizont commented 2 years ago

Finaly got some useful error

{ "errors": { "code": 500, "title": "Internal server error", "detail": "ArgumentCountError: Too few arguments to function PlgContentSppagebuilder::onContentPrepare(), 3 passed in /var/www/html/libraries/src/Plugin/CMSPlugin.php on line 285 and exactly 4 expected in /var/www/html/plugins/content/sppagebuilder/sppagebuilder.php:93\nStack trace:\n#0 /var/www/html/libraries/src/Plugin/CMSPlugin.php(285): PlgContentSppagebuilder->onContentPrepare()\n#1 /var/www/html/libraries/vendor/joomla/event/src/Dispatcher.php(486): Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}()\n#2 /var/www/html/libraries/src/Application/EventAware.php(111): Joomla\Event\Dispatcher->dispatch()\n#3 /var/www/html/api/components/com_content/src/View/Articles/JsonapiView.php(196): Joomla\CMS\Application\WebApplication->triggerEvent()\n#4 /var/www/html/libraries/src/MVC/View/JsonApiView.php(222): Joomla\Component\Content\Api\View\Articles\JsonapiView->prepareItem()\n#5 /var/www/html/api/components/com_content/src/View/Articles/JsonapiView.php(178): Joomla\CMS\MVC\View\JsonApiView->displayItem()\n#6 /var/www/html/libraries/src/MVC/Controller/ApiController.php(187): Joomla\Component\Content\Api\View\Articles\JsonapiView->displayItem()\n#7 /var/www/html/libraries/src/MVC/Controller/BaseController.php(730): Joomla\CMS\MVC\Controller\ApiController->displayItem()\n#8 /var/www/html/libraries/src/Dispatcher/ApiDispatcher.php(59): Joomla\CMS\MVC\Controller\BaseController->execute()\n#9 /var/www/html/libraries/src/Component/ComponentHelper.php(389): Joomla\CMS\Dispatcher\ApiDispatcher->dispatch()\n#10 /var/www/html/libraries/src/Application/ApiApplication.php(423): Joomla\CMS\Component\ComponentHelper::renderComponent()\n#11 /var/www/html/libraries/src/Application/ApiApplication.php(110): Joomla\CMS\Application\ApiApplication->dispatch()\n#12 /var/www/html/libraries/src/Application/CMSApplication.php(278): Joomla\CMS\Application\ApiApplication->doExecute()\n#13 /var/www/html/api/includes/app.php(54): Joomla\CMS\Application\CMSApplication->execute()\n#14 /var/www/html/api/index.php(31): require_once('...')\n#15 {main}" } }

brianteeman commented 2 years ago

and there is your answer and explanation why banners worked and articles produced an error.

Too few arguments to function PlgContentSppagebuilder::onContentPrepare()

The problem is int the SP Pagebuilder plugin

alikon commented 2 years ago

not a core issue