Custom Fields
Re-Envisioned
Support General Fatal error after updating Meta Box because of extended class

  • Creator
    Topic
  • #28093
    Resolved Jugibur
    Participant

    Hi,

    I just updated Meta Box and run into the following error in the admin area:
    Fatal error: Uncaught Error: Class 'MBAC\Post' not found in [...]/plugins/dab-admin-columns/PT_Admin_Columns.php:2

    In this file I extended my class from MBAC\Post:
    class PT_Admin_Columns extends \MBAC\Post {

    The cause was that Meta Box was not activated after the update installation. But unfortunately the Admin area doesn't allow me to activate Meta Box (and the extensions) to get my own plugin running.

    So first I had to deactivate my class mentioned above in order to access the admin area again - to then finally be able to activate Meta Box again.

    Question: What is the correct way to prevent such serious errors?

    Thanks!
    Juergen

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #28101
    Long Nguyen
    Moderator

    Hi,

    Simply, you can check if the class exists before doing your stuff.

    if( class_exists( '\MBAC\Post' ) ) { 
        // do your stuff
    }
    
    #28106
    Jugibur
    Participant

    Oh, so easy, thanks for your help!

    I'm now using it in combination mit function_exists('rwmb_meta') like mentioned in the docu.

    #28183
    Jugibur
    Participant

    Sorry to bringt this up again, but since today (?) the (class_exists('\MBAC\Post')) request doesn't work anymore.
    I'm wondering if Meta Box changed something but I think this isn't the case, because extending '\MBAC\Post' works fine.

    Of course I could remove the (class_exists('\MBAC\Post')) request but I whish I can leave it for safty to prevent breaking the site if Admin columns isn't activated.

    Does anybody know why this class_exists request doesn't work anymore?

    Juergen

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.