Support » Fixing WordPress » in_category (etc) is only working unstable

  • Resolved Aireoreion


    Hello together,

    we’re having a WP site that’s connected to a forum. To establish this connection one task is to post new posts in a certain category to this forum.

    However the plugin using any function to ask for a post’s category is working unstable since one week, i.e. sometimes the WP function does deliver the correct value, sometimes not…

    Tested function, which are unstable:
    in_category, has_category, get_the_category

    MySQL Version: Gentoo Linux mysql-5.0.90-r2
    Datebase: MyISAM

    PHP: 5.3.15-pl0-gentoo
    API: FPM/FastCGI

    Webserver: nginx/1.4.1

    Plugin with unstable function return:

    function getTopicId($data) {
    			if($data['post_status'] == "publish")
    				if(preg_match('#\$id\-([0-9]+)\$\s*#i', $data['post_content'], $matches))
    					$this->topicId = $matches[1];
    					$data['post_content'] = str_replace($matches[0], "", $data['post_content']);
    			return $data;
    		function doTheJob($post_ID, $post) {
    			if($post->post_status == "publish")
    				// Category is News?
    				$isInNews = false;
    				$isInNews = in_category("News", $post_ID);

    Also there is no difference whether revision is aksed first:

    // Revision?
    				$post_rev = wp_is_post_revision($post);
    				$post_ID = $post_rev ? $post_rev : $post_ID;

    The function is registered by

    if (class_exists("WbbPostConn")) {
    	$wbbPostConn = new WbbPostConn();
    if (isset($wbbPostConn)) {
    	// Installer
    	register_activation_hook(__FILE__, array(&$wbbPostConn, 'install'));
    	// The job
    	add_action('save_post', array(&$wbbPostConn, 'doTheJob'), 1, 2);
    	add_filter('wp_insert_post_data', array(&$wbbPostConn, 'getTopicId'));

    If i had a die($isInNews) after
    $isInNews = in_category(“News”, $post_ID);
    and publish a new post within the category “News”, it does return sometimes a 1 (as it should), but often it does not return the 1…

    Any ideas? I mean I could query wp_term_relationships directly, but what is the sense in it?
    Currently we just update the post until the wp-function delivers the correct value oO

    wp_posts: 56k Entries
    wp_postmeta: 194k Entries
    wp_terms: 5922 Entries
    wp_term_relationships: 125k Entries
    wp_term_taxonomy: 5961 Entries

    Thank you very much,

Viewing 1 replies (of 1 total)
  • Hello together,

    an update to the newest verion 3.9.1 did the fix. Now the function is working stable againg

    Thanks WP-Team!

Viewing 1 replies (of 1 total)
  • The topic ‘in_category (etc) is only working unstable’ is closed to new replies.