?
avatar altcom-jc
altcom-jc
18 Nov 2016

Steps to reproduce the issue

Using the Contacts editor in Joomla 3.6.4, edit any contact which has tags that will populate the tag ordering page.

Expected result

Contact edit page should correctly render and populate screen including tag ordering tab.

Actual result

Rendering of contact edit page fails.
Error Code: 1052 Column 'name' in group statement is ambiguous is displayed in browser tab header.

System information (as much as possible)

Joomla 3.6.4 PHP any version from 5.3.10 onwards including PHP 7.

Additional comments

Error is in /libraries/cms/helper/tags.php line 622.
Generated group clause for SQL select statement should qualify field names with table aliases.
Error is solved by adding table alias 'ua' to field 'name' i.e. 'ua.name'.

avatar altcom-jc altcom-jc - open - 18 Nov 2016
avatar brianteeman
brianteeman - comment - 18 Nov 2016

Can you provide some more details please - perhaps with screenshots. I
tried to replicate the issue described but had no problems

On 18 November 2016 at 11:55, altcom-jc notifications@github.com wrote:

Steps to reproduce the issue

Using the Contacts editor in Joomla 3.6.4, edit any contact which has tags
that will populate the tag ordering page.
Expected result

Contact edit page should correctly render and populate screen including
tag ordering tab.
Actual result

Rendering of contact edit page fails.
Error Code: 1052 Column 'name' in group statement is ambiguous is
displayed in browser tab header.
System information (as much as possible)

Joomla 3.6.4 PHP any version from 5.3.10 onwards including PHP 7.
Additional comments

Error is in /libraries/cms/helper/tags.php line 622.
Generated group clause for SQL select statement should qualify field names
with table aliases.
Error is solved by adding table alias 'ua' to field 'name' i.e. 'ua.name'.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#12933, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPH8QB8Yy7ukHSoey4asXlMTbm6FE3zks5q_ZIpgaJpZM4K2Z-T
.

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
https://brian.teeman.net/ http://brian.teeman.net/

avatar brianteeman brianteeman - change - 19 Nov 2016
Status New Information Required
avatar brianteeman
brianteeman - comment - 9 Dec 2016

I am closing this due to a lack of response. It can always be reopened if the requested information is provided.


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

avatar brianteeman brianteeman - change - 9 Dec 2016
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2016-12-09 12:29:16
Closed_By brianteeman
avatar brianteeman brianteeman - close - 9 Dec 2016
avatar LivioCavallo
LivioCavallo - comment - 31 Jul 2017

The issue is still present in Joomla! 3.7.4. It's not a problem now but it's a problem waiting to arise...

The group clause in libraries/cms/helper/tags.php @ row 637 should use the field "author" not "name":
->group('m.type_alias, m.content_item_id, m.core_content_id, core_modified_time, core_created_time, core_created_by_alias, author, author_email');

To understand the issue:

Create some contacts, with ad associated tag.
Create a menu-item of type Tagged elements (blog).
If you want the blog-view to be able to show some additional contact info you have to modify the model deriving the class model or via a model-override, using MVC plugin, to join the fields you need.
Let's use MVC plugin; copy components/com_tags/models/tag.php in /code dir and add these lines @ row 157 to join the telephone field:

$typesarray = $tagsHelper::getTypes('assocList', $typesr, false);
foreach ($typesarray as $type) {
if ('com_contact.contact' == $type['type_alias']) {
$query->join('LEFT', $this->_db->quoteName('#__contact_details', 'cd') . ' ON (' . $this->_db->quoteName('c.core_title') . ' = ' . $this->_db->quoteName('cd.name') . ')');
$query->select('cd.name AS cd_name, cd.telephone AS cd_telephone, ');
break;
}
}

The query will fail with error: Column 'name' in group statement is ambiguous.

Yes, at the moment the problem won't arise in standard joomla installation.
It arises only in a slightly extended Joomla scenario, in a just non-trivial Joomla application (when a class is derived or the tags model is overriden via MVC plugin to show some additional contacts field).

Anyway it seems that is NOT A GOOD PRACTICE to have a SELECT correctly renaming a field (as in libraries/cms/helper/tags.php @ row 599: "...ua.name END AS author") and later on using the non-renamed and not-table-qualified column 'name'.
It is an ERROR WAITING TO ARISE.

For a better practice the group clause in libraries/cms/helper/tags.php @ row 637 should use the field "author" not "name"; it should read:
->group('m.type_alias, m.content_item_id, m.core_content_id, core_modified_time, core_created_time, core_created_by_alias, author, author_email');

At the moment, if you override the model as described above, inserting a join such as the proposed one, you have to fix the query error via a text substitution, immediately after the above join:

$query->setQuery(str_replace(' name, ', ' author, ', $query));

I think this should be 'fixed'

avatar zero-24
zero-24 - comment - 31 Jul 2017

@LivioCavallo this is a issue closed back in 2016 can you please open a new issue or pull request with the suggested changes?

avatar LivioCavallo
LivioCavallo - comment - 31 Jul 2017

I never did a pull request or submitted a new issue. Now I try to submit a new issue

avatar zero-24
zero-24 - comment - 31 Jul 2017
avatar LivioCavallo
LivioCavallo - comment - 31 Jul 2017

Now there is a new issue ##17363: #17363
Did I open it right?

avatar zero-24
zero-24 - comment - 31 Jul 2017

Thanks! Looks good to me.

Add a Comment

Login with GitHub to post a comment