WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] in_category (etc) is only working unstable (2 posts)

  1. Aireoreion
    Member
    Posted 1 month ago #

    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

    Stats:
    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,
    ---Air

  2. Aireoreion
    Member
    Posted 3 weeks ago #

    Hello together,

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

    Thanks WP-Team!

Reply

You must log in to post.

About this Topic