Category Defaults don't work as designed
- Status
- Closed
- Subject
- Category Defaults don't work as designed
- Version
- 9.x
- Category
- Usability
- Feature
- Category
- Resolution status
- Fixed or Solved
- Submitted by
- David Carter
- Lastmod by
- Ushindi Gedeon
- Rating
- Description
So I've been vexed by the "category_defaults" tiki preference settings since they got expanded in version 9.x to include object name and object type. Supposedly you can add filters to set the default category based on the object name using a regex, and additionally set the default category to only assign if the object type is a wiki page. This is a fantastic feature! However, I've never been able to get it to work. The syntax is confusing and poorly documented (naturally), but the real problem is that even when you get it exactly right, the feature's still broken.
I am not a coder, and even though I have commit privs, I don't think I'm prepared to "fix" this in the source, so maybe somebody can help the community out with this information.
- Solution
- Workaround
After revisiting the problem today, I have come up with two issues that are at the root of this problem. The first and most painfully obvious is that the object name and object type variables for this setting are nulled out in the array that is build for them by the Manipulator.php file located at /lib/core/Category/. On line 31, you've got:
Manipulator.phpCopy to clipboardfunction addRequiredSet(array $categories, $default, $filter=null, $type=null)Once I took the "=null" bits out it actually did parse these two elements into the array. Brilliant. No more beating my head against a wall.
The second issue is that the preference box at Admin > Categories for Category Defaults doesn't record the setting properly. I had to go look in my database using phpMyAdmin and see what was actually written there in the tiki_preferences table for the category_defaults row. Apparently the first line of the text area gets parsed incorrectly, and if you don't have any object name filter to specify, it chokes on the second colon and takes your input for object type as being the variable for object name. I was able to replicate this bug in both 9.3 and 9.4. The second line of text (and presumably additional lines - I only checked two) get parsed correctly, but since the first line is munged up, the whole thing breaks.
For example, in my environment this is the correct setting I was striving for in Category Defaults:
Category DefaultsCopy to clipboard*1/3::wiki page *11/12::wiki pageI don't have any object name filter, but I only want the categories assigned to wiki pages. Unfortunately, saving this data records the following in the database:
Broken category_defaultsCopy to clipboarda:2:{i:0;a:4:{s:10:"categories";a:1:{i:0;s:2:"*1";}s:7:"default";s:1:"3";s:6:"filter";s:11:":wiki page ";s:4:"type";s:0:"";}i:1;a:4:{s:10:"categories";a:1:{i:0;s:3:"*11";}s:7:"default";s:2:"12";s:6:"filter";s:0:"";s:4:"type";s:9:"wiki page";}}As you can see, the first "filter" setting is ":wiki page" with a line feed and carriage return embedded behind it. Compare it to the second line, which gets parsed correctly. I had to manually edit my record to be like this:
Working category_defaultsCopy to clipboarda:2:{i:0;a:4:{s:10:"categories";a:1:{i:0;s:2:"*1";}s:7:"default";s:1:"3";s:6:"filter";s:0:"";s:4:"type";s:9:"wiki page";}i:1;a:4:{s:10:"categories";a:1:{i:0;s:3:"*11";}s:7:"default";s:2:"12";s:6:"filter";s:0:"";s:4:"type";s:9:"wiki page";}}This, my friends, works as expected.
Why does the text area input not get parsed correctly into the database for the first line? That is an exercise for the reader, I guess.
- Importance
- 5
- Easy to solve?
- 5
- Priority
- 25
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show2.tiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show.tikiwiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Ticket ID
- 4442
- Created
- Wednesday 24 April, 2013 20:47:53 UTC
by David Carter - LastModif
- Saturday 04 July, 2026 21:30:47 UTC