Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

版本升级造成的 ResourceCollection 数据结构变更问题 #56

Closed
bangbangda opened this issue Nov 2, 2021 · 3 comments
Closed

Comments

@bangbangda
Copy link

每次升级的时候要考虑下对原有程序的影响范围,可以做好兼容或者有个明确的说明。
目前以为升级导致接口返回格式变化,直接导致测试全部挂掉2次了。如果没有测试,会直接导致前端应用全部失败。

第一次还能通过修改配置文件完成兼容,这次直接没法兼容了。
直接在返回结果中把 data 这层去掉,姑且不说哪种方式更合理,像这种大的结构性变动应该有个说明比较好吧。

// formatResourceCollectionResponse 
if ($resource->resource instanceof AbstractPaginator) {
            $paginated = $resource->resource->toArray();
            $paginationInformation = $this->formatPaginatedData($paginated);

            $data = array_merge_recursive(['data' => $resource->resolve(request())], $resource->with(request()), $resource->additional, $paginationInformation);
        } else {
            $data = array_merge_recursive($resource->resolve(request()), $resource->with(request()), $resource->additional);
        }
@jiannei
Copy link
Owner

jiannei commented Nov 2, 2021

你使用的是哪个版本,紧急修复下先。

可以考虑先往下降一个版本,在composer.json中固定住版本号。

@bangbangda
Copy link
Author

你使用的是哪个版本,紧急修复下先。

可以考虑先往下降一个版本,在composer.json中固定住版本号。

嗯 临时降低了个版本

@jiannei jiannei changed the title 下定决心准备弃用了 版本升级造成的 ResourceCollection 数据结构变更问题 Nov 3, 2021
@jiannei
Copy link
Owner

jiannei commented Nov 17, 2021

已还原

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants