Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

JoinedSubclassPersister doesn't properly bind on some versions of php #753

Merged
merged 1 commit into from

3 participants

@51systems

I ran into this bug after deploying an application to production:

 An exception occurred while executing 'INSERT INTO TextSprite (id, text, fontId) VALUES (?, ?, ?)' with params ["4"]:

    SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

The parent table is being inserted properly (It's where the single param 4 comes from for the id), but the child table insert fails.

This was on a shared host with PHP version 5.3.24. On my development machine, everything works fine.

The issue is when the id is not a composite key, it's just a string (in this case), and for whatever reason !isset($id[$columnName]) fails to return a sane value on my production version of php.

By adding a check to see if the ID is an array we can determine if its a composite key, and not bother with the column checks if its not.

Not sure how to write unit tests for this one since it only affects certain versions of PHP (apparently). So advice on that is appreciated.

@51systems 51systems Modified executeInserts method in JoinedSubclassPersister to only che…
…ck for the presence of columns in a composite primary key
27bae51
@doctrinebot
Collaborator

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-2607

We use Jira to track the state of pull requests and the versions they got
included in.

@guilhermeblanco guilhermeblanco merged commit 0ae8aa3 into doctrine:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 12, 2013
  1. @51systems

    Modified executeInserts method in JoinedSubclassPersister to only che…

    51systems authored
    …ck for the presence of columns in a composite primary key
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php
View
2  lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php
@@ -197,7 +197,7 @@ public function executeInserts()
}
foreach ($data as $columnName => $value) {
- if (!isset($id[$columnName])) {
+ if (!is_array($id) || !isset($id[$columnName])) {
$stmt->bindValue($paramIndex++, $value, $this->columnTypes[$columnName]);
}
}
Something went wrong with that request. Please try again.