Matrix getBlockTypesByFieldId() function doesn't work as intended? One of the functions in a plugin that I'm working on, is the ability to create fields. It has created a Matrix field, and directly after that, I want to know the MatrixBlockType.

I don't get any results if I use the following code:

$blockTypes = craft()&gt;matrix&gt;getBlockTypesByFieldId($newField-&gt;id, 'handle');


However, if I do the exact same thing as the above function should do, and run this code I do have results:

$results = craft()-&gt;db-&gt;createCommand()
-&gt;select('id, fieldId, fieldLayoutId, name, handle, sortOrder')
-&gt;from('matrixblocktypes')
-&gt;where('fieldId = :fieldId', array(':fieldId' =&gt; $newField&gt;id))
-&gt;order('sortOrder')
-&gt;queryAll();


If you would debug both variables, you'll notice that the first one doesn't contain any data.

If I would be creating the fields and in later server request I would use the first example, I do receive the data. Somehow it's not available right after creating the field.

Can anyone help me out here by any chance? I want to use the first example, which is the correct way.
Turns out this was a bug in Craft and we've just fixed it for the next (post build 2568) release.