? Pending

User tests: Successful: Unsuccessful:

avatar alikon
alikon
10 May 2020

Pull Request for Issue # .

Summary of Changes

render the image field

Testing Instructions

edit an article
add an Intro Image and/or Full Article Image
save
call the api
{{base_url}}api/index.php/v1/content/article

Expected result

the image field are rendered
Screenshot from 2020-05-10 12-12-47

Actual result

N/A

Documentation Changes Required

avatar alikon alikon - open - 10 May 2020
avatar alikon alikon - change - 10 May 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 May 2020
Category Administration com_content
avatar adj9 adj9 - test_item - 10 May 2020 - Not tested
avatar adj9
adj9 - comment - 10 May 2020

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.

avatar wilsonge
wilsonge - comment - 10 May 2020

@alikon this should be the Fully Qualified Domain name to the image not just the path

avatar Quy
Quy - comment - 10 May 2020

Go to the Home Dashboard:

Notice: Undefined property: stdClass::$images in \administrator\components\com_content\src\Model\ArticlesModel.php on line 655

ba439ed 11 May 2020 avatar alikon redo
avatar alikon alikon - change - 11 May 2020
Labels Added: ?
avatar alikon
alikon - comment - 11 May 2020

@wilsonge can you re-check it now
@Quy no more Notice

avatar ceford
ceford - comment - 11 May 2020

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?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar SharkyKZ
SharkyKZ - comment - 11 May 2020

@adj9 @ceford To test the API you need to connect to it somehow. You can use Joomla's HTTP library, cURL or an external application like Postman.

avatar alikon
alikon - comment - 11 May 2020

@adj9 . @ceford

an easy way to test if you don't want to use tools like Postman

  1. disable API Authentication - Joomla Token plugin
  2. enable API Authentication - Basic Auth plugin
  3. create a super user: admin psw: admin
  4. put this script on your root folder site
  5. change CURLOPT_URL accordingly
  6. run this script from terminal or from browser
<?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;
avatar Quy
Quy - comment - 11 May 2020

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\"}",
avatar alikon
alikon - comment - 11 May 2020

@Quy are you talking about the example script ?

avatar Quy
Quy - comment - 11 May 2020

I expect it to look like your screenshot, but this instead:

api

avatar alikon
alikon - comment - 11 May 2020

Screenshot from 2020-05-11 20-21-43

avatar alikon
alikon - comment - 11 May 2020

this is what I got in postman .... so unable to reproduce your findings

avatar alikon
alikon - comment - 11 May 2020

with single article without an images or with a list of articles....

Screenshot from 2020-05-11 20-27-59

avatar Quy
Quy - comment - 11 May 2020

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": ""
                },
avatar ceford
ceford - comment - 12 May 2020

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.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar alikon
alikon - comment - 13 May 2020

i've appliyed this pr with com_patchtester on the latest 4.0-dev iand unable to replicate your 500
@Quy may I ask you to test it with com_patchtester ?

avatar Quy Quy - test_item - 13 May 2020 - Tested successfully
avatar Quy
Quy - comment - 13 May 2020

I have tested this item successfully on 235d9f8


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar ceford
ceford - comment - 14 May 2020

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?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar Razzo1987 Razzo1987 - test_item - 16 May 2020 - Tested successfully
avatar Razzo1987
Razzo1987 - comment - 16 May 2020

I have tested this item successfully on 235d9f8

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"
                }
            }
        }
    }
}

Schermata da 2020-05-16 10-01-07


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.
avatar coolcat-creations
coolcat-creations - comment - 16 May 2020

@alikon can you enable to add a custom path before clicking on the select icon, that saves admins a LOT of time...

avatar brianteeman
brianteeman - comment - 16 May 2020

@coolcat-creations this pr is about the api application and not the administrator application

avatar alikon
alikon - comment - 16 May 2020

@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...

avatar roland-d
roland-d - comment - 16 May 2020

You should be able to use the HttpFactory instead of Guzzle.

avatar wilsonge
wilsonge - comment - 18 May 2020

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?

avatar alikon
alikon - comment - 19 May 2020

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

? what i'm missing ?

avatar zero-24
zero-24 - comment - 19 May 2020

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?

avatar alikon
alikon - comment - 20 May 2020

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

avatar zero-24
zero-24 - comment - 20 May 2020

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?

avatar alikon
alikon - comment - 21 May 2020

removed Guzzle
ready to be re-tested

avatar toivo toivo - test_item - 24 May 2020 - Tested successfully
avatar toivo
toivo - comment - 24 May 2020

I have tested this item successfully on 32e7210

Tested successfully in Nightly Build of 24 May.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar toivo
toivo - comment - 24 May 2020

@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}]}


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar SharkyKZ
SharkyKZ - comment - 24 May 2020

@toivo see if #28394 solves your issue.

avatar toivo
toivo - comment - 24 May 2020

@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.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar wilsonge
wilsonge - comment - 12 Jun 2020

@toivo Yes API should work in either case. However I think #29303 should have fixed this.

avatar Quy
Quy - comment - 14 Jun 2020

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

avatar alikon
alikon - comment - 14 Jun 2020

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

avatar Quy Quy - test_item - 14 Jun 2020 - Tested successfully
avatar Quy
Quy - comment - 14 Jun 2020

I have tested this item successfully on af796ce


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29020.

avatar wilsonge
wilsonge - comment - 15 Jun 2020

@bembelimen can you test this please? The admin model changes required here from workflows especially

avatar SharkyKZ
SharkyKZ - comment - 16 Jun 2020

Looks like upstream changes were applied manually to one file.

@alikon Can you revert last commit and merge upstream branch instead?

avatar alikon
alikon - comment - 16 Jun 2020

redone #29630

avatar alikon alikon - change - 16 Jun 2020
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2020-06-16 06:42:14
Closed_By alikon
avatar alikon alikon - close - 16 Jun 2020

Add a Comment

Login with GitHub to post a comment