? Success

User tests: Successful: Unsuccessful:

avatar Bhanudev
Bhanudev
18 Feb 2014

Testing for same alias is not done by Contact Creator Plugin.Due to this, 2 contacts with same alias can be created(which is not desirable). So,the extra code ,line numbers 66 to 76, appends the current time stamp to alias if the same alias is already present.
Before Patch: before patch_2 contacts with same alias
After Patch : after patch

The bug is reported at http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=33291

avatar Bhanudev Bhanudev - open - 18 Feb 2014
avatar Bakual
Bakual - comment - 18 Feb 2014

Please have a look at our Coding Style Standards: http://joomla.github.io/coding-standards

avatar infograf768
infograf768 - comment - 18 Feb 2014

Please look at: #3131
Contact creator can't create same alias because an error is sent to prevent it when creating a user and the existing contact alias is in the same category as targetted by contactcreator.
That does not mean we should not implement a solution to create a specific alias instead of sending the error, when possible, taking into account the category as shown in PR 3131 code.

avatar Bhanudev
Bhanudev - comment - 19 Feb 2014

@Bakual This is my first time and I'm unaware of the coding standards.Thank you.
@infograf768 Even though an error is generated, new contact with same alias is getting created. So, this small patch will prevent such a situation.Thanks.

avatar Bakual
Bakual - comment - 19 Feb 2014

@Bhanudev

This is my first time and I'm unaware of the coding standards.Thank you.

No problem :smile:
There are still two minor issues, if you can update them the PR is perfect from a codestyle view.

avatar Bhanudev
Bhanudev - comment - 19 Feb 2014

@Bakual Thanks again :smiley: The status of the bug at http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=33291 is still open. Is there something I should do ?

avatar Bakual
Bakual - comment - 19 Feb 2014

@Bhanudev Thanks. I've set the tracker to "pending", which means it is waiting for testers now.

avatar infograf768
infograf768 - comment - 20 Feb 2014

@Bahanudev
I repeat, a new contact is not created if it is in the same category as the one which contains a contact with same alias.

avatar phproberto
phproberto - comment - 20 Feb 2014

@Bhanudev thanks for contributing to Joomla!

Some notes:

  • @infograf768 is right. Contacts with the same alias are allowed if they are in different categories (so no bug there).
  • For future contributions please use JDatabaseQuery to build queries to ensure that queries are compatible with all the existing drivers. This:
$db = JFactory::getDbo();
$db->setQuery('SELECT id FROM #__contact_details WHERE alias = "' . $user['name'] . '"');
$id2 = $db->loadResult();

would become:

$query = $db->getQuery(true)
    ->select("id")
    ->from('#__contact_details')
    ->where('alias = ' . $db->quote($user['name']));
$db->setQuery($query);
$id2 = $db->loadResult();
  • Here we already had a ContactTableContact instance so you can use it to search an existing contact avoiding to use queries. This is a sample call to search same alias in same category (being $contactTable a ContactTableContact instance):
$contactTable->load(array('alias' => $alias, 'catid' => $categoryId)
  • You can use JString::increment() to increase strings in the same way Joomla! does it in most places. For common strings (name, title...) we use:
// Converts "Webmaster" into "Webmaster (2)"
$name = JString::increment($name);

and for aliases we use:

// Converts "webmaster" into "webmaster-2"
$alias = JString::increment($alias, 'dash');
  • Whenever is possible if another user is already trying to fix an issue send your pull requests against his/her branch. This way both works get recognized and we keep track of everything in a single joomlacode issue and in a single github pull request.

I've sent a PR against @infograf768 branch (#3131) here: infograf768#6

I'm closing this in favour of that pull request. Thanks again for your efforts here!

avatar phproberto phproberto - change - 20 Feb 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-02-20 12:38:30
avatar phproberto phproberto - close - 20 Feb 2014
avatar phproberto phproberto - close - 20 Feb 2014

Add a Comment

Login with GitHub to post a comment