主題: XMLRPC metaWeblogNewPost($args) 的一个BUG 作者: maomaode 於 十一月 27, 2006, 01:28:33 下午 引用 if ( $catList != NULL ) { foreach( $catList as $categoryName ) { foreach( $cats as $blogCategory ) { $categoryName = trim($categoryName); if ( strcmp( $categoryName, $blogCategory->getName()) == 0 ) { $categories[] = $blogCategory->getId(); } } } } else { // if no category, let's pick a random one $blogCategory = array_pop( $cats ); $categories[] = $blogCategory->getId(); } 应该改成: 引用 if ( !empty($catList) ) 否则如果输入的文章分类, 如果不存在的时候, 会发生错误{ foreach( $catList as $categoryName ) { foreach( $cats as $blogCategory ) { $categoryName = trim($categoryName); if ( strcmp( $categoryName, $blogCategory->getName()) == 0 ) { $categories[] = $blogCategory->getId(); } } } } if ( empty($catList) || empty($categories)) { // if no category, let's pick a random one $blogCategory = array_pop( $cats ); $categories[] = $blogCategory->getId(); } |