Ticket #1556 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

Doctrine_Query_Registry should add and return clone of the query

Reported by: honza.trtik Owned by: romanb
Priority: minor Milestone: 1.0.4
Component: Query/Hydration Version: 1.0.2
Severity: Keywords: query registry
Cc: Has Test: no
Status: Pending Core Response Has Patch: yes

Description

Folowing example is selfexplaining the issue:

$r = Doctrine_Manager::getInstance()->getQueryRegistry();

// Add new query - list ordered by permission attribute
$q1 = Doctrine_Query::create()->from('sfGuardUser')->orderBy('username');
$r->add('sfGuardUser/list', $q1);
var_dump($q1->getDql()); // string(35) " FROM sfGuardUser ORDER BY username"

// Get this query from registry and adjust it
$q2 = $r->get('list', 'sfGuardUser');
$q2->orderBy('password');
var_dump($q2->getDql()); // string(35) " FROM sfGuardUser ORDER BY password"

// Try to get original added query from registry
$q3 = $r->get('list', 'sfGuardUser');
var_dump($q3->getDql()); // string(35) " FROM sfGuardUser ORDER BY password" 

If you add query to registry, get it again and adjust via fluent query interface, you change query object in registry. That is not expected behavior, i think.. IMHO the solution is cloning query before adding and before returning.

Attachments

patch_doctrine_query_registry.patch (182 bytes) - added by honza.trtik 9 months ago.

Change History

Changed 9 months ago by honza.trtik

Changed 9 months ago by jwage

  • milestone changed from Unknown to 1.0.4

Changed 9 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [5088]) [1.0, 1.1] fixes #1556 - issue with query registry not storing copies of queries

Note: See TracTickets for help on using tickets.