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

PHP8 対応漏れ?「受注管理>受注登録」画面でシステムエラー #829、Warning 回避 #836

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

seasoftjapan
Copy link
Contributor

@seasoftjapan seasoftjapan commented Feb 6, 2024

No description provided.

@seasoftjapan seasoftjapan added this to the 2.17.3 milestone Feb 6, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (6d5a5b9) 55.38% compared to head (a23d6b7) 55.36%.

Files Patch % Lines
data/class/util/SC_Utils.php 50.00% 2 Missing ⚠️
data/class/SC_FormParam.php 80.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #836      +/-   ##
==========================================
- Coverage   55.38%   55.36%   -0.02%     
==========================================
  Files          75       75              
  Lines        8908     8911       +3     
==========================================
  Hits         4934     4934              
- Misses       3974     3977       +3     
Flag Coverage Δ
tests 55.36% <80.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

nanasess
nanasess previously approved these changes Feb 7, 2024
Copy link
Contributor

@nanasess nanasess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bbkids
Copy link
Contributor

bbkids commented Feb 7, 2024

PHP8 Warning 回避 (b366a0f)
の修正を入れましたところ、
数量欄に「あ」を入力し、[計算結果の確認]ボタンを押すと
当方の環境では、システムエラーが出るようになりました。一応お知らせ致します。

[/manager/order/edit.php] Fatal error(E_ERROR): Uncaught TypeError: Unsupported operand types: int + string in data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php:1212

@bbkids
Copy link
Contributor

bbkids commented Feb 7, 2024

すみません、今試してみましたところ、
当初の私の検証ミスの様でして、
PHP8 Warning 回避 (b366a0f)
の修正以前でも、
数量欄のみ改善させていない様で御座います。

具体的には、
数量欄に「あ」を入力し、[計算結果の確認]ボタンを押すと
当方の環境では、システムエラーで落ちます。

その場合のエラーログは、
[/admin/order/edit.php] Fatal error(E_ERROR): Uncaught TypeError: Unsupported operand types: string * string in data/class/util/SC_Utils.php:895

@nanasess
Copy link
Contributor

nanasess commented Feb 7, 2024

@bbkids @seasoftjapan

数量欄のみ改善させていない

こちらは別途 issues で対応したほうが良いですかね?

@bbkids
Copy link
Contributor

bbkids commented Feb 7, 2024

数量欄のみ改善させていない

すみません、「数量欄のみ改善されていない」の間違いでした。

別途 issues でOKです。

@seasoftjapan
Copy link
Contributor Author

@bbkids 不具合報告ありがとうございます。
@nanasess #836 (comment) の再現を確認しましたが、同じ画面内で且つ性質は似ているので、Issue は #829 で良さそうな気がします。一旦 fixed #829 の記述を削除しました。マージに間に合わなかったら PR は追加します。

setProductsQuantity() 内のエラーを回避するため、lfCheckError() の事前呼び出しを徹底した。
@seasoftjapan
Copy link
Contributor Author

seasoftjapan commented Feb 7, 2024

まずは、#836 (comment) への対応です。

lfCheckError() の前に setProductsQuantity() が呼ばれていたり、
lfCheckError() を通過せずに setProductsQuantity() が呼ばれていたりする状況でした。

setProductsQuantity() の前に lfCheckError() を呼び、エラーがあったら switch を break するよう調整しています。

変更箇所が多いですが、十分にデバッグできていないため、一旦別ブランチに push すると思います。

【追記】
push しました。
https://github.com/seasoftjapan/eccube-2_13/tree/seasoft-829-2

- 新規登録時に point (受注前ポイント) が空文字のため、生じるエラーを回避した。SC_FormParam を初期化。
- 上記の他にも SC_FormParam の初期化が不適当と思われる箇所を調整した。
@bbkids
Copy link
Contributor

bbkids commented Feb 8, 2024

この修正以降、
商品追加で一度 規格1と規格2がある商品を追加し、その追加した商品を規格がない商品に変更をすると

public function changeShipmentProducts(); の中の以下の箇所で、エラー落ちします。

$arrShipmentProducts['shipment_classcategory_name1'][$shipping_id][$no] = $arrProductInfo['classcategory_name1'];
$arrShipmentProducts['shipment_classcategory_name2'][$shipping_id][$no] = $arrProductInfo['classcategory_name2'];

Fatal error(E_ERROR): Cannot assign an empty string to a string offset が出ます。
また、その逆で、規格がない商品を一度追加して、その追加した商品を規格1と規格2がある商品に変更すると
同じ個所で、 Warning(E_WARNING): Only the first byte will be assigned to the string offset がでます。

@bbkids
Copy link
Contributor

bbkids commented Feb 9, 2024

$arrShipmentProducts[]を辿ってみましたところ、
入れ子の配列のについて初期化されていなかったようで、NULLがセットされエラー落ちしていたものと考えられます。

$arrShipmentProducts['shipment_classcategory_name1'][$shipping_id] = [];
$arrShipmentProducts['shipment_classcategory_name2'][$shipping_id] = [];

changeShipmentProducts()の中で値をセットする直前に、配列として初期化したところエラー落ち解消されました。
LC_Page_Admin_Order_Edit全体を把握できていないので、ここでの初期化が適切かどうかは何とも言えません。

【追記】
その後、
https://github.com/seasoftjapan/eccube-2_13/tree/seasoft-829-2 に上記をマージしたものを一通り試して見ましたが、エラー落ちはなくなりました。
Warninngは少々残ります(かなり減りました)が、当方が試した限りは、おおむね良さそうな感じで御座います。

f0ecec3 では不十分で、```$objFormParam->getValue('point')``` が ```""``` となり、```TypeError: Unsupported operand types: string - string``` を生じるケースがあった。
- 演算子の空文字の扱いが厄介なので null とする。
- SC_FormParam::getValue() が多次元配列の1次要素の一部を空文字で返してエラーとなるのを回避した。
- SC_FormParam::getValue() で定義されていないキーを指定した場合に例外を補足する。暗黙的に空文字を返して、後続の処理でエラーとなるのを防ぐ意図。
- 演算子の空文字の扱いが厄介なので null とする。
- SC_FormParam の order_id が配列となり、Smarty h 修飾子がエラーとなるのを回避した。
- shipment_classcategory_name1, shipment_classcategory_name2 の処理が抜けていた箇所を補った。
@seasoftjapan
Copy link
Contributor Author

seasoftjapan commented Feb 11, 2024

@bbkids ご報告ありがとうございます。
イレギュラーな操作をすると、他にもPHPエラーありますね。

当プルリクをドラフトに変更して、もう少しじっくりと調整しようかと思います。併せて、seasoft-829-2 ブランチに push していた内容を、プルリク対象ブランチに push し直す予定です。
(@nanasess それで、自動マージになっても master にマージされなくなると想定していますが、違いましたらご指摘ください。)

この画面は、PHPエラー以外の既存バグも多々あると思うので、どこで切りをつけるか難しくなりそうです。

@seasoftjapan seasoftjapan marked this pull request as draft February 11, 2024 09:50
@nanasess nanasess dismissed their stale review March 22, 2024 05:25

要調整とのことですので一旦 approve を取り下げす

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

Successfully merging this pull request may close these issues.

None yet

4 participants