• I’ve found that on 6.3.8 / WP 3.6, I can reliably induce a fatal error when using the custom redirection module. The fatal error comes from the final line of this, from ./modules/custom-redirection/custom-redirection.php:

    public function login_form() {
                    $template =& Theme_My_Login::get_object()->get_active_instance();
                    echo wp_original_referer_field( false, $template->get_option( 'instance' ) ? 'current' : 'previous' ) . "\n";
            }

    Investigation showed that $template was null. So I fixed it by changing the line to:

    echo wp_original_referer_field( false, (!empty($template) && $template->get_option( 'instance' )) ? 'current' : 'previous' ) . "\n";

    That doesn’t really feel like the proper solution – it doesn’t seem that $template should be able to be null. But that was good enough for me for now.

    https://www.ads-software.com/plugins/theme-my-login/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve found he same problem in the registration form if enabled custom password.
    If you have two instances (ie registration + login) and if you get an error in the second instance (ie password blank) the first instance get php error for $template==null.

    It’s because the program try to load the current instance (2) while processing the first instance.

    I wrote a fix for this issue. I don’t know if it is the best way, but for the moment it works.

    file: class-theme-my-login.php
    put this code at the beginning after
    public $request_instance;

    /** //rrr
    	 * Holds current instance being worked
    	 *
    	 * @since 6.0
    	 * @access public
    	 * @var int
    	 */
    	private $current_instance;

    add this function:

    /**
    	 * set active instance
    	 * //rrr
    	 * @since 6.3
    	 * @access public
    	 *
    	 * @set Instance field
    	 */
    	public function set_current_instance($set_instance) {
    		$this->current_instance = $set_instance;
    	}

    change this function:

    public function get_instance( $id = 0 ) {
    		if ( isset( $this->loaded_instances[$id] ) )
    			return $this->loaded_instances[$id];
    //rrr
    		elseif ( isset( $this->loaded_instances[$current_instance] ) )
    			return $this->loaded_instances[$current_instance];
    		else
    			return $this->loaded_instances[0];
    	}

    change this function:

    public function load_instance( $args = '' ) {
    		$args['instance'] = count( $this->loaded_instances );
    
    		$instance = new Theme_My_Login_Template( $args );
    
    		if ( $args['instance'] == $this->request_instance ) {
    			$instance->set_active();
    			$instance->set_option( 'default_action', $this->request_action );
    		}
    
    		$this->loaded_instances[] = $instance;
    		//rrr
    		$this->set_current_instance(count($this->loaded_instances)-1);
    
    		return $instance;
    	}

    Thanks remur, your solution works.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP fatal error in custom redirection module, and fix’ is closed to new replies.