title: onAfterWrite method called twice with DataObjectManager
body: <p>I am using dataobjectmanager with a many_many relationship (I can't use manymanydataobjectmanager for this) between owner and car. Whenever a new car is created I iterate through all instances of owner and add it's id to a linked table along with the new car ID.</p>
  
  <p>My problem is that the code for doing this is within the onafterwrite method and is called twice. I'm not sure why. I've also noticed that for my three owners it is creating rows in the linked table oddly.  The first two IDs will be in order then it will stick one.  So it'll be rows 1, 2 and 4 with no 3.</p>
  
  <p>This is my onAfterWrite method</p>
  
  <pre><code>public function onAfterWrite() {
  
      if(Permission::check('ADMIN')){
          $Pages = DataObject::get('Owner');              
  
          foreach($Pages as $owner) {
  
          DB::query("INSERT INTO Owner_Cars (OwnerID, CarID) VALUES ('". $owner-&gt;ID . "', '" . $this-&gt;ID . "')");
          }
      }
      else {
          echo "Failure";
          return false;
      }
      return parent::onAfterWrite();
  }
  </code></pre>
  
  <p>I'd appreciate any advice you could give me.</p>
  
  <p>Thanks</p>