[TYPO3-mvc] blog_example: "You should never see this warning."

Bastian Waidelich bastian at typo3.org
Mon Feb 21 11:48:49 CET 2011


Dmitry Dulepov wrote:

Hi Dmitry,

> Blog_example gives this in Tx_ExtBase_Persistence_QueryResult->warning
> field:
>
> "You should never see this warning. If you do, you probably used PHP
> array functions like current() on the
> Tx_Extbase_Persistence_QueryResult. To retrieve the first result, you
> can use the getFirst() method."

Since version 1.3.0 $query->execute() returns an instance of 
Tx_Extbase_Persistence_QueryResultInterface instead of an array with the 
records (see [1]).

Due to an inconsistency of PHP, the array_()* methods, and some 
iteration methods like current() do not work on the QueryResult (or 
objects which implement ArrayAccess in general).

The real issue is: There is no way to catch the case that someone calls 
current() on the ResultObject. Instead of calling the "current()" method 
of the Interface, PHP will return the first field of the object - even 
if it is private!
The pragmatic solution was to add a private field that contains the 
warning "You should never see this warning..." so you would at least get 
a hint if you debug the result.


> Is that a bug or could it be safely ignored? Blogs are displayed, the
> warning is ignored by the code but I thought it could be a bug.

I didn't really get it. Did you get that warning somewhere when trying 
out the BlogExample or just while looking at the code?
If the first is the case, that's definitely a bug - but I can't find a 
place where array-functions are used on the QueryResult in the BlogExample!?

Best,
Bastian

[1] http://forge.typo3.org/projects/typo3v4-mvc/wiki/QueryResult



More information about the TYPO3-project-typo3v4mvc mailing list