• Resolved freedomsoftwareza

    (@freedomsoftwareza)


    Good day

    I have a code snippet that is suppose to count the amount of posts of a specific user. Where the code checks that the user is logged in it keeps changing one of the special characters “>” to “>”.

    Here is the code:

    function total_post_count() {
    	$current_user = wp_get_current_user();
    	if ( 0 == $current_user->ID ) {
    	    return;
    	} else {
    		$profile_id = um_profile_id();
    		$count = count_user_posts( $profile_id );
    	    echo "<p class='post_count'>" . $count . "</p>";
    	}
    }
    add_shortcode( 'total_post_c', 'total_post_count' );

    The “>” in line 3 is the one that keeps changing. The strange part is that the snippet works for a few days and then suddenly the snippet automatically deactivates due to a syntax error and I find that the “>” was changed to “&GT;”. When this happens all the other snippets also stop working although they are still activated. Once I change the “&GT;” back to “>” then I can activate this snippet and all the other snippets start working again.

    Why would this keep happing at random intervals, sometimes after a few days, and how do I go about preventing this change in the future?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @freedomsoftwareza,

    First thing to check is if you are running the latest version of the plugin, we had an issue with special characters in a previous version that has been fixed.

    Can you please enable error logging from the WPCode Settings to get more details about the error triggering the behaviour you described?

    Thread Starter freedomsoftwareza

    (@freedomsoftwareza)

    Hi @gripgrip

    The plugin version is currently 2.0.8.1. We generally keep everything up to date on a weekly basis.

    I have now turned on the error logging, but I will have to wait until the issue occurs again. I had to fix it again about 2 hours ago after I had to fix it about 5 hours agon as well. Currently it is fine and working, but I will keep an eye on it until it happens again and then send you the report.

    Thread Starter freedomsoftwareza

    (@freedomsoftwareza)

    Hi @gripgrip

    Ok, it finally changed again. I think it happened last week. I have send you the error log using your contact form on your website. Hope that helps, or should I rather post it here?

    Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @freedomsoftwareza,

    Thank you for the update. Yes, that is better as posting the log here might reveal sensitive data on a public forum, I can’t find your message though, can you please try again using the form at https://wpcode.com/contact

    Thank you

    Thread Starter freedomsoftwareza

    (@freedomsoftwareza)

    Hi @gripgrip

    I have send you the information using the contact form on https://wpcode.com/contact.

    Thank you

    Plugin Author Mircea Sandu

    (@gripgrip)

    Got the message, thank you, we’ll look into it and get back to you.

    Plugin Author Mircea Sandu

    (@gripgrip)

    Thank you @freedomsoftwareza, I have found the source of the issue.

    This is actually a side-effect of our plugin automatically disabling some snippets due to an error and we are looking into improving this behaviour to avoid this issue in the future.

    Thread Starter freedomsoftwareza

    (@freedomsoftwareza)

    Thank you very much for the help and effort. I have made changes to the other snippet that could have potentially caused the error. Hopefully this will solve the issue. I will leave this topic open until the end of the week and if the issue does not resurface then I will mark this topic as resolved.

    Thread Starter freedomsoftwareza

    (@freedomsoftwareza)

    Good day

    Unfortunately the issue has not been resolved. The plugin changed the “>” character again even after making the changes as suggested. I changed the code snippet with the mycred_get_users_cred function to mycred_get_users_balance which takes only one parameter. None of the snippets are being deactivated due to errors, all of them are still active, even the snippet with the “>” character that was changed. When this happens, all the other snippets stop working completely even though they are active. When I change the “&GT;” back to “>” then all the snippets suddenly works again, but as I said, none of the snippets throw any error and works perfectly fine when that character is not changed.

    I can send you the error log again if that would help.

    Plugin Author Mircea Sandu

    (@gripgrip)

    Thank you for the update @freedomsoftwareza – yes, please send the updated log via email to take another look.

    The snippet only gets changed if a snippet throws an error so the short-term solution here is to make sure none of the snippets run into errors.

    Thread Starter freedomsoftwareza

    (@freedomsoftwareza)

    I have just send you the email with the error log txt attached and a small explanation with further details.

    Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @freedomsoftwareza,

    I sent you a reply with more details, but I think the issue is not in the snippet you are using but the function you are calling in your snippet is not supposed to be used for logged-out users and thus is throwing an error.

    Plugin Author Mircea Sandu

    (@gripgrip)

    I am going to mark this as resolved for now, please let us know if the issue comes up again.

    Thread Starter freedomsoftwareza

    (@freedomsoftwareza)

    Good day

    I tested the code for a few days and made sure to have all the checks in place every time the issue reoccurs as you suggested, but yesterday it gave me the exact same issue and the error log is virtually exactly the same. None of the solutions seems to work at this stage.

    Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @freedomsoftwareza,

    Thank you for the update and I’m sorry this is still an issue. While the character changing issue is related to the way WPCode handles automatic snippet deactivations in a very specific scenario like you have this is still a side-effect of the snippet generating an error, otherwise it would not end up in that scenario.

    If you don’t mind, I will reach out privately so that we can look at the snippet specifics to prevent this from happening in the future without exposing any specifics of your snippets in a public forum.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Automatically changes special characters’ is closed to new replies.