User tests: Successful: Unsuccessful:
Pull Request for Issue # .
render the image field
edit an article
add an Intro Image and/or Full Article Image
save
call the api
{{base_url}}api/index.php/v1/content/article
N/A
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_content |
Go to the Home Dashboard:
Notice: Undefined property: stdClass::$images in \administrator\components\com_content\src\Model\ArticlesModel.php on line 655
Labels |
Added:
?
|
I don't know enough to test this. My article URL is http://localhost/j4bugtest/index.php/en/blog/3-welcome-to-your-blog
Editing to .../api/index.php/v1/content/... in any combination I have tried just gives me a Not Found response. So what should the api url look like?
an easy way to test if you don't want to use tools like Postman
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://localhost/quattro/api/index.php/v1/content/article",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Accept: application/vnd.api+json",
"Authorization: Basic YWRtaW46YWRtaW4="
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
It is not returning as object.
"images": "{\"image_intro\":\"images\\/joomla_black.png\",\"float_intro\":\"\",\"image_intro_alt\":\"a\",\"image_intro_caption\":\"b\",\"image_fulltext\":\"images\\/powered_by.png\",\"float_fulltext\":\"\",\"image_fulltext_alt\":\"c\",\"image_fulltext_caption\":\"d\"}",
this is what I got in postman .... so unable to reproduce your findings
Installed the package from here: https://ci.joomla.org/artifacts/joomla/joomla-cms/4.0-dev/29020/downloads/32042/
Assigned images:
{
"errors": {
"code": 500,
"title": "Internal server error"
}
}
Removed images:
"images": {
"image_intro": "",
"float_intro": "",
"image_intro_alt": "",
"image_intro_caption": "",
"image_fulltext": "",
"float_fulltext": "",
"image_fulltext_alt": "",
"image_fulltext_caption": ""
},
Still baffled! Without the patch the api script using curl given above recovers all 15 articles (valid json) in descending order with no mention of images. With the patch I get the Internal server error message.
I have tested this item
A couple of things I have discovered:
Adding this line to the curl script given above allows debugging (I am using Eclipse):
CURLOPT_COOKIE => 'XDEBUG_SESSION=1',
With the patch applied using com_patchtester:
On stepping through the code I get to administrator/components/com_content/src/Helper/contentHelper.php line 232:
$uri = Psr7\uri_for($uri);
and that statement throws a fatal error.
This morning I updated my bugtest installation on-line from the nightly build.
Is this helpful?
I have tested this item
Tested with nightly build and Path Tester and fail --> We think is a problem with the package of the nightly
Downloaded source from github, compiled and tested: Works correctly.
Tested with intro and fulltext images, float, alt, caption.
Also tested with external url image.
Also tested POST.
PERFECT!
{
"links": {
"self": "https://j4.jugmi.it/api/index.php/v1/content/article"
},
"data": {
"type": "articles",
"id": "6",
"attributes": {
"typeAlias": "com_content.article",
"id": 6,
"asset_id": 92,
"title": "Test Api Nicola 5",
"state": 0,
"created": "2020-05-16 08:00:19",
"images": {
"image_intro": "https://leganerd.com/wp-content/uploads/2020/03/google-classroom-cover-999x500.jpg",
"float_intro": "none",
"image_intro_alt": "Intro alt",
"image_intro_caption": "Intro capt",
"image_fulltext": "https://www.fastweb.it/var/storage_feeds/CMS/articoli/108/10840b1e803a03d644e95dd60efa9f64/480x270.jpg",
"float_fulltext": "left",
"image_fulltext_alt": "Full alt",
"image_fulltext_caption": "Full capt"
},
"language": "*",
"tags": [],
"text": "Test Pubblicazione Articolo con Nicola 5 "
},
"relationships": {
"category": {
"data": {
"type": "categories",
"id": "2"
}
},
"author": {
"data": {
"type": "users",
"id": "385"
}
}
}
}
}
@coolcat-creations this pr is about the api application and not the administrator application
@ceford sure it helped us to discover the root of the issue, i've used that library "Guzzle"which is present on dev but it is not delivered on the nightly build... let's see if that library it is necesssary or not to be delivered on the final "nighly" package.... work in progress...
You should be able to use the HttpFactory instead of Guzzle.
Just prefix the value with Joomla\CMS\Uri\Uri::root()
- there's no need for any of the helper work as far as I can tell?
well that will work with "internal" path like images/sampledata/fruitshop/apple.jpg
not for external one like
https://www.fastweb.it/var/storage_feeds/CMS/articoli/108/10840b1e803a03d644e95dd60efa9f64/480x270.jpg
not for external one like
https://www.fastweb.it/var/storage_feeds/CMS/articoli/108/10840b1e803a03d644e95dd60efa9f64/480x270.jpg
Can you please explain how do you get that external file to that place in the first place? And when you have successfully added it why is that a problem now?
You might only prefix the images with Joomla\CMS\Uri\Uri::root() when they are not starting with "http" already?
if you use the API POST for create an article you can set "image_intro" with an external url
curl -X POST -H "Content-Type: application/json" /api/index.php/v1/content/article -d
{
"alias": "my-article",
"articletext": "My text",
"catid": 64,
"language": "*",
"metadesc": "",
"metakey": "",
"images": {
"image_intro": "https://leganerd.com/wp-content/uploads/2020/03/google-classroom-cover-999x500.jpg",
"float_intro": "none",
"image_intro_alt": "Intro alt",
"image_intro_caption": "Intro capt",
"image_fulltext": "https://www.fastweb.it/var/storage_feeds/CMS/articoli/108/10840b1e803a03d644e95dd60efa9f64/480x270.jpg",
"float_fulltext": "left",
"image_fulltext_alt": "Full alt",
"image_fulltext_caption": "Full capt"
},
"title": "Here's an article"
}
with the backend you cannot see #28852
Ok so when the url is set to an external already you don't have to touch it right? So the only case you would need to touch it is when it is just a relative URL?
Idea than would be to check whether is starts with www and if no add uri::root and in the other case dont touch it.
Would that work?
removed Guzzle
ready to be re-tested
I have tested this item
Tested successfully in Nightly Build of 24 May.
@alikon @wilsonge - if 'Use URL Rewriting' is selected in Global Configuration - SEO, the API reports a 404 error. Is this a known issue or should I report it? My test environment is Wampserver 3.2.1 with Apache 2.4.41 MySQL 8.0.19 PHP 7.4.5
Error: {"errors":[{"title":"Resource not found","code":404}]}
@SharkyKZ - Yes and no - after #28394 was applied when 'Use URL Rewriting' was selected, the API worked all right. However, if 'Use URL Rewriting' was NOT selected, the API produced the error 404 - Resource not found. The API should work in both cases, IMHO.
PHP Warning: Invalid argument supplied for foreach() in \administrator\components\com_content\src\Model\ArticlesModel.php on line 649
PHP Warning: Invalid argument supplied for foreach() in \libraries\src\MVC\View\JsonApiView.php on line 126
good catch, this pr was made before workflow v3 was merged so the administrator/components/com_content/src/Model/ArticlesModel.php
included in this pr was old
now should be ok
I have tested this item
@bembelimen can you test this please? The admin model changes required here from workflows especially
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-06-16 06:42:14 |
Closed_By | ⇒ | alikon |
I have not tested this item.
I've a question:
To see the JSON I just need to add api / index.php / v1 / content / article to the article URL?
I'm not very familiar with APIs!
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.