1

doctrine/mongodb-odm バージョン 1.0.8

自己参照多対多の双方向関係を使用するドキュメントがあります。最初に、cascade=persist を設定する必要があるというエラーが表示されました。私はそれをしましたが、今では非常に奇妙な教義エラーが発生しています。私の文書:

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/**
 * @ODM\Document(collection="ledger", repositoryClass="Tng\ExampleBundle\Repository\LedgerRepository")
 */
class Ledger
{
    /**
     * @ODM\Id(strategy="AUTO")
     */
    protected $id;

    /**
     * If this is a payment, this will link to the debit ledger
     * @ODM\ReferenceMany(
     *      targetDocument="Tng\ExampleBundle\Document\Ledger",
     *      inversedBy="payment",
     *      strategy="addToSet",
     *      cascade={"persist"},
     *      simple=true
     * )
     */
    protected $payment_for;

    /**
     * If this is a debit, these are the payments and credits
     * @ODM\ReferenceMany(
     *      targetDocument="Tng\ExampleBundle\Document\Ledger",
     *      mappedBy="payment_for",
     *      strategy="addToSet",
     *      cascade={"persist"},
     *      simple=true
     * )
     */
    protected $payments;

    public function __construct()
    {
        $this->payments = new \Doctrine\Common\Collections\ArrayCollection();
        $this->payment_for = new \Doctrine\Common\Collections\ArrayCollection();
    }

    // all standard getters/setters with:
    public function addPaymentFor(\Tng\ExampleBundle\Document\Ledger $paymentFor)
    {
        $this->payment_for[] = $paymentFor;
        $paymentFor->payments[] = $this;
    }

    public function removePaymentFor(\Tng\ExampleBundle\Document\Ledger $paymentFor)
    {
        $this->payment_for->removeElement($paymentFor);
        $paymentFor->payments->removeElement($this);
    }
}

カスケード レコードを保存しようとすると、次のようになります。

$payment->setPaymentFor($ledger);
$dm->persist($payment);

次のエラーが表示されます。

Notice: 未定義のインデックス: $set

スタックトレース

  1. vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php の 315 行目 -
  2. ErrorHandler ->handleError ('8'、'未定義のインデックス: $set'、'/var/www/etc-mongo-tng/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister. php', '315', array('data' => array(), 'options' => array('upsert' => true)))
  3. vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php の 315 行目 + DocumentPersister で ->executeUpsert (array(), array())
  4. vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php の 296 行目 +
  5. DocumentPersister -> executeUpserts (array()) の vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/UnitOfWork.php の 1189 行目 +
  6. UnitOfWork ->executeUpserts (object(ClassMetadata), array('000000005a8560de00007fc48349ed60' => object(Ledger)), array()) で vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/UnitOfWork.php 行425 +

同じバグが 1.1.2 ブランチに影響を与えるようには見えません。次のように DocumentPersister.php にパッチを適用すると、すべて機能します。これは正当なバグですか?PRをするべきですか?

private function executeUpsert(array $data, array $options)
{
    // I added this line
    if (empty($data)) { return; }
    $options['upsert'] = true;
    $criteria = array('_id' => $data['$set']['_id']);
    unset($data['$set']['_id']);
4

0 に答える 0