Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other WordPress 3.3 toolbar covers php errors

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35645
    gilgimech
    Participant

    If anyone hasn’t noticed yet the WordPress 3.3 toolbar (formally the admin head and admin bar) covers the first few lines of php errors. That’s pretty annoying. I’ve got a fix for it though.

    Put this code in your functions.php file.


    if ((error_reporting() && is_admin())) {
    echo '

    ';
    return;
    }

    What it does is it adds padding to the body if there is an error, so everything except the toolbar get pushed down. Allowing you to see the errors. I haven’t done extensive testing of this though, but it seems to be working so far.

    Has anyone else come up with a fix for this issue yet?

    #92763
    TheDoc
    Member

    That’s interesting. I would assume if there was an error the toolbar shouldn’t even load.

    #92764
    gilgimech
    Participant

    Yeah, I don’t think the WordPress team considered that. I posted something about this issue on the wordpress.org forums and the mod’s answer was to use error logs, but then nothing is perfect. Bugs like that are to be expected when there are major changes like the toolbar.

    #94441
    gilgimech
    Participant

    If anyone else had any issue with this too. I’ve come up with a couple of solutions.
    Here’s a plugin that will disable the toolbar.
    http://wordpress.org/extend/plugins/old-skool-admin-head/

    This code will have the errors output in admin alerts


    function customError($errno, $errstr, $errfile, $errline){
    $errorType = array (
    E_ERROR => 'ERROR',
    E_CORE_ERROR => 'CORE ERROR',
    E_COMPILE_ERROR => 'COMPILE ERROR',
    E_USER_ERROR => 'USER ERROR',
    E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR',
    E_WARNING => 'WARNING',
    E_CORE_WARNING => 'CORE WARNING',
    E_COMPILE_WARNING => 'COMPILE WARNING',
    E_USER_WARNING => 'USER WARNING',
    E_NOTICE => 'NOTICE',
    E_USER_NOTICE => 'USER NOTICE',
    E_DEPRECATED => 'DEPRECATED',
    E_USER_DEPRECATED => 'USER_DEPRECATED',
    E_PARSE => 'PARSING ERROR'
    );
    if (array_key_exists($errno, $errorType)) {
    $errname = $errorType[$errno];
    } else {
    $errname = 'UNKNOWN ERROR';
    }
    ob_start();?>

    Error: []
    on line

    echo ob_get_clean();
    }
    set_error_handler("customError", E_ERROR ^ E_CORE_ERROR ^ E_COMPILE_ERROR ^
    E_USER_ERROR ^ E_RECOVERABLE_ERROR ^ E_WARNING ^ E_CORE_WARNING ^
    E_COMPILE_WARNING ^ E_USER_WARNING ^ E_NOTICE ^ E_USER_NOTICE ^
    E_DEPRECATED ^ E_USER_DEPRECATED ^ E_PARSE );

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.