Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2008-06-17 00:54:49

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,234

Re: smd_where_used: help keep your admin side tidy

Bloke wrote:

If you […] can think of any enhancements, feel free to let me know.

I can’t appraise if the following exceeds what you mean, but let’s see.

I’ve been dealing with thoughts on such matter two weeks ago (leftovers mentioned here). My final plans were to automatically find only orphaned forms (but to get rid of unused plugins this way would be fine for me). Thus my suggestion is a more independent search, so that in principle we won’t have to test for each existing name manually, we don’t have to enter them and we don’t even have to remember them. We’d simply check mode “Find orphans”, select “forms” and press “Go”.
If this results in a list, there should be checkboxes to select … same procedure as we all know from the forms tab.

Is this something within reach?

BTW, I’d apply for beta testing this shredder ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#22 2008-06-17 05:04:06

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: smd_where_used: help keep your admin side tidy

Stef

I think Uli’s idea re automatic location of orphaned “whatnots” is a good one. Should be quite easy to do too. Not too sure about automatically deleting them though — some plugins have uninstall routines that would need running to really clean things up.

Maybe you could present a list of orphans and have some checkboxes and an action select or something. Kind of like the Txp articles tab.


Steve

Offline

#23 2008-06-17 07:39:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,829
Website

Re: smd_where_used: help keep your admin side tidy

Not a bad idea Uli/Steve. I can probably rustle up some way of showing what’s not used and leave the decision as to what to do with them to you.

Leave it with me.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#24 2008-06-17 10:38:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,829
Website

Re: smd_where_used: help keep your admin side tidy

OK, so my SQL brain is not quite as good as I hoped it would be.

Dealing with uli’s request I need to make up a series of queries that pull out records that have no reference to a particular name in any other (reasonable) table. I have narrowed it down to these queries:

  1. Every page that is not assigned from a section
  2. Every stylesheet that is not assigned from a section
  3. Every section that has no articles in it (excluding ‘default’ which cannot have an article anyway)
  4. Every plugin that is not referenced from an article (body/excerpt) or another form or page
  5. Every form that has no reference to it in any article (body/excerpt/override) or another form or page

The first three are easy using LEFT/RIGHT JOINs and some IS NULL magic. Well, “easy” but it makes no provision for things like rvm_maintenance which uses an “error_503” page and a “maintenance” stylesheet that are only referenced from a form/within the plugin itself, so they are incorrectly flagged as orphans. Guess we’ll have to live with things like that. Also, should error_default be ignored or does anyone actually ever assign it to a section?

I am, however, struggling with query|ies, joins or subselects for the last two. If anyone has any glimmers of SQL knowledge in this regard, please would you put me out of my misery and shove me in the right direction. I don’t particularly want to grab every form, page and article then iterate over them all one by one to see if any of them reference each other :-\ My intuition says there’ll be some SQL skulduggery that will ease the process, I just can’t figure what it is.

Many thanks in advance.

Last edited by Bloke (2008-06-17 10:39:57)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#25 2008-06-17 17:17:11

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,234

Re: smd_where_used: help keep your admin side tidy

3. Every section that has no articles in it

I’ve one section with individual unique goods (i.e. articles) that can well be sold out at a certain point in time. This section shouldn’t be deleted in a moment of dullness, though. My idea is to flag certain things, f.i. by using the smd_vars table. Could also be used to flag plugins requiring a de-installation.

  1. should per se exclude plugins type 1 and 2 (you’ll have meant so, Stef).

And one more thing to consider: I remember there are some plugins out there that use names for functions/tags diverging from their own ones (like “xyz_img_sel” and “xyz_image_selector”). That will be more difficult, I think.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#26 2008-06-17 19:09:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,829
Website

Re: smd_where_used: help keep your admin side tidy

uli wrote:

I’ve one section with individual unique goods (i.e. articles) that can well be sold out at a certain point in time.

Unfortunately, the plugin cannot legislate for that. If it’s empty, it gets flagged. I leave it up to the site author to make sure they don’t delete stuff they really want, which is why the search results in this mode have a heading labelled “Possible orphans” ;-)

fwiw, I don’t think adding a ‘delete’ mechanism directly from this plugin is a particularly good idea, but I’m willing to be corrected. There is a link to each suspected item for you to check it over first and I think deletion should be handled via the normal TXP admin page. My reasoning is partly because of situations just like you highlighted; partly because it is too easy to click an ‘x’ in a column to the left of the one you meant to click the link for; and partly (mostly!) because it’s a pig to code. The ‘x’ system would have to be done manually because I cannot re-use the dLink() functionality in the core without writing my own delete function. And I think the checkboxes/with-selected->delete thing can only be applied to tables with unique rows.

  1. should per se exclude plugins type 1 and 2

Definitely.

I remember there are some plugins out there that use names for functions/tags diverging from their own ones… That will be more difficult, I think.

Yes. For “more difficult”, read “impossible without searching the plugin source code”. However, I have an idea about that.

As it stands, I have the code working and it’s potentially useful functionality (thank you again for the idea). Unfortunately the code that produces it is currently as pretty as Peter Beardsley so it needs refactorisation before I let anyone see it.

Last edited by Bloke (2008-08-10 07:55:33)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#27 2008-06-17 22:00:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,829
Website

Re: smd_where_used: help keep your admin side tidy

Alrighty, give v0.14 | compressed a shot.

It adds tentative ‘orphan’ search functionality when you leave the Find box empty and hit ‘Search’. It’s not perfect and could probably do with some feedback from prolonged use to hone it towards greatness. Please skim the Notes in the plugin help to find the gotchas.

The code is prettier than earlier — perhaps elevated to a slightly gormless Matt Le Tissier — but I could not find a way to make the form and plugin queries work all-in-one. Instead of programmatically hunkering through the result sets I cheated and made hundreds of little calls to the database. And I mean hundreds; on an average-sized site you’re probably looking at 150 – 200 or more.

I’ve tried to be a bit intelligent about it and abort the calls early each time it finds a match, but it still hammers the database and for this I apologise. It is remarkably quick considering what it’s doing, but if that causes serious performance problems or someone is worried about the sheer number of calls in such a short space of time, let me know and I’ll try to find a way to re-re-factorise the logic. Code donations to fix my half-assed SQL skills are always welcome.

Until next time we meet… enjoy!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#28 2008-06-17 22:12:27

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_where_used: help keep your admin side tidy

Stef, Thanks for this plug-in.
When I first saw the thread I thought “Oh, I won’t need that.”
Then I switched my site to testing mode and noticed I had a deprecated tag in use somewhere.
Moments later I’ve fixed it with your help.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#29 2008-06-17 22:17:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,829
Website

Re: smd_where_used: help keep your admin side tidy

MattD wrote:

… noticed I had a deprecated tag in use somewhere. Moments later I’ve fixed it with your help.

*beam* glad it’s been of service.

When I first saw the thread I thought “Oh, I won’t need that.”

That’s a good point. I’ve updated the topic title to better reflect what it does after 4 revisions in 24 hours. Ta!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#30 2008-06-17 22:23:17

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_where_used: help keep your admin side tidy

Hi Bloke,
don’t want to hijack this thread. I just chimed in to share with you some ugly football players pictures, in case you run out of them in future plug-in developments.

Jairo Patiño
‘Carucha’ Muller (“Carucha” means something like “funny/ugly face”)
Carlitos Tevez


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB