Support

Account

Home Forums Backend Issues (wp-admin) Uncaught TypeError in Admin Backend

Solved

Uncaught TypeError in Admin Backend

  • Recently upgraded WooCommerce to the latest build, and I believe WP as well had a recent one that was installed. In any event, somehow have caused a new issue/conflict that seems only to be happening on the /wp-admin side. Unfortunately the exception getting thrown is causing some functionality problems as far as other JS usage/buttons in certain places, so would be great if anyone can point me in the right way.

    Currently upon pageload of the admin side, /wp-content/plugins/advanced-custom-fields//js/input.min.js is throwing the following error: Uncaught TypeError: Cannot read property ‘post_id’ of null

    Current jQuery include is via: https://code.jquery.com/jquery-2.2.0.min.js

    Let me know if anyone has any suggestions! Feels like I’ve fixed something similar before once some time back, but can’t really recall.

  • Looking at the minified JS code, it seems the null variable seems to be getting caught right around here…

    if(acf.screen.post_id=acf.o.post_id,acf.screen.nonce=acf.o.nonce,$(“#icl-als-first”).length>0){

  • Nothing, eh? Always fun when a simple core update to WP or WooCommerce totally incapacitates a plugin. Will have to disable this completely for now I guess and navigate away, one less dependency that can spontaneously combust.

  • Hi @bluetoothtiger

    I’m afraid I can’t reproduce this issue. Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Fifteen) with other plugins deactivated? If the issue disappears, then you can activate the theme and plugins one by one to see which one causes the issue.

    If the issue persists, please contact [email protected] and provide them with some screenshots, your ACF and WordPress version, and step by step to reproduce the issue.

    Thanks!

  • Not real sure what the cause/conflict is, but certainly didn’t have multiple days to spend trying to figure out the cause on a production environment.

    This was the workaround implemented. Seems to be working fine now in the backend as far as I can tell, and at least not breaking half the javascript functionality on the page when it threw the null error.

    Starting at line 987 of the non-minified version of input.js, added a simple null catch and exit.

    
    	$(document).ready(function(){
    		
    		/* added this condition, since acf.o was null at certain points for some reason when in the admin backend */
    		if (acf.o == null) {
    			return;
    		}
    		
    		// update post_id
    		acf.screen.post_id = acf.o.post_id;
    		acf.screen.nonce = acf.o.nonce;
    

    Hope this at least helps someone else in a similar situation.

  • Hi @bluetoothtiger

    Thanks for sharing your fix. It sure will help anyone who has the same problem.

    Thanks!

  • I’m having this same issue. When I have a custom field that is an image upload, it gives me the following error:

    
    post.php?post=4&action=edit:4035 Uncaught ReferenceError: acf is not defined
        at post.php?post=4&action=edit:4035
    (anonymous) @ post.php?post=4&action=edit:4035
    input.min.js?ver=4.4.11:1 Uncaught TypeError: Cannot read property 'post_id' of null
        at HTMLDocument.<anonymous> (input.min.js?ver=4.4.11:1)
        at i (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mo…:2)
        at Object.fireWith [as resolveWith] (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mo…:2)
        at Function.ready (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mo…:2)
        at HTMLDocument.K (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-ui-mo…:2)
Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Uncaught TypeError in Admin Backend’ is closed to new replies.