? ? ? Success
Pull Request for # 6962

User tests: Successful: Unsuccessful:

avatar brianteeman
brianteeman
30 Jul 2015

Com_redirect will quickly gather hundreds if not thousands of links if enabled (with gather urls option).

Currently the only way to remove them is to manually select them and use the delete button on the toolbar which is a real pain when you have more than a few hundred.

This PR adds a new toolbar button "Purge Unpublished" which when selected will delete all links that are not published.

To test make sure you enable that the Redirect Plugin is enabled and the option 'Collect URLs' is enabled. Generate some fake urls on the front end. Check to make sure they are displayed in the admin as unpublished links. Press the button and voila they are gone.

(Please be gentle this is my first PR that effects the full MVC triad)

avatar brianteeman brianteeman - open - 30 Jul 2015
avatar brianteeman brianteeman - change - 30 Jul 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 30 Jul 2015
Labels Added: ? ?
avatar rdeutz
rdeutz - comment - 30 Jul 2015

code doesn't looks bad, the query should be changed to

$query = $db->getQuery(true);

$query->delete('#__redirect_links')->where($db->qn('published') . '<> 1');

$db->setQuery($query);
371aee5 30 Jul 2015 avatar brianteeman query
avatar brianteeman brianteeman - change - 30 Jul 2015
Labels Added: ?
avatar brianteeman brianteeman - change - 30 Jul 2015
Category Administration Language & Strings
avatar brianteeman brianteeman - change - 30 Jul 2015
Rel_Number 0 6962
Relation Type Pull Request for
Easy No Yes
avatar justinherrin
justinherrin - comment - 30 Jul 2015

I tested out your code... a nice and welcomed feature if you ask me. I did notice a few things though...

  1. If I had links that were marked as "Archived" status, those also got deleted when I hit the new "Purge" button. I would guess that some folks might want to keep "Archived" links and not have them be purged out.
  2. If the feature is meant to purge out "Archived" links as well, can you update the COM_REDIRECT_CLEAR_SUCCESS language string success message to say "All unpublished, archived, and trashed links have been successfully deleted."?
avatar brianteeman
brianteeman - comment - 30 Jul 2015

To be perfectly honest I didnt even know you could have a status of anything other than enabled/disabled as com_redirects list view really doesnt follow the same behaviour as other components.

My personal view is that it should probably only remove unpublished/disabled links which means that the query needs changing and not the strings - I guess it depends on what others think.

avatar justinherrin
justinherrin - comment - 30 Jul 2015

My personal view is that it should probably only remove unpublished/disabled links which means that the query needs changing and not the strings

I agree with that as well.

I then would suggest updating the models/links.php query delete line to be...

$query->delete('#__redirect_links')->where($db->qn('published') . '= 0');
avatar rdeutz
rdeutz - comment - 30 Jul 2015

didn't thought about it but a "anything = 0" is much more better

avatar Bakual
Bakual - comment - 30 Jul 2015

Should also be faster I think. At least in theory.

avatar brianteeman
brianteeman - comment - 30 Jul 2015

Whatever you decide I will update just let me know

On 30 July 2015 at 18:41, Thomas Hunziker notifications@github.com wrote:

Should also be faster I think. At least in theory.


Reply to this email directly or view it on GitHub
#7586 (comment).

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

avatar Bakual
Bakual - comment - 30 Jul 2015

$query->delete('#__redirect_links')->where($db->qn('published') . '= 0'); is correct if it should only delete unpublished items. Which I think is the most useful behavior.

avatar brianteeman
brianteeman - comment - 30 Jul 2015

I have updated the query as suggested

avatar Bakual Bakual - change - 30 Jul 2015
Milestone Added:
avatar joomdonation
joomdonation - comment - 16 Aug 2015

I think we can improve the code a bit. Instead of store the message in the model and use it in controller (via _message property), the purge method in model should only return true or false. Then the purge method in controller can check and return value of the model and display the corresponding message.

avatar brianteeman
brianteeman - comment - 24 Aug 2015

@joomdonation perhaps but this code is written exactly the same way as similar functionality already in the core

avatar kathastaden kathastaden - test_item - 25 Aug 2015 - Tested successfully
avatar kathastaden
kathastaden - comment - 25 Aug 2015

I have just tested it successfully! Very nice feature.
I also tested, that "archived" links are not deleted with the new Purge Button.

1) Enabled Redirect Plugin and "Collect URLs"
2) Opened Frontend and created fake URLs
3) Marked some of them in the Redirect Plugin as "archived"
4) Clicked on the Button "Purge Unpublished"
5) Only the "unpublished" links were deleted


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

avatar joomdonation
joomdonation - comment - 26 Aug 2015

@brianteeman I made a PR brianteeman#15 to show how the code should look like. I think it's better then the original code (not sure where you see that code in Joomla core but I guess there is not much code like that). Hope the maintainer who check this PR will decide what code to use.

avatar brianteeman
brianteeman - comment - 26 Aug 2015

You can find it in com_installer, com_joomlaupdate

On 26 August 2015 at 15:49, Tuan Pham Ngoc notifications@github.com wrote:

@brianteeman https://github.com/brianteeman I made a PR brianteeman#15
brianteeman#15 to show how the code
should look like. I think it's better then the original code (not sure
where you see that code in Joomla core but I guess there is not much code
like that). Hope the maintainer who check this PR will decide what code to
use.


Reply to this email directly or view it on GitHub
#7586 (comment).

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

avatar FPerisa FPerisa - test_item - 27 Aug 2015 - Tested successfully
avatar FPerisa
FPerisa - comment - 27 Aug 2015

I tested the purge like @kathastaden. It was successfull and worked like expected :+1:

avatar brianteeman
brianteeman - comment - 2 Sep 2015

I've merged the contribution from @joomdonation - I guess it needs retesting now

avatar SiteOp
SiteOp - comment - 19 Sep 2015

It works. Great job. Thanks.


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

avatar SiteOp SiteOp - test_item - 19 Sep 2015 - Tested successfully
avatar zero-24 zero-24 - alter_testresult - 19 Sep 2015 - FPerisa: Not tested
avatar zero-24 zero-24 - alter_testresult - 19 Sep 2015 - kathastaden: Not tested
avatar zero-24 zero-24 - change - 19 Sep 2015
Status Pending Ready to Commit
avatar zero-24
zero-24 - comment - 19 Sep 2015

Works great thanks @brianteeman moving to RTC based on the lest testing.


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

avatar joomla-cms-bot joomla-cms-bot - change - 19 Sep 2015
Labels Added: ?
avatar zero-24 zero-24 - test_item - 19 Sep 2015 - Tested successfully
avatar brianteeman brianteeman - reference | 26d8f45 - 24 Oct 15
avatar roland-d roland-d - close - 24 Oct 2015
avatar roland-d
roland-d - comment - 24 Oct 2015

Thanks everybody, merged into 3.5-dev with commit 26d8f45

avatar roland-d roland-d - change - 24 Oct 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-10-24 07:23:54
Closed_By roland-d
avatar brianteeman brianteeman - head_ref_deleted - 24 Oct 2015
avatar wilsonge wilsonge - change - 17 Jan 2016
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment