Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2020-12-12 21:04:44
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
etc wrote #327430:
This plugin has a great potential imo, but is not working on Windows.
Hmm, not surprised – I did ‘fess up to Unix-only testing. This’ll be an interesting(!) exercise, leave it with me.
Offline
#17 2020-12-14 09:36:28
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
Oleg, I don’t have a Windows hosting for testing, but give this one a go.
Offline
Re: adi_detritus - Sweep up the rubbish
Thanks Adi, the errors are gone now and the plugin seems to do its job. I still get many warnings, but that’s quite common in php 8 since it tends to unsilence them:
Warning "mime_content_type(C:\xampp\htdocs\textpattern\textpattern/.git): Failed to open stream: No such file or directory"
in C:\xampp\htdocs\textpattern\textpattern\plugins\adi_detritus\adi_detritus.php at line 413.
Offline
#19 2020-12-14 21:01:26
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
etc wrote #327490:
Thanks Adi, the errors are gone now and the plugin seems to do its job. I still get many warnings, but that’s quite common in php 8 since it tends to unsilence them:
Warning "mime_content_type(C:\xampp\htdocs\textpattern\textpattern/.git): Failed to open stream: No such file or directory"...
Yikes! The corresponding code in the plugin is:
@mime_content_type($path)
- where $path is a non-existing file at the time.
I see from the PHP 8 release notes that:
The @ operator no longer silences fatal errors
I was being a bit lazy with the use of the “@” error-control operator – which I’ll fix – but I can’t quite reconcile a so-called “fatal error” only generating a warning!
Offline
Re: adi_detritus - Sweep up the rubbish
gomedia wrote #327503:
I was being a bit lazy with the use of the “@” error-control operator
If it’s any consolation, core has been hit with this too and we’re gradually working out ways to eradicate the ‘@’ trick.
The proper route is probably try... catch. That means you can then choose to ignore something that you’d previously silenced as a ‘soft’ error in the catch() block. It also gives you the opportunity to actually create the file if it was missing, which is a nice by-product. We’re not there yet in core with our exception handling so we’re tending to just use defensive code around our previous ‘@’ crutches. Not perfect, but it’ll do for now.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#21 2020-12-15 07:13:23
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
etc wrote #327490:
Thanks Adi, the errors are gone now and the plugin seems to do its job. I still get many warnings, but that’s quite common in php 8 since it tends to unsilence them.
No problem, hopefully the unsilenced warnings now keep quiet.
Version 0.4 available for download:
- OS-agnosticism (thanks etc)
- less reliance on the “@” error-control operator WRT PHP 8
Offline
Re: adi_detritus - Sweep up the rubbish
Ace, no more php warnings, thanks.
I’ve counted >100 silenced calls in txp code, though none seems to raise its head in php 8.
Offline
Re: adi_detritus - Sweep up the rubbish
etc wrote #327525:
I’ve counted >100 silenced calls in txp code
Yeah. Like making new classes and retiring old functions, this is one of those things I think we should “fix as we find them” over time.
Sorry for hijacking your thread, Adi.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#24 2021-01-12 02:01:41
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
Version 0.5 is here:
- 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
Offline
#25 2021-05-24 06:35:05
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
Version 0.6 now available:
- 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
Offline
#26 2021-07-01 04:33:43
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
Updated to 0.7 – now with added plugin perusal:
- 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
Offline
Re: adi_detritus - Sweep up the rubbish
Hi Adi,
given the upcoming changes in the categories management (notably that their tree is not rebuilt on each operation any more), would it be possible to add a tree integrity check/repair to adi_detritus? Just in case :-) Thanks.
Offline
#28 2021-11-12 10:47:27
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: adi_detritus - Sweep up the rubbish
etc wrote #331932:
given the upcoming changes in the categories management (notably that their tree is not rebuilt on each operation any more), would it be possible to add a tree integrity check/repair to
adi_detritus? Just in case :-) Thanks.
Sure thing, but could you point me in the direction of categories management changes?
Offline
Re: adi_detritus - Sweep up the rubbish
gomedia wrote #331933:
Sure thing, but could you point me in the direction of categories management changes?
Thanks. The db/tree structure remains unchanged. Currently (4.8.7) the whole tree is rebuilt when some category is altered (inserted/moved/deleted). This keeps the tree sane but yields two db queries per category, which can become rather long for heavily categorized sites (1000 cats or more).
In 4.8.8 these operations are optimized and everything should work fine. But, if someone manipulates categories outside of txp, things can go west. Since the cat tree is not fully rebuilt by core any more, users would be lost in this case. I thought adi_detritus might add a ‘repair’ possibility, just in case. Of course, we could do it in core, but the feature would be of no use for most users.
Few things that adi_detritus might check and rebuild the tree if needed:
- orphan children (parent do not exist)
- wrong nesting (category not within the branch of its parent)
- orphan parents (missing children)
The first point is easy. For the second one, you might test
SELECT child.id FROM txp_category child, txp_category parent
WHERE child.parent=parent.name
AND child.type=parent.type
AND (child.lft<=parent.lft OR child.rgt>=parent.rgt)
The third one looks more tricky, I leave it with you ;-)
Edit: also, starting from some version, category name must be lowercase. Older sites could thus contain invalid category names.
Offline