Skip to content

Commit

Permalink
Fix #19807: Fix REST serializer not using serializeModel() when wor…
Browse files Browse the repository at this point in the history
…king with array of models
  • Loading branch information
zucha authored May 21, 2023
1 parent 0fcd434 commit 301a1cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.48 under development
------------------------

- Bug #19807: Fix REST serializer not using `serializeModel()` when working with array of models (zucha)
- Enh #19766: Add support for PHP generators to JSON helper (vladis84)
- Bug #19683: Updated `framework\mimeType.php` to the actual value. Fix typo in `build/controllers/MimeTypeController.php` (DeryabinSergey)
- Bug #19705: Add binary and other data type to `$typeMap` list for MySQL (sohelahmed7)
Expand Down
3 changes: 1 addition & 2 deletions framework/rest/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,9 @@ protected function serializeModelErrors($model)
*/
protected function serializeModels(array $models)
{
list($fields, $expand) = $this->getRequestedFields();
foreach ($models as $i => $model) {
if ($model instanceof Arrayable) {
$models[$i] = $model->toArray($fields, $expand);
$models[$i] = $this->serializeModel($model);
} elseif (is_array($model)) {
$models[$i] = ArrayHelper::toArray($model);
}
Expand Down

0 comments on commit 301a1cf

Please sign in to comment.