Fatal error when wp_login_url is called from admin backend
-
Hello,
When anything (plugin or theme) requests
wp_login_url
or similar function from the admin backend (ie, whenis_admin() == true
) the it generates a fatal error. Here is a stack trace:[30-May-2014 21:13:31 UTC] PHP Fatal error: Call to a member function get_page_permastruct() on a non-object in D:\iPanelThemes\wordpress\wp-includes\link-template.php on line 356 [30-May-2014 21:13:31 UTC] PHP Stack trace: [30-May-2014 21:13:31 UTC] PHP 1. {main}() D:\iPanelThemes\wordpress\wp-admin\admin-ajax.php:0 [30-May-2014 21:13:31 UTC] PHP 2. require_once() D:\iPanelThemes\wordpress\wp-admin\admin-ajax.php:20 [30-May-2014 21:13:31 UTC] PHP 3. require_once() D:\iPanelThemes\wordpress\wp-load.php:29 [30-May-2014 21:13:31 UTC] PHP 4. require_once() D:\iPanelThemes\wordpress\wp-config.php:110 [30-May-2014 21:13:31 UTC] PHP 5. do_action() D:\iPanelThemes\wordpress\wp-settings.php:236 [30-May-2014 21:13:31 UTC] PHP 6. call_user_func_array() D:\iPanelThemes\wordpress\wp-includes\plugin.php:470 [30-May-2014 21:13:31 UTC] PHP 7. IPT_FSQM_Loader->init_admin_menus() D:\iPanelThemes\wordpress\wp-includes\plugin.php:470 [30-May-2014 21:13:31 UTC] PHP 8. IPT_FSQM_All_Forms->__construct() D:\iPanelThemes\wordpress\wp-content\plugins\wp-fsqm-pro\classes\class-ipt-fsqm-loader.php:144 [30-May-2014 21:13:31 UTC] PHP 9. IPT_FSQM_Form_Elements_Admin->__construct() D:\iPanelThemes\wordpress\wp-content\plugins\wp-fsqm-pro\classes\class-ipt-fsqm-admin.php:603 [30-May-2014 21:13:31 UTC] PHP 10. IPT_FSQM_Form_Elements_Base->__construct() D:\iPanelThemes\wordpress\wp-content\plugins\wp-fsqm-pro\classes\class-ipt-fsqm-form-elements-admin.php:28 [30-May-2014 21:13:31 UTC] PHP 11. IPT_FSQM_Form_Elements_Base->init() D:\iPanelThemes\wordpress\wp-content\plugins\wp-fsqm-pro\classes\class-ipt-fsqm-form-elements-base.php:57 [30-May-2014 21:13:31 UTC] PHP 12. IPT_FSQM_Form_Elements_Base->get_default_settings() D:\iPanelThemes\wordpress\wp-content\plugins\wp-fsqm-pro\classes\class-ipt-fsqm-form-elements-base.php:70 [30-May-2014 21:13:31 UTC] PHP 13. wp_login_url() D:\iPanelThemes\wordpress\wp-content\plugins\wp-fsqm-pro\classes\class-ipt-fsqm-form-elements-base.php:1159 [30-May-2014 21:13:31 UTC] PHP 14. site_url() D:\iPanelThemes\wordpress\wp-includes\general-template.php:350 [30-May-2014 21:13:31 UTC] PHP 15. get_site_url() D:\iPanelThemes\wordpress\wp-includes\link-template.php:2482 [30-May-2014 21:13:31 UTC] PHP 16. apply_filters() D:\iPanelThemes\wordpress\wp-includes\link-template.php:2524 [30-May-2014 21:13:31 UTC] PHP 17. call_user_func_array() D:\iPanelThemes\wordpress\wp-includes\plugin.php:192 [30-May-2014 21:13:31 UTC] PHP 18. Theme_My_Login->site_url() D:\iPanelThemes\wordpress\wp-includes\plugin.php:192 [30-May-2014 21:13:31 UTC] PHP 19. Theme_My_Login::get_page_link() D:\iPanelThemes\wordpress\wp-content\plugins\theme-my-login\includes\class-theme-my-login.php:581 [30-May-2014 21:13:31 UTC] PHP 20. get_permalink() D:\iPanelThemes\wordpress\wp-content\plugins\theme-my-login\includes\class-theme-my-login.php:809 [30-May-2014 21:13:31 UTC] PHP 21. get_page_link() D:\iPanelThemes\wordpress\wp-includes\link-template.php:139 [30-May-2014 21:13:31 UTC] PHP 22. _get_page_link() D:\iPanelThemes\wordpress\wp-includes\link-template.php:322
As you can see it originated from a plugin calling
wp_login_url()
which in return got filtered bysite_url
and thereby calling a tml function which in return callsget_permalink()
->get_page_link()
->_get_page_link()
. I did a little investigation and found that during the time when_get_page_link()
was called,$wp_rewrite
was completely empty (null
). So that is causing the problem. I am yet to find the source of this conflict, but an solution is to apply all tml filters only on frontend. Under classTheme_My_Login::load()
I added a conditional statementif ( ! is_admin() ) : add_filter( 'site_url', array( &$this, 'site_url' ), 10, 3 ); add_filter( 'logout_url', array( &$this, 'logout_url' ), 10, 2 ); add_filter( 'single_post_title', array( &$this, 'single_post_title' ) ); add_filter( 'the_title', array( &$this, 'the_title' ), 10, 2 ); add_filter( 'wp_setup_nav_menu_item', array( &$this, 'wp_setup_nav_menu_item' ) ); add_filter( 'wp_list_pages_excludes', array( &$this, 'wp_list_pages_excludes' ) ); add_filter( 'page_link', array( &$this, 'page_link' ), 10, 2 ); endif;
and it solved (ugly hack). Could you please look into this?
- The topic ‘Fatal error when wp_login_url is called from admin backend’ is closed to new replies.