Serialisation/deserialisation no longer works
まだ誰も着手していません。
評価
調査の方向性
まず、レポートで説明されている Message モデルと ItemBody モデル、および backing store のサブスクリプションから始め、次に PHP serialize() と unserialize() を使って失敗を再現します。シリアライゼーションに関する記述について readme.md と upgrade.md を確認します。SDK モデルにネストされたオブジェクトが含まれている場合でも、ネイティブのシリアライゼーションとデシリアライゼーションが機能するか、またはドキュメントにサポートされている代替手段が明確に記載されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
Native serialisation and deserialisation of models no longer works in v2.
In the msgraph-sdk-php-core readme.md file it states:
We provide Microsoft Graph models for easy serialization and deserialization.
If you would like to leverage the models we provide, please take a look at the [Microsoft Graph PHP SDK](https://packagist.org/packages/microsoft/microsoft-graph) and for beta models - the [Microsoft Graph Beta PHP SDK](https://packagist.org/packages/microsoft/microsoft-graph-beta).
Sadly this is no longer the case. As soon as any nested object is added to a model, serialisation fails as the embedded closures cannot be serialised.
Admittedly this text is obviously written for V1 as it references Graph Beta, but I don't think it has been intentional to remove the ability to natively serialise models. If that is the case, I think that is a bad move. I don't think there in anything in the upgrade.md file that suggests you can no longer natively serialize and, importantly, deserialize models. No examples exist describing how to do this using the SDK.
Take for example the Message model, in it's basic form you can serialise it, however as soon as you add an ItemBody element you can't because the backing store now contains a subscriber for changes to the ItemBody, which is implemented as a closure. This prevents the Message model from being serialised using native PHP serialize/unserialize methods.
My usage case is that I need to offload the sending of messages to a background task. The messages are created when forms are submitted etc. and saved to a scheduler list which picks them up via a command line background task, and then performs the actual sending of the Message object.
There are already issues that hint towards this problem but not to the actual cause of the error:
https://github.com/microsoftgraph/msgraph-sdk-php/issues/1471
https://github.com/microsoftgraph/msgraph-sdk-php/issues/1470
https://github.com/microsoftgraph/msgraph-sdk-php/issues/1452
Expected behavior
Native serialize and unserialize methods should work with all SDK models.
How to reproduce
This simple code will crash when attempting to serialise the Message object:
$message = new Message();
$message->setSubject('Test');
$body = new ItemBody();
$body->setContentType(new BodyType(BodyType::HTML));
$body->setContent('<p>Test</p>');
$message->setBody($body); // Causes a subscription to be set on ItemBody
$test = serialize($message); // This would be stored for the background task.
SDK Version
v2.12.0
Latest version known to work for scenario above?
v1
Known Workarounds
None.
Debug output
Click to expand log
object(Exception)#705 (7) { ["message":protected]=> string(41) "Serialization of 'Closure' is not allowed" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(64) "redacted.php" ["line":protected]=> int(220) ["trace":"Exception":private]=> array(5) { ... } ```Configuration
No response
Other information
No response
- 主要言語
- PHP
- スター
- 669
- フォーク
- 149
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoftgraph/msgraph-sdk-php のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoftgraph/msgraph-sdk-php#1794 · コメント 2 件 ·
-
bug: metadata type:bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoftgraph/msgraph-sdk-php#1739 · コメント 6 件 ·
-
status:waiting-for-triage type:bug
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
microsoftgraph/msgraph-sdk-php#1643 · コメント 8 件 · リアクション 4 件 ·
-
status:waiting-for-triage
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
microsoftgraph/msgraph-sdk-php#1800 · リアクション 3 件 ·
-
Nowオープン
難易度 5/5 1週間以上 初心者へのやさしさ 1/100
microsoftgraph/msgraph-sdk-php#1799 ·
microsoftgraph/msgraph-sdk-php の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
matomo-org/plugin-CustomAlerts#310 ·
メンテナーはふだん 1 日以内に返信
-
Bug Status: Needs Triage
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
domain/checkout Platform(Default) priority/low testing/acceptance
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
pluginsGLPI/addressing#132 ·
-
5.14.0 PIE packages still declare PHP >=8.3, so PIE installs them on PHP 8.3 and the build failsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100