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.
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:
function 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:
*1/3::wiki page *11/12::wiki page
I 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:
a: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:
a: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.
To help developers solve the bug, we kindly request that you demonstrate your bug on a show2.tiki.org instance. To start, simply select a version and click on "Create show2.tiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show2.tiki.org.
To help developers solve the bug, we kindly request that you demonstrate your bug on a show.tikiwiki.org instance. To start, simply select a version and click on "Create show.tikiwiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show.tikiwiki.org.
filename | created | hits | comment | version | filetype | ||
---|---|---|---|---|---|---|---|
No attachments for this item |