Page MenuHomePhabricator

ParserFunctions function getExprParser does not return a pre-existing handle to the Expr parser if it exists
Closed, ResolvedPublic

Description

Author: rtdean

Description:
Patch to correct issue as described

The code for the function getExprParser returns a handle to a new instance of ExprParser on every call, rather than a pre-existing handle if one is already set.

Here is the current code:

function &getExprParser() {
    if ( !isset( $this->mExpr ) ) {
        if ( !class_exists( 'ExprParser' ) ) {
            require( dirname( __FILE__ ) . '/Expr.php' );
        }
        $this->mExprParser = new ExprParser;
    }
    return $this->mExprParser;
}

The variable checked in the if statement, mExpr, is not defined as a class variable in the ExtParserFunctions class. I believe this to be a typo / refactoring artifact, and that it should instead check to see if mExprParser is set.

function &getExprParser() {
    if ( !isset( $this->mExprParser ) ) {
        if ( !class_exists( 'ExprParser' ) ) {
            require( dirname( __FILE__ ) . '/Expr.php' );
        }
        $this->mExprParser = new ExprParser;
    }
    return $this->mExprParser;
}

I've attached a patch with the correction as well.


Version: unspecified
Severity: normal

Attached:

Details

Reference
bz13041

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:08 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz13041.
bzimport added a subscriber: Unknown Object (MLST).