Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
plugin system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
12 Aug 2012 at 16:57 UTC
Updated:
2 Apr 2015 at 21:44 UTC
Jump to comment: Most recent
We need an additional logic check to prevent an unnecessary foreach statement.
| Comment | File | Size | Author |
|---|---|---|---|
| derivativefix.patch | 1.37 KB | eclipsegc |
Comments
Comment #1
eclipsegc commentedadding tag
Comment #2
neclimdulshouldn't it be foreach-ing over an empty array which is basically the same?
Comment #3
eclipsegc commentedYeah, except then we expect every Discovery class and decorator to be perfect, which in a perfect world would be fine, but I figured I'd just anticipate people screwing it up.
Comment #4
aspilicious commentedThe one thing I don't get is that it doens't return an empty array. I'm testing the block patch. Seems like a bug in getDerativeDefintions() method
Comment #5
aspilicious commented+class CategoryBlock implements DerivativeInterface {
+ protected $derivatives;
Initialize this with an array() and problems probably are gone. We should learn peope to use the correct syntax...
Comment #6
boztek commentedI tested both approaches and initialising $derivatives works but for the purposes of http://drupal.org/node/1535868 it looks like we would need to initialise at least CategoryBlock, LanguageBlock and SystemMenuBlock in the same way.
i.e.
With that in mind the original patch makes sense.
Comment #7
jibranderivativefix.patch queued for re-testing.
Comment #8
xanoIt's not our problem if people implement an interface and don't stick to the required return value types. We should not make our code less readable to accommodate other people's possible mistakes, that will cause a
Invalid argument supplied for foreach()error anyway.Comment #9
dawehnerCan we test this change?
Comment #10
dawehner.
Comment #11
xanoLet's not hide it when people make coding errors. People should discover errors and fix them.