When you get an error using the api it is often made up of TWO strings
Save failed with the following error: Another Contact from this category has the same alias (remember it may be a trashed item).
Save failed with the following error: COM_CONTACT_ERROR_UNIQUE_ALIAS
The relevant code is
joomla-cms/libraries/src/MVC/Controller/ApiController.php
Lines 480 to 484 in 8bc41ad
I suspect it might be caused by my PR #26393
Labels |
Added:
?
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-10-30 08:44:26 |
Closed_By | ⇒ | alikon |
Closed_By | alikon | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @alikon by The JTracker Application at issues.joomla.org/joomla-cms/26846
please test #26864
Status | Closed | ⇒ | Confirmed |
Closed_Date | 2019-10-30 08:44:26 | ⇒ | |
Closed_By | joomla-cms-bot | ⇒ |
Status | Confirmed | ⇒ | New |
Closed_Date | 0000-00-00 00:00:00 | ⇒ |
Set to "open" on behalf of @alikon by The JTracker Application at issues.joomla.org/joomla-cms/26846
reopened cause #26864 don't solve the issue even if correct something
the problem is not with the use statement. In joomla we had 2 applications and therefore we had a language folder in each application (site and administrator). We now have an additional application (api) and so we should really have an application language folder. It is not enough to proxy to either the site or the administrator folder as the strings could be in either.
Instead of adding one more language file for API, which will have duplicate constants and values, what if we load the languages files needed (may it be the backend file or site file) ?
Eg: for above case load lang. file in save method.
/joomla-cms/api/components/com_contact/Controller/ContactController.php
protected function save($recordKey = null)
{
$lang = Factory::getLanguage();
$lang->load('com_contact', JPATH_ADMINISTRATOR, null, false, true);
// Other code below
}
3rd party ext. developers can choose which files to load - site or admin's in case of the APIs they build
Labels |
Added:
J4 Issue
|
We already load the component specific language files that way in the ApiDispatcher https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Dispatcher/ApiDispatcher.php#L65
Our problem is the core joomla files en-GB.ini and lib-joomla.en-GB.ini (or of course the translated version)
ok - i will dig into this as we discussed - tomorrow
Lib joomla always comes from admin https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Application/CMSApplication.php#L741
So it’s just the main en-GB file here https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Language/Language.php#L271 at language object first use
The code I pointed to was component files in both cases. It tries to load from active application language file (i.e. JPATH_BASE which here is JPATH_API). We don’t fall back the en-GB.ini as that’s handled in the library for language on the lines just above here
So the problem then is that we want to be loading the component language file from the admin and its not
We're loading the component language file just fine - at least that was my read. The issue I understood from our discussion was around the en-GB.ini (https://github.com/joomla/joomla-cms/blob/staging/language/en-GB/en-GB.ini) which needed to go in the language folder of the API. It was the strings like JCategory
that didn't translate in the API https://github.com/joomla/joomla-cms/blob/staging/language/en-GB/en-GB.ini#L61
turned out there are two different issues
For me
com_contact
backend lang. file was not loadedOK So
lib_joomla
is fine so just the en-GB.ini file)I agree with your conclusion and thats what I was trying to say
Please explain how to test this problem as When you get an error using the api
is pre(or post)-homo-sapiens language for me...
Make an API request creating a contact and then submit a request to create a second one with the same alias for the first issue.
Make an API request missing a required field (e.g. category) in the form to reproduce the second issue
Make an API request
does not help at all, sorry.
I guess that you need to read the instructions for using the API https://docs.joomla.org/J4.x:Joomla_Core_APIs
@infograf768 unless you know curl there is no "easy" way to test this jm.
First you have to identify yourself as a super admin, THEN you can create the contact, HOWEVER
both of these require curl ( since your using curl to begin with ) and you can't simply cut/paste from command line. I THINK you then have to read the response but thats conjecture.
the link brian gave you is worthless to your specific question other then it provides sample json(?) data that curl would use.
The doc, like most of our docs now, assume your a experienced dev and know what your doing. Seeing it's an api I can SORTA understand that BUT I've seen several api's that are extremely well documented.
I would THINK this is something the unit tests should be able to handle reliably.
After about 30 minutes of testing/checking/trying it looks like phpstorm has a method to make life "easier" but it's as clear as mud to me.
The link is absolutely not worthless. If it was then I wouldnt have been able to do anything ;)
Instead of curl you will probably find it easier to use postman https://www.getpostman.com/
I am creating a quick video for that and will update thiis post when the video is online
@N6REJ I'd love to end up producing an Open API file (and push that into something like ReDoc) for something like swagger unfortunately trying to get the list of parameters and response parameters is basically impossible for Joomla. We have plugins adding dynamic extra information in responses and custom fields that add extra required fields potentially to the request. So whilst the docs suck - their better the nothing and probably about as good as we can do for the next few months until the API is solid and we can focus on building the best docs possible
The link is absolutely not worthless. If it was then I wouldnt have been able to do anything ;)
Notice i said "to your specific purpose" along with caveats!
Instead of curl you will probably find it easier to use postman https://www.getpostman.com/
I am creating a quick video for that and will update thiis post when the video is online
FANTASTIC! I tried to find something like that but was unable to!... TYVM! THAT SIR IS HELPFUL... please add it to the docs.
Labels |
Added:
?
|
I'm also getting these notices:
Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\joomla-cms\libraries\src\Language\Language.php on line 1029
Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\joomla-cms\libraries\src\Language\Language.php on line 1029
Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\joomla-cms\libraries\src\Language\Language.php on line 1029
Notice: Trying to access array offset on value of type null in C:\xampp\htdocs\joomla-cms\libraries\src\Language\Language.php on line 1060
Does it make sense to make paths in Language API configurable instead of relying on JPATH_BASE
?
I think we are going to need API paths. Right now we're running something a bit hacky to get to the admin models - but the long term aim is 3rd party extensions will be able to make API's first class the same as Admin/Site
Labels |
Added:
?
|
Anyone here able to do a PR to clone the en-GB.ini file from admin into the JROOT/api/language directory? should fix the last of the issue
on it
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-01-28 22:18:56 |
Closed_By | ⇒ | brianteeman |
Labels |
Removed:
?
|
Labels |
Removed:
?
|
it seems that adding the missing import of
use Joomla\CMS\Language\Text;
on #26393 should solve