[TYPO3-mvc] Unsure if i spotted a bug

Sebastian Fischer sf at marketing-factory.de
Mon Jan 3 11:13:23 CET 2011


Hi everyone,

looking into the Tx_Extbase_Persistence_QueryResult class i have seen 
something that worries my a little.

class Tx_Extbase_Persistence_QueryResult implements 
Tx_Extbase_Persistence_QueryResultInterface {
         public function getFirst() {
                 if (is_array($this->queryResult)) {
                         $queryResult = $this->queryResult;
                         reset($queryResult);
                 } else {
                         $query = clone $this->query;
                         $query->setLimit(1);
                         $queryResult = 
$this->dataMapper->map($this->query->getType(), 
$this->persistenceManager->getObjectDataByQuery($this->query));
                 }
                 $firstResult = current($queryResult);
                 if ($firstResult === FALSE) {
                         $firstResult = NULL;
                 }
                 return $firstResult;
         }
}

My concern is now, that im very unsure it this line is optimal:

$this->dataMapper->map($this->query->getType(), 
$this->persistenceManager->getObjectDataByQuery($this->query));

If i understand it right, target is to have a query with limit one in 
$query. But this object isnt used when it comes to mapping, or is it my 
misunderstanding? Wouldn't it be a better solution to use:

$this->dataMapper->map($query->getType(), 
$this->persistenceManager->getObjectDataByQuery($query));

I think that would speed up the query if getFirst is called more than once.

Greetings
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list