• Hello, I’m a PHP/Javascript developer with some experience with WP, but I was called in on an emergency by a friend to help fix errors in their current WP site which is built on some crazy theme by this guy:

    dressyourwp.com

    I figured out that the problem is in the version of jQuery being used, so I attempted to add the jQuery migrate to the registered scripts by doing the following change:

    // Add RSS links to <head> section
    	automatic_feed_links();
    
    	// Load jQuery
    	if ( !is_admin() ) {
    
    	   wp_deregister_script('jquery');
    	    wp_register_script('jquery', ("https://code.jquery.com/jquery-1.10.2.js"), false);
    // ADDED THIS LINE ONLY
    	    wp_register_script('jquery-migrate', ("https://code.jquery.com/jquery-migrate-1.2.1.js"), false);
    // END OF EDIT
           wp_enqueue_script( 'jquery.colorbox', get_bloginfo('template_directory') . '/js/jquery.colorbox.js', array( 'jquery' ) );
    	   wp_enqueue_script("prototype", get_bloginfo('template_url') . "/js/prototype.js");
    	   wp_enqueue_script("scriptaculous", get_bloginfo('template_url') . "/js/scriptaculous.js");
    	   wp_enqueue_script("glider", get_bloginfo('template_url') . "/js/glider.js");
     wp_enqueue_script(" validation", get_bloginfo('template_url') . "/js/ validation.js");
    
    	}

    When I uploaded ONLY THAT ONE CHANGE. The entire site now says:

    https://www.albanco.com/

    Fatal error: Call to undefined function automatic_feed_links() in /data/…/htdocs/wp-includes/functions.php on line 4

    I removed that line and uploaded the original functions.php and have the same error… I have no idea what happened or how it happened, but now a simple fix for a big problem has turned in to a MAJOR problem that I can’t seem to figure out.

    I’ve commented out the automatic_feeds_link() function and then another function throws the same error… it’s like editing this single PHP file caused it to “recompile” and break the entire build… which doesn’t make sense since I was under the impression PHP didn’t compile.

    Because of the complexity of the theme and the fact that I didn’t make it, I’m really apprehensive about removing it or changing anything else.

    Can somebody please explain to me what happened? The Theme was loading up fine, i made no other changes… how can a single line (which is then removed) cause such destruction?

Viewing 15 replies - 1 through 15 (of 16 total)
  • I’d try that theme on a local dev instance and check your logs to see what is happening.

    You could also check the file for syntax errors with php -l from the command line.

    Never, EVER, de-register core jQuery!

    Thread Starter goosus

    (@goosus)

    @mattbeck
    Ok, but how could there be syntax errors when I literally added 1 line, then removed it? Unfortunately I don’t have command line access to the host and setting up a local dev environment it’s really practical given the size of the site and the massive differences between my local env and the production one.

    @esmi
    I didn’t de-register anything, I attempted to register the jquery-migrate plugin to make the other jquery plugins work again. I then removed that single line and found that it didn’t make a difference

    Can anyone tell me how WP actually works when a file is changed in the theme? Does it compile something somewhere else? I can’t understand how simply updating a single line in a single file (after making 0 net changes) could break the entire site so completely and irreversibly?

    I didn’t de-register anything

    This snippet:

    // Load jQuery
    	if ( !is_admin() ) {
    	   wp_deregister_script('jquery');
    wp_register_script('jquery', ("https://code.jquery.com/jquery-1.10.2.js"), false);

    could be quite reasonably described as one of the worst sins that it is possible to commit in a WordPress theme. What theme are you using? Where did you download it from?

    Thread Starter goosus

    (@goosus)

    @esmi

    I didn’t put there, there only piece of code that I have added (and them removed) is the 1 line between the comment. The theme originated here:

    dressyourwp.com

    From someone in Chile who I have yet to get in contact with.

    I didn’t make the theme, I didn’t install it, I didn’t modify it or upgrade it. All I did was upload 1 file with 1 line change, then uploaded the same file again changing it back.

    That was all it took to take me from “Oh yeah, I think I fix this little jquery issue you’re having” to “OH SHIT, what the hell is going on here??????”.

    From someone in Chile who I have yet to get in contact with.

    I suggest you try getting in touch with them asap. Or consider switching to another theme. That snippet can stop many plugins from working and can even stop the WP admin area itself in its tracks.

    Thread Starter goosus

    (@goosus)

    @esmi
    I was already told they were incommunicado, which is why I was brought in the first place. So I’m operating on the assumption that he is dead or incapacitated. I can’t just change the theme because I’m pretty sure the page code is tightly coupled to this theme style, though I guess it’d be better than just white screen of death.

    I can see how messing with the core javascript could break a theme, but the error I’m getting persistently is a PHP Fatal Error and that snippet was there and working fine before I did anything.

    Does anyone have any insight in to how WordPress PHP actually operates? Is there some caching functionality of Theme code that updates when a change is made? Is there a compile step? Could the theme have gotten upgraded at some point, but then still semi-work until a theme file was changed?

    I can speculate all day long, so I don’t need help in that, but what I really am looking for is someone with deeper understanding of the WP clockwork who can give me some definite knowledge to work with.

    Does anyone have any insight in to how WordPress PHP actually operates?

    No different from bog-standard PHP.

    Is there some caching functionality of Theme code that updates when a change is made?

    Normally themes do not cache anything. That’s plugin territory.

    Is there a compile step?

    No.

    Could the theme have gotten upgraded at some point, but then still semi-work until a theme file was changed?

    Impossible for us to determine since it is a non-WPORG (and very non-standard) theme.

    Personally, I wouldn’t touch that theme with a barge pole. One of the reasons I asked where the theme was from is that the reputable theme shops will remove any theme that de-registers core jQuery on the spot and, in some cases, have been asked to be notified if any of their themes are caught doing this.

    Thread Starter goosus

    (@goosus)

    Ok, looks like I found the problem:

    <——- THIS GUY

    I uploaded the functions.php for the theme in to the wp-includes and overwrote THAT functions.php file.

    Now, like a semi-clever idiot, I’ve realized that I backed up the wp-content folder, but NOT the wp-includes folder.

    Can anyone tell me how to figure out what version of WP I’ve got installed here (Admin is broken, remember) so I can find the right one to replace it with?

    check the readme.html file in the site root.

    Thread Starter goosus

    (@goosus)

    Ok, thanks guys, moving forward here… not sure if I should create a new post, but after restoring my functions.php (version 3.6.1), I now have a different fatal error:

    Fatal error: Call to undefined function wp_suspend_cache_addition() in /data/11/0/126/127/778290/user/796823/htdocs/wp-includes/cache.php on line 324

    Should I make another post, or do you guys have some more insight?

    Can you access the admin?

    If so, try running a core update and see if that fixes it.

    If not, take a look at the manual (FTP) update instructions in the codex.

    Hope you have a backup of all this.

    Thread Starter goosus

    (@goosus)

    Ok, I have fixed the issue finally…

    Turns out that I was on 3.6, not 3.6.1 (readme said one thing, version.php another?), so I uploaded that functions.php file back to wp-includes and everything is humming again.

    Thanks a lot for all the support, informational and psychological, I was on the edge of insanity.

    If either of you take bitcoin, shoot me an address and I’ll tip you some coin.

    Why are you using an old copy of WordPress (the current version is 3.8.1)? Were you aware that a 3.6.1 site is currently running a very real risk of being hacked? You really need to upgrade WordPress asap.

    If either of you take bitcoin, shoot me an address and I’ll tip you some coin.

    Thank you for the offer but that’s really not necessary. Instead, see if there is the odd 1 or 2 questions on these forums that you could answer. Sort of passing the favour on. ??

    Thread Starter goosus

    (@goosus)

    Honestly, I am not a wordpress guru and like I said, I was doing this as a favor for a friend at the company.

    I will pass along the recommendations, but as always, it’s a matter of budget for them I’m sure. I helped fix their problem now, but I’m not looking to mire myself again by attempting to upgrade their WP with this shoddy theme and unknown plugins.

    Honestly, I may be recommending they move away from WP completely, as this theme is poorly implemented and if they’re changing the theme to a more robust one, may as well do the same with the platform.

    As for helping on the WP forums, I feel like WP support requires such esoteric, non-PHP specific knowledge that I doubt I could contribute more than noise.

    Anyways, thanks again for the help, I’ll pay it forward somehow I’m sure!

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Fatal Errors changing after changing functions.php’ is closed to new replies.