Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-10-22 05:24:36

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

adi_detritus - Sweep up the rubbish

Summary

Building sites are great places to play, but who likes to tidy up?

This is where adi_detritus comes in. It’ll scour your website’s filesystem and plugins for items that are redundant, superfluous or even absent.

It’s a bit like Stef’s smd_where_used plugin’s lint functionality but instead for the website filesystem. Perhaps “what is that?” or “where is it?” are better indications of its function.

No changes are made. It’s up to the website administrator to decide what to do with the information presented.

See the help supplied with the plugin, or have a look online. You can download the latest version from here.

Requirements

Textpattern v4.7+.

Version history

  • 0.7
    • new: removed objections to all .webmanifest files
    • new objections your honour: textpattern/jquery.js, textpattern/txp_img (4.6+)
    • new: check writability of image thumbnails
    • new: TXP 4.8+ plugin file & manifest checks – type/order/code mismatches
    • improved: slightly less whingey about images
  • 0.6
    • fix: removed objection to INSTALL.txt & UPGRADE.txt (for TXP 4.8.5)
    • fix: “Missing” language string name change (for TXP 4.8)
    • fix: improved event discovery
    • new: warnings for uninstalled plugins that have files in textpattern/plugins dir
  • 0.5
    • fix: double notifications for .nodelete
    • fix: removed objection to sitemap.xml (thanks bici)
    • new: browserconfig.xml & site.webmanifest awareness
    • new: check for .swf files
    • new: textpattern/plugins directory checks
    • more OS-agnosticism
  • 0.4
    • OS-agnosticism (thanks etc)
    • less reliance on the “@” error-control operator WRT PHP 8
  • 0.3
    • more orphans: images/.nodelete, textpattern/license.txt, textpattern/lgpl-2.1.txt (not present in TXP 4.6+)
    • fix: incorrect default pref values for unlinked file exclusions
    • fix: remove “style” from default style directories list
    • fix: missing language strings
    • new: redundant preference checks
  • 0.2
    • anti-caching measure
    • fix for unescaped quotes in db queries (thanks peterj)
  • 0.1
    • initial release

Feedback

Comments are most welcome.

Developer beer vouchers

If you find this plugin useful, please consider donating to the Textpattern development team.

Last edited by gomedia (2021-07-01 04:30:38)

Offline

#2 2020-10-22 07:16:45

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,058
Website

Re: adi_detritus - Sweep up the rubbish

ohh … this is naughty. running it on my old-old-old local TXP playground site result is soo many warnings :-(

Great help file !

Thank you for this; I am sure I and others will find this useful to keep the file-servers a little cleaner.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#3 2020-10-22 08:40:46

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: adi_detritus - Sweep up the rubbish

Nice one! Thank you.


BB6 Band My band
Gud One My blog

Offline

#4 2020-11-24 05:30:05

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 99

Re: adi_detritus - Sweep up the rubbish

This is a beauty. Turing up all sorts of tumbleweeds on an 8 year old site I’m redoing. I am getting repeated errors at the top of the admin page of this nature – apostrophes in messy file names seem to be tripping something up?

User_Error "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'm a Dirty Dinosaur Review.pdf'' at line 1"
in /home/abcde/2020dev/textpattern/lib/txplib_db.php at line 448.

Offline

#5 2020-11-24 05:51:38

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_detritus - Sweep up the rubbish

peterj wrote #326998:

… apostrophes in messy file names seem to be tripping something up?

Yep, tripping up my crappy coding. Leave it with me.

Offline

#6 2020-11-24 06:59:08

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_detritus - Sweep up the rubbish

Try this one … it’s also got an anti-page-caching measure.

Offline

#7 2020-11-24 07:21:21

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 99

Re: adi_detritus - Sweep up the rubbish

Thanks, working nicely now.

Offline

#8 2020-12-07 09:37:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: adi_detritus - Sweep up the rubbish

This is such a cool idea. It takes smd_where_used’s ‘orphan’ checking to another level. I’m going to give it a spin later.

Out of curiosity, does it scan the prefs or lang tables to find strings that are owned by plugins that are no longer installed? If not, could it? I’m not sure if there’s a use case here but if a plugin doesn’t tidy up after itself (ahem, *cough* smd_article_stats) and is deleted then it can leave orphans.

Would be nice to find a way to tidy those, but I’m not sure how it can be done practically. Taking article stats as an example, it uses smd_artstat as a prefix (a holdover from when we only allowed 11 characters for the event) so hunting for prefs in a plugin that doesn’t exist, using an event that may not match the plugin name is tricky!

However, for plugins that are installed, it should be relatively easy to find strings and prefs that do exist by either matching the owner (in terms of lang strings) the event (for prefs) or checking the names themselves for keys that are prefixed with the plugin name. Exclude any strings and prefs that are owned by core, then display the inverse as ‘possible orphans’.

That won’t help in the specific case of smd_article_stats because it’s a stupid anomaly and I’ll need to fix it one day. So that’ll show up as a false positive. But for other, more well-behaved plugins, it might be a nice feature to help tidy up after slapdash plugin authors such as myself.

No worries if it’s out of scope or too tricky (or the plugin does it already). Just popped in my head while answering a post on this subject.


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

#9 2020-12-07 09:48:52

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_detritus - Sweep up the rubbish

Bloke wrote #327317:

Out of curiosity, does it scan the prefs or lang tables to find strings that are owned by plugins that are no longer installed? If not, could it? I’m not sure if there’s a use case here but if a plugin doesn’t tidy up after itself (ahem, cough smd_article_stats) and is deleted then it can leave orphans.

Hmm, interesting. I’ll ponder further …

Offline

#10 2020-12-11 23:05:47

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_detritus - Sweep up the rubbish

Version 0.3 is available for download:

  • more orphans: images/.nodelete, textpattern/license.txt, textpattern/lgpl-2.1.txt (not present in TXP 4.6+)
  • fix: incorrect default pref values for unlinked file exclusions
  • fix: remove “style” from default style directories list
  • fix: missing language strings
  • new: redundant preference checks

Thanks to Stef for the preference check inspiration and for being the guinea pig beta tester.

Language string checking has been dropped in the too-hard-basket for the moment, but never say never!

Last edited by gomedia (2020-12-11 23:06:03)

Offline

#11 2020-12-12 07:04:58

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,072
Website Mastodon

Re: adi_detritus - Sweep up the rubbish

/home/bici/apps/topgoods_app/sitemap.xml (Not recognized)

should this file be flagged?


…. texted postive

Offline

#12 2020-12-12 07:18:40

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: adi_detritus - Sweep up the rubbish

bici wrote #327424:

/home/bici/apps/topgoods_app/sitemap.xml (Not recognized)

should this file be flagged?

If “sitemap.xml” is a standard filename that all TXP websites use then I can add it to the exemptions list. But if it’s a user-chosen filename referenced by an HTML tag in the website itself, then adi_detritus is currently not that clever.

You can always add it to the “Ignore filesystem items” preference.

Offline

Board footer

Powered by FluxBB