Skip to content

Instantly share code, notes, and snippets.

@jwage
Created June 18, 2010 16:38
Show Gist options
  • Save jwage/443872 to your computer and use it in GitHub Desktop.
Save jwage/443872 to your computer and use it in GitHub Desktop.
diff --git a/lib/Doctrine/ODM/MongoDB/DocumentManager.php b/lib/Doctrine/ODM/MongoDB/DocumentManager.php
index 1b4fc2c..944d6e7 100644
--- a/lib/Doctrine/ODM/MongoDB/DocumentManager.php
+++ b/lib/Doctrine/ODM/MongoDB/DocumentManager.php
@@ -426,12 +426,11 @@ class DocumentManager
*
* @param string $documentName The document name to load.
* @param string $id The id the document to load.
- * @param boolean $isProxy
* @return object $document The loaded document.
* @todo this function seems to be doing to much, should we move parts of it
* to BasicDocumentPersister maybe?
*/
- public function loadByID($documentName, $id, $isProxy = false)
+ public function loadByID($documentName, $id)
{
$class = $this->getClassMetadata($documentName);
$collection = $this->getDocumentCollection($documentName);
@@ -441,11 +440,7 @@ class DocumentManager
if ( ! $result) {
return null;
}
- $document = $this->load($documentName, $id, $result);
- if ($isProxy) {
- $this->getUnitOfWork()->registerManaged($document, $id, $result);
- }
- return $document;
+ return $this->load($documentName, $id, $result);
}
/**
@@ -461,7 +456,9 @@ class DocumentManager
{
if ($data !== null) {
$hints = array(Query::HINT_REFRESH => Query::HINT_REFRESH);
- return $this->_unitOfWork->getOrCreateDocument($documentName, $data, $hints);
+ $document = $this->_unitOfWork->getOrCreateDocument($documentName, $data, $hints);
+ $this->getUnitOfWork()->registerManaged($document, $id, $data);
+ return $document;
}
return false;
}
diff --git a/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php b/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php
index 5268076..506cd5e 100644
--- a/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php
+++ b/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php
@@ -265,7 +265,7 @@ class <proxyClassName> extends \<className> implements \Doctrine\ODM\MongoDB\Pro
{
if ( ! $this->__isInitialized__ && $this->__dm) {
$this->__isInitialized__ = true;
- if ($this->__dm->loadByID(get_class($this), $this->__identifier, true) === null) {
+ if ($this->__dm->loadByID(get_class($this), $this->__identifier) === null) {
throw \Doctrine\ODM\MongoDB\MongoDBException::documentNotFound(get_class($this), $this->__identifier);
}
unset($this->__dm);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment