Skip to content
This repository
Browse code

avoid unneeded query in delete()

  • Loading branch information...
commit cf18e8d38b4cb0f7646d3cacc721132e81e20826 1 parent 89b2edd
ceeram authored June 19, 2012

Showing 1 changed file with 8 additions and 7 deletions. Show diff stats Hide diff stats

  1. 15  lib/Cake/Model/Model.php
15  lib/Cake/Model/Model.php
@@ -2440,13 +2440,14 @@ public function delete($id = null, $cascade = true) {
2440 2440
 						break;
2441 2441
 					}
2442 2442
 				}
2443  
-
2444  
-				$keys = $this->find('first', array(
2445  
-					'fields' => $this->_collectForeignKeys(),
2446  
-					'conditions' => array($this->alias . '.' . $this->primaryKey => $id),
2447  
-					'recursive' => -1,
2448  
-					'callbacks' => false
2449  
-				));
  2443
+				if ($updateCounterCache) {
  2444
+					$keys = $this->find('first', array(
  2445
+						'fields' => $this->_collectForeignKeys(),
  2446
+						'conditions' => array($this->alias . '.' . $this->primaryKey => $id),
  2447
+						'recursive' => -1,
  2448
+						'callbacks' => false
  2449
+					));
  2450
+				}
2450 2451
 			}
2451 2452
 
2452 2453
 			if ($db->delete($this, array($this->alias . '.' . $this->primaryKey => $id))) {

0 notes on commit cf18e8d

Please sign in to comment.
Something went wrong with that request. Please try again.