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

セッションデータに保存される配送商品のコンテンツデータは必要? #1007

Open
clicktx opened this issue Sep 19, 2024 · 4 comments · May be fixed by #1021
Open

セッションデータに保存される配送商品のコンテンツデータは必要? #1007

clicktx opened this issue Sep 19, 2024 · 4 comments · May be fixed by #1021

Comments

@clicktx
Copy link
Contributor

clicktx commented Sep 19, 2024

dtb_session.sess_dataに保存されるデータにshipping itemsに関する無駄な情報が多い気がします。

  1. カートに商品を追加
  2. shoppingプロセスをすすんで「入力内容のご確認画面」まで進む(途中まででも良いかも)
  3. セッションデータに商品データ全て(?)が保存される

main_commentやsub_title1〜、sub_comment1〜等、dtb_productsにあるデータが(恐らく)すべて含まれるため、商品の説明コンテンツが長いほどデータ量が多くなります。

何かに使われる気はしないのですが、必要なデータなのでしょうか?
かなり昔にMySQLでセッションデータがオーバーフローする現象がある、というような書き込みを見かけた気がしますが、、、

@nanasess
Copy link
Contributor

一応、不要なデータは切り落すようになっていたと思いますが、正常に動作していませんかね、、?

/**
* セッション中の商品情報データの調整。
* productsClass項目から、不必要な項目を削除する。
*/
public function adjustSessionProductsClass(&$arrProductsClass)
{
$arrNecessaryItems = array(
'product_id' => true,
'product_class_id' => true,
'name' => true,
'price02' => true,
'point_rate' => true,
'main_list_image' => true,
'main_image' => true,
'product_code' => true,
'stock' => true,
'stock_unlimited' => true,
'sale_limit' => true,
'class_name1' => true,
'classcategory_name1' => true,
'class_name2' => true,
'classcategory_name2' => true,
);
// 必要な項目以外を削除。
foreach ($arrProductsClass as $key => $value) {
if (!isset($arrNecessaryItems[$key])) {
unset($arrProductsClass[$key]);
}
}
}

かなり昔にMySQLでセッションデータがオーバーフローする現象がある、というような書き込みを見かけた気がしますが、、、

2.13 までは MySQL は text 型のカラムにセッション情報を格納していたので、しばしば溢れるケースがありました
866be13
https://svn.ec-cube.net/open_trac/ticket/1341

@clicktx
Copy link
Contributor Author

clicktx commented Sep 20, 2024

DBによる違いはありますでしょうか?
検証環境はphp7.4+postgresqlです。

ショッピングプロセスで配送先が確定された時の更新で追加される感じでした。

セッションの中身をJSONにしたものを貼っておきます。
https://gist.github.com/clicktx/2d0e12842620505f56d40349c6fcc3a4

@clicktx
Copy link
Contributor Author

clicktx commented Sep 20, 2024

ざっとコードを追うと下記部分が怪しい感じですかね(未検証)

// 配列が長くなるので, リファレンスを使用する
$arrItems = &$_SESSION['shipping'][$shipping_id]['shipment_item'][$product_class_id];
$arrItems['shipping_id'] = $shipping_id;
$arrItems['product_class_id'] = $product_class_id;
$arrItems['quantity'] = $quantity;
$objProduct = new SC_Product_Ex();
// カート情報から読みこめば済むと思うが、一旦保留。むしろ、カート情報も含め、セッション情報を縮小すべきかもしれない。
/*
$objCartSession = new SC_CartSession_Ex();
$cartKey = $objCartSession->getKey();
// 詳細情報を取得
$cartItems = $objCartSession->getCartList($cartKey);
*/
if (empty($arrItems['productsClass'])) {
$product = &$objProduct->getDetailAndProductsClass($product_class_id);
$arrItems['productsClass'] = $product;
}
$arrItems['price'] = $arrItems['productsClass']['price02'];
$inctax = SC_Helper_TaxRule_Ex::sfCalcIncTax(
$arrItems['price'],
$arrItems['productsClass']['product_id'],
$arrItems['productsClass']['product_class_id']
);
$arrItems['total_inctax'] = $inctax * $arrItems['quantity'];

ここで代入していそう

$product = &$objProduct->getDetailAndProductsClass($product_class_id);
$arrItems['productsClass'] = $product;

@nanasess
Copy link
Contributor

@clicktx ありがとうございます。こちらでも確認してみますね

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