首页 > 应用开发 > IT综合 > Jive笔记8--查询的Bug (转)
// Forum filter -- we can ignore filtering if we are searching all // forums in the system. if (forums.length != 0 && factory.getForumCount() != forums.length) { String[] forumIDs = new String[forums.length]; for (int j=0; j public Query createQuery() { // Special implementation of this method so that we can deteRmine the // actual list of forums that the user has permissions to search over. ArrayList forumList = new ArrayList(); for (Iterator iter = forums(); iter.hasNext(); ) { forumList.add(iter.next()); } Forum [] forums = new Forum[forumList.size()]; for (int i=0; i
问题就在这个sb的if()判断!!
这里牵涉到ForumFactoryProxy.createQuery()里面的一段代码
从这段代码可以看到,获得了用户可访问的forums,传递给DBQuery。
这样似乎可以限制用户在其可访问的forums中搜索。
所以有了DBQuery::executeQuery()中的哪个if(判断),意思是:如果传入的forums和(DBForumFactory)factory.getForumCount()相同,则认为查询所有Forums,不做判断。否则,是在某几个forum中查询。
上面的逻辑很对,,但是加了Category以后就出问题了。
首先,为了兼容factory.getForums(),factory.getForumCount()都是调用了RootForumCategory的方法,也就是说,只返回了root forum.
你发现问题了么?
没错,按照上面的判断,我选择了forum(2),此时系统有1个rootForum,显然if(factory.getForumCount() != forums.length)这样的判断是不成立的。所以“在forum(2)中查询这个条件”这个条件就被忽略了。于是,返回了不应该出现的查询结果。
究其根本的原因有2个,(1)jive2.5后来加入的Category以后同时为了保证兼容,而带来的问题;(2)搜索的权限控制问题。
顺便带一句,jive官方网站的论坛没有rootForum.所以,上面的判断永远成立。于是这个问题就被“隐藏起来”了。
解决办法
自己想!!!
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10752019/viewspace-958265/ ,如需转载,请注明出处,否则将追究法律责任。