? ? Success

User tests: Successful: Unsuccessful:

avatar Kubik-Rubik
Kubik-Rubik
17 Jun 2014

With this PR a new feature is introduced to the Redirect component:

Batch process to add any number of URLs in one step. The URLs can be added in a modal box which is opened after a click on the new batch button. To speed up the adding, not only the old URL but also the new URL can be added in the same process. The URLs have to be separated with a | (pipe symbol):

http://example.com/old|http://example.com/new

The old URL is mandatory, the new URL not.The host is added automatically to the old URL if not provided which is necessary for the redirect component to work properly.

If an entry already exists, an error "Duplicate entry" is thrown.

How to test

  • Add the PR with the help of the Patchtester component
  • Go to "Components" - "Redirect"
  • Click on the "Batch" button
  • Enter some URLs and click on the "Process" button
  • Entered URLs should be displayed in the overview list
avatar Kubik-Rubik Kubik-Rubik - open - 17 Jun 2014
avatar Kubik-Rubik Kubik-Rubik - change - 17 Jun 2014
Labels Added: ? ?
avatar Bakual
Bakual - comment - 17 Jun 2014

@Kubik-Rubik When I don't enter anything and click "process", the form is submitted and en empty URL (root URL) is registered. The field has a red border so it looks like some client side validation is in place, but it doesn't prevent sending the form and the server side code doesn't check it.

Personally I would not use JError because it's deprecated. In that case here it only shows a warning message anyway. So imho it would be better to just enqueue a message and return after it. It requires that we set the redirect earlier so the return doesn't end up in a white page :)
Something like this:

$this->setRedirect('index.php?option=com_redirect&view=links');
if (!$batch_urls)
{
    $this->setMessage(JText::_('COM_REDIRECT_NO_ITEM_ADDED'), 'error');

    return;
}

The model error could either be done with a message or an exception. It's personal preference if it should be a simple message or an error page. Currently with JError::raiseWarning it's just a message :)

avatar Kubik-Rubik
Kubik-Rubik - comment - 17 Jun 2014

@Bakual Thank you for your feedback. Please take a look at the new commit. Removed use of deprecated JError class and added server side check for empty values (no empty values possible any more). Tried to avoid unnecessary else statements in the controller, so I just set the error message as default, then overwrite it with the success message if everything was executed properly!

avatar zero-24
zero-24 - comment - 21 Jun 2014

Thanks @Kubik-Rubik
Cool feature. Here two questions / suggestions:

  • Can we move the batch button at the end of the toolbar (as we have it on all other places e.g. com_content) ?
  • My browser is german and if i let the box empty i get always a german error message (Bitte füllen Sie dieses Feld aus). Also if i choose english or a other language for Backend.
avatar Kubik-Rubik
Kubik-Rubik - comment - 21 Jun 2014

Thank you for your feedback, @zero-24 !

  1. Yes, we could move it. But for me it makes more sense that the "Batch" button is next to the "New" button.
  2. This is correct, this tooltip is generated by your browser (the preferred language from the settings). No changes needed here.
avatar Kubik-Rubik
Kubik-Rubik - comment - 7 Jul 2014

@zero-24 @Bakual Updated PR with the "correct" batch button position. Please test it again. Thank you!

avatar Bakual
Bakual - comment - 9 Jul 2014

@Kubik-Rubik Can you try rebasing your branch with staging. Looks like Travis fails for some reason and I think it should work with current staging.

avatar Bakual
Bakual - comment - 10 Jul 2014

Hmm. I get a database error:

1062 Duplicate entry 'http://sermon.hopto.org/http://example.com/old' for key 'idx_link_old' SQL=INSERT INTO `d1y5s_redirect_links` (`old_url`,`new_url`,`referer`,`comment`,`hits`,`published`,`created_date`) VALUES ('http://sermon.hopto.org/http://example.com/old', 'http://example.com/new' ,'', '',0,0, '2014-07-10 18:55:21'),('http://sermon.hopto.org/foo', 'bar' ,'', '',0,0, '2014-07-10 18:55:21') 

The entries are inserted however. So to me it looks like the query is run twice?

avatar Bakual
Bakual - comment - 10 Jul 2014

Another thing I noted but I'm not sure if that's related to your PR and may even be intentional: The old_url is always stored with the domain, if it's not specified it's added automatically. However the new_url is stored as entered.

avatar Kubik-Rubik
Kubik-Rubik - comment - 11 Jul 2014

@Bakual

1.) Can not reproduce the problem with the multiple executions. If an entry already exists, an error "Duplicate entry" is thrown, this is correct.

2.) This is an intentional behavior. The old_url has to be part of the same domain. The redirect URL (new_url) can be an external URL, so I don't add the same domain to it.

avatar Bakual
Bakual - comment - 11 Jul 2014

Can't reproduce it anymore myself. I have no clue what happened yesterday.
Setting to RTC.

avatar Bakual Bakual - reference | - 11 Jul 14
avatar Bakual Bakual - close - 11 Jul 2014
avatar Bakual
Bakual - comment - 11 Jul 2014

Merged into 3.4-dev branch. Thanks!

avatar Bakual Bakual - change - 11 Jul 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-07-11 12:04:58
avatar Bakual Bakual - close - 11 Jul 2014
avatar wilsonge wilsonge - change - 8 Feb 2015
Milestone Added:
avatar Kubik-Rubik Kubik-Rubik - head_ref_deleted - 20 Jun 2015

Add a Comment

Login with GitHub to post a comment