Skip to content

Instantly share code, notes, and snippets.

@skowron-line
Last active November 30, 2016 15:16
Show Gist options
  • Save skowron-line/809d8dd0058572f0f061688e38dea90c to your computer and use it in GitHub Desktop.
Save skowron-line/809d8dd0058572f0f061688e38dea90c to your computer and use it in GitHub Desktop.
ocramius/proxy-manager v1.0.2 bug

Returning value for Propel getConnection is PDO (https://github.com/propelorm/Propel/blob/1.6/runtime/lib/Propel.php#L542-L551)

<service id="suggestions.database.handler" class="PDO" lazy="true">
    <factory class="Propel" method="getConnection" /> 
    <argument type="constant">SuggesterBundle\Model\SuggestionPeer::DATABASE_NAME</argument>
</service>

PDO prepare is

public function prepare ($statement, array $driver_options = array()) {}

But it generates

/**
 * {@inheritDoc}
 */
public function prepare($statement, $options = null) // BUG This should be array by default, and generating "Warning: PDO::prepare() expects parameter 2 to be array, null given"
{
    $this->initializer5829d944aa3e0505487367 && $this->initializer5829d944aa3e0505487367->__invoke($this->valueHolder5829d944aa3ab371428905, $this, 'prepare', array('statement' => $statement, 'options' => $options), $this->initializer5829d944aa3e0505487367);

    return $this->valueHolder5829d944aa3ab371428905->prepare($statement, $options);
}

Working solution

<service id="suggestions.database.handler" class="PropelPDO" lazy="true">
    <factory class="Propel" method="getConnection" />
    <argument type="constant">SuggesterBundle\Model\SuggestionPeer::DATABASE_NAME</argument>
</service>

But as I mention earlier getConnection is returning \PDO instance

PropelPDO is

public function prepare($sql, $driver_options = array())

and generates

/**
 * {@inheritDoc}
 */
public function prepare($sql, $driver_options = array()) // This is correct
{
    $this->initializer5829da1913b73243834477 && $this->initializer5829da1913b73243834477->__invoke($this->valueHolder5829da1913b35413254236, $this, 'prepare', array('sql' => $sql, 'driver_options' => $driver_options), $this->initializer5829da1913b73243834477);

    return $this->valueHolder5829da1913b35413254236->prepare($sql, $driver_options);
}
@Ocramius
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment