Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: On creation a category is not listed
Bloke wrote #339830:
I’ve pushed a tentative patch as described above. It’s hacky but it seems to work, and hopefully doesn’t prevent the cache from working in other use cases.
That’s (more or less) what I have tried, but
- it does prevent cache from working, since
getTree()
is called multiple times (category lists/menus) by core - more oddly, it didn’t seem to work in my tests, but I’ve tested rather quickly.
The cache itself is a great query-saver in nested category lists iterations, so I wouldn’t like to dump it. TBC
Offline
Re: On creation a category is not listed
etc wrote #339831:
That’s (more or less) what I have tried, but it does prevent cache from working, since
getTree()
is called multiple times (category lists/menus) by core
Damn. I guess if it’s called recursively on the category page, it’ll pass the refresh
parameter along too.
But it should always use the cache elsewhere (e.g. public tag) because that attribute isn’t passed in so would be false… right? Edit: ah. I see what you mean, we’re calling getTree()
not get_tree()
. Yeah, that will bypass the cache.
If I’ve messed up the logic, by all means fix it or see if you can fathom a better solution. It’s a tough one.
Last edited by Bloke (Yesterday 19:03:28)
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
Re: On creation a category is not listed
Could we tweak the function signature of getTree()
so it takes an optional refresh
param, instead of hard-coding it in the call to get_tree()
? And then pass that parameter as true
only on the Category page? We did a similar thing with get_prefs()
IIRC.
Or is there a better way to approach this? The cache is definitely necessary for performance, so removing it is not an option.
Edit: ugh, getTree()
is already stuffed full of params. I dislike tacking on things like refresh
, because if we want to use it, we have to specify all the other optional params too. Grrr.
Last edited by Bloke (Yesterday 19:17:05)
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
Re: On creation a category is not listed
I’ve reverted the above unworking patch.
At least, for now, the bleeding edge adi_matrix doesn’t trigger this behaviour so we have some breathing room. Maybe core doesn’t need “fixing” and plugin authors just need to make sure they never call getTree()
on the Content > Categories panel, or it will break core behaviour?
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
Re: On creation a category is not listed
Bloke wrote #339834:
Maybe core doesn’t need “fixing” and plugin authors just need to make sure they never call
getTree()
on the Content > Categories panel, or it will break core behaviour?
I think we should fix/enhance it somehow, but am unsure on the way. Maybe, refresh if lastmod has changed between two calls? Dunno
Offline
Re: On creation a category is not listed
etc wrote #339835:
Maybe, refresh if lastmod has changed between two calls?
That sounds like a reasonable assumption. Will that work for all content types?
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
Re: On creation a category is not listed
Bloke wrote #339836:
That sounds like a reasonable assumption. Will that work for all content types?
I hope so, the site lastmod seems to be updated (by core at least) on any category change. So, if a plugin calls getTree()
and then a category is altered, the list should be refreshed on successive calls.
This, unfortunately, includes other content (articles etc) updates, but well..
Offline
Re: On creation a category is not listed
etc wrote #339837:
This, unfortunately, includes other content (articles etc) updates, but well..
That’s okay. I think I’d rather have fresh content delivered and less head scratching than a few milliseconds shaved off the response. The cache works most of the time to keep speed up.
Unless you’re operating Textpattern in a heavy multi-user environment, or using many category-based plugins, I doubt it will make much difference in day-to-day admin.
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
#21 Today 02:08:48
Re: On creation a category is not listed
Bloke wrote #339830:
In the meantime, I’ll probably hack the adi_matrix plugin so it only loads the category tree if it’s on an admin page where it needs it. Edit: Patched;
With that patched adi_matrix plugin, category creation or deletion functionality is restored and so far I don’t see any downsides in the plugin’s working. TY.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
#22 Today 09:51:48
Re: On creation a category is not listed
Oddly, the site lastmod is not updated on category manipulations (create/edit/delete/etc). Is it a bug? Once patched, the cache refresh based on lastmod seems to work.
Offline
#23 Today 10:00:07
Re: On creation a category is not listed
etc wrote #339840:
Oddly, the site lastmod is not updated on category manipulations (create/edit/delete/etc). Is it a bug?
Maybe. Not sure if we just considered publishable content as “modified”. But it does arguably change the site URL structure, so should probably contribute to lastmod.
Once patched, the cache refresh based on lastmod seems to work.
Excellent. That’s a clever approach.
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