From 57f0e3ea17d0989cbd1b7d7b966e483fccf1d480 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 11 Dec 2024 15:53:40 +0900 Subject: [PATCH] Fix warning --- data/class/SC_CartSession.php | 23 +++++++++++++++++-- data/class/SC_Customer.php | 9 +++++--- data/class/SC_Response.php | 2 +- data/class/helper/SC_Helper_Address.php | 2 +- data/class/helper/SC_Helper_Customer.php | 2 +- data/class/helper/SC_Helper_Maker.php | 4 ++-- data/class/helper/SC_Helper_Purchase.php | 12 +++++----- data/class/helper/SC_Helper_Session.php | 2 +- data/class/pages/mypage/LC_Page_Mypage.php | 2 +- .../products/LC_Page_Products_Detail.php | 2 +- .../pages/products/LC_Page_Products_List.php | 2 +- .../class/pages/shopping/LC_Page_Shopping.php | 4 ++-- .../shopping/LC_Page_Shopping_Payment.php | 8 +++++-- 13 files changed, 50 insertions(+), 24 deletions(-) diff --git a/data/class/SC_CartSession.php b/data/class/SC_CartSession.php index 645d997646..72b8de4e90 100644 --- a/data/class/SC_CartSession.php +++ b/data/class/SC_CartSession.php @@ -117,7 +117,7 @@ public function getNextCartID($product_type_id) { $count = []; foreach ($this->cartSession[$product_type_id] as $key => $value) { - $count[] = $this->cartSession[$product_type_id][$key]['cart_no']; + $count[] = $this->cartSession[$product_type_id][$key]['cart_no'] ?? null; } return max($count) + 1; @@ -147,7 +147,8 @@ public function getMax($product_type_id) { $max = 0; if ( - is_array($this->cartSession[$product_type_id]) + isset($this->cartSession[$product_type_id]) + && is_array($this->cartSession[$product_type_id]) && count($this->cartSession[$product_type_id]) > 0 ) { foreach ($this->cartSession[$product_type_id] as $key => $value) { @@ -157,6 +158,24 @@ public function getMax($product_type_id) } } } + } else { + $this->cartSession[$product_type_id] = []; + } + + // カート内商品の最大要素番号までの要素が存在しない場合、要素を追加しておく + for ($i = 0; $i <= $max; $i++) { + if (!array_key_exists($i, $this->cartSession[$product_type_id])) { + $this->cartSession[$product_type_id][$i] = [ + 'id' => null, + 'cart_no' => null, + 'price' => 0, + 'quantity' => 0, + 'productsClass' => [ + 'product_id' => null, + 'product_class_id' => null, + ], + ]; + } } return $max; diff --git a/data/class/SC_Customer.php b/data/class/SC_Customer.php index 1855dd6e46..8263c7e9b8 100644 --- a/data/class/SC_Customer.php +++ b/data/class/SC_Customer.php @@ -270,9 +270,12 @@ public function getValue($keyname) { // ポイントはリアルタイム表示 if ($keyname == 'point') { - $objQuery = SC_Query_Ex::getSingletonInstance(); - $point = $objQuery->get('point', 'dtb_customer', 'customer_id = ?', [$_SESSION['customer']['customer_id']]); - $_SESSION['customer']['point'] = $point; + $point = 0; + if (isset($_SESSION['customer']['customer_id'])) { + $objQuery = SC_Query_Ex::getSingletonInstance(); + $point = $objQuery->get('point', 'dtb_customer', 'customer_id = ?', [$_SESSION['customer']['customer_id']]); + $_SESSION['customer']['point'] = $point; + } return $point; } else { diff --git a/data/class/SC_Response.php b/data/class/SC_Response.php index 331edd818b..b6ac1afacd 100644 --- a/data/class/SC_Response.php +++ b/data/class/SC_Response.php @@ -176,7 +176,7 @@ public static function sendRedirect($location, $arrQueryString = [], $inheritQue } // url-path → URL 変換 - if ($location[0] === '/') { + if ($location !== '' && $location[0] === '/') { $netUrl = new Net_URL($location); $location = $netUrl->getUrl(); } diff --git a/data/class/helper/SC_Helper_Address.php b/data/class/helper/SC_Helper_Address.php index b6c93e2193..f5dc3bd2d4 100644 --- a/data/class/helper/SC_Helper_Address.php +++ b/data/class/helper/SC_Helper_Address.php @@ -194,7 +194,7 @@ public function delivErrorCheck($arrParam) $error_flg = true; } - if (strlen($arrParam['other_deliv_id']) > 0 && (!is_numeric($arrParam['other_deliv_id']) || !preg_match("/^\d+$/", $arrParam['other_deliv_id']))) { + if (isset($arrParam['other_deliv_id']) && (!is_numeric($arrParam['other_deliv_id']) || !preg_match("/^\d+$/", $arrParam['other_deliv_id']))) { $error_flg = true; } diff --git a/data/class/helper/SC_Helper_Customer.php b/data/class/helper/SC_Helper_Customer.php index f391a8f921..c25c407bca 100644 --- a/data/class/helper/SC_Helper_Customer.php +++ b/data/class/helper/SC_Helper_Customer.php @@ -111,7 +111,7 @@ public static function sfEditCustomerData($arrData, $customer_id = null) $customer_id = $objQuery->nextVal('dtb_customer_customer_id'); $arrData['customer_id'] = $customer_id; // 作成日 - if (is_null($arrData['create_date'])) { + if (!isset($arrData['create_date'])) { $arrData['create_date'] = 'CURRENT_TIMESTAMP'; } $objQuery->insert('dtb_customer', $arrData); diff --git a/data/class/helper/SC_Helper_Maker.php b/data/class/helper/SC_Helper_Maker.php index 3370ca6df8..2f989797b7 100644 --- a/data/class/helper/SC_Helper_Maker.php +++ b/data/class/helper/SC_Helper_Maker.php @@ -45,9 +45,9 @@ public function getMaker($maker_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select('*', 'dtb_maker', $where, [$maker_id]); + $arrRet = $objQuery->getRow('*', 'dtb_maker', $where, [$maker_id]); - return $arrRet[0]; + return $arrRet; } /** diff --git a/data/class/helper/SC_Helper_Purchase.php b/data/class/helper/SC_Helper_Purchase.php index 8f2d1be7c9..4d06432361 100644 --- a/data/class/helper/SC_Helper_Purchase.php +++ b/data/class/helper/SC_Helper_Purchase.php @@ -312,7 +312,7 @@ public static function saveOrderTemp($uniqId, $params, &$objCustomer = null) $exists = SC_Helper_Purchase_Ex::getOrderTemp($uniqId); // 国ID追加 - $sqlval['order_country_id'] = ($sqlval['order_country_id']) ? $sqlval['order_country_id'] : DEFAULT_COUNTRY_ID; + $sqlval['order_country_id'] = isset($sqlval['order_country_id']) ? $sqlval['order_country_id'] : DEFAULT_COUNTRY_ID; if (SC_Utils_Ex::isBlank($exists)) { $sqlval['order_temp_id'] = $uniqId; @@ -780,23 +780,23 @@ public static function registerShipmentItem($order_id, $shipping_id, $arrParams) continue; } $d = $objProduct->getDetailAndProductsClass($arrValues['product_class_id']); - $name = SC_Utils_Ex::isBlank($arrValues['product_name']) + $name = !isset($arrValues['product_name']) ? $d['name'] : $arrValues['product_name']; - $code = SC_Utils_Ex::isBlank($arrValues['product_code']) + $code = !isset($arrValues['product_code']) ? $d['product_code'] : $arrValues['product_code']; - $cname1 = SC_Utils_Ex::isBlank($arrValues['classcategory_name1']) + $cname1 = !isset($arrValues['classcategory_name1']) ? $d['classcategory_name1'] : $arrValues['classcategory_name1']; - $cname2 = SC_Utils_Ex::isBlank($arrValues['classcategory_name2']) + $cname2 = !isset($arrValues['classcategory_name2']) ? $d['classcategory_name2'] : $arrValues['classcategory_name2']; - $price = SC_Utils_Ex::isBlank($arrValues['price']) + $price = !isset($arrValues['price']) ? $d['price'] : $arrValues['price']; diff --git a/data/class/helper/SC_Helper_Session.php b/data/class/helper/SC_Helper_Session.php index 6823f16261..b18dbcd5ba 100644 --- a/data/class/helper/SC_Helper_Session.php +++ b/data/class/helper/SC_Helper_Session.php @@ -210,7 +210,7 @@ public static function createToken() public static function isValidToken($is_unset = false) { // token の妥当性チェック - $ret = $_REQUEST[TRANSACTION_ID_NAME] === $_SESSION[TRANSACTION_ID_NAME]; + $ret = ($_REQUEST[TRANSACTION_ID_NAME] ?? '') === ($_SESSION[TRANSACTION_ID_NAME] ?? ''); if (empty($_REQUEST[TRANSACTION_ID_NAME]) || empty($_SESSION[TRANSACTION_ID_NAME])) { $ret = false; diff --git a/data/class/pages/mypage/LC_Page_Mypage.php b/data/class/pages/mypage/LC_Page_Mypage.php index ec5e3ae3eb..2c165d1649 100644 --- a/data/class/pages/mypage/LC_Page_Mypage.php +++ b/data/class/pages/mypage/LC_Page_Mypage.php @@ -85,7 +85,7 @@ public function action() $customer_id = $objCustomer->getValue('customer_id'); // ページ送り用 - $this->objNavi = new SC_PageNavi_Ex($_REQUEST['pageno'], + $this->objNavi = new SC_PageNavi_Ex($_REQUEST['pageno'] ?? 1, $this->lfGetOrderHistory($customer_id), SEARCH_PMAX, 'eccube.movePage', diff --git a/data/class/pages/products/LC_Page_Products_Detail.php b/data/class/pages/products/LC_Page_Products_Detail.php index 807e064ccf..5db73af215 100644 --- a/data/class/pages/products/LC_Page_Products_Detail.php +++ b/data/class/pages/products/LC_Page_Products_Detail.php @@ -570,7 +570,7 @@ public function lfSetFile(SC_UploadFile $objUpFile, $arrProduct, &$arrFile) // サブ画像の有無を判定 $subImageFlag = false; for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) { - if ($arrFile['sub_image'.$i]['filepath'] != '') { + if (isset($arrFile['sub_image'.$i]['filepath'])) { $subImageFlag = true; } } diff --git a/data/class/pages/products/LC_Page_Products_List.php b/data/class/pages/products/LC_Page_Products_List.php index c97724b129..e919662016 100644 --- a/data/class/pages/products/LC_Page_Products_List.php +++ b/data/class/pages/products/LC_Page_Products_List.php @@ -338,7 +338,7 @@ public function lfGetSearchConditionDisp($arrSearchData) if (strlen($arrSearchData['maker_id']) > 0) { $objMaker = new SC_Helper_Maker_Ex(); $maker = $objMaker->getMaker($arrSearchData['maker_id']); - $arrSearch['maker'] = $maker['name']; + $arrSearch['maker'] = $maker['name'] ?? ''; } // 商品名検索条件 diff --git a/data/class/pages/shopping/LC_Page_Shopping.php b/data/class/pages/shopping/LC_Page_Shopping.php index 5699ff9695..e3e8b39e54 100644 --- a/data/class/pages/shopping/LC_Page_Shopping.php +++ b/data/class/pages/shopping/LC_Page_Shopping.php @@ -454,10 +454,10 @@ public function setFormParams(&$objFormParam, &$objPurchase, $uniqid) if (count($arrShippingTemp) > 1) { $objFormParam->setParam($arrShippingTemp[1]); } else { - if ($arrOrderTemp['deliv_check'] == 1) { + if (isset($arrOrderTemp['deliv_check']) && $arrOrderTemp['deliv_check'] == 1) { $objFormParam->setParam($arrShippingTemp[1]); } else { - $objFormParam->setParam($arrShippingTemp[0]); + $objFormParam->setParam($arrShippingTemp[0] ?? []); } } $objFormParam->setValue('order_email02', $arrOrderTemp['order_email']); diff --git a/data/class/pages/shopping/LC_Page_Shopping_Payment.php b/data/class/pages/shopping/LC_Page_Shopping_Payment.php index ee967a93d5..6f6fee8196 100644 --- a/data/class/pages/shopping/LC_Page_Shopping_Payment.php +++ b/data/class/pages/shopping/LC_Page_Shopping_Payment.php @@ -310,7 +310,7 @@ public function lfCheckError(&$objFormParam, $subtotal, $max_point) $objErr->doFunc(['ポイントを使用する', 'point_check'], ['EXIST_CHECK']); if ($arrForm['point_check'] == '1' - && SC_Utils_Ex::isBlank($objErr->arrErr['use_point'])) { + && SC_Utils_Ex::isBlank($objErr->arrErr['use_point'] ?? '')) { $objErr->doFunc(['ポイント', 'use_point'], ['EXIST_CHECK']); if ($max_point == '') { $max_point = 0; @@ -356,7 +356,11 @@ public function saveShippings(&$objFormParam, $arrDelivTime) $time_id = $objFormParam->getValue('deliv_time_id'.$shipping_id); $_SESSION['shipping'][$key]['deliv_id'] = $deliv_id; $_SESSION['shipping'][$key]['time_id'] = $time_id; - $_SESSION['shipping'][$key]['shipping_time'] = $arrDelivTime[$time_id]; + if (isset($arrDelivTime[$time_id])) { + $_SESSION['shipping'][$key]['shipping_time'] = $arrDelivTime[$time_id]; + } else { + $_SESSION['shipping'][$key]['shipping_time'] = ''; + } $_SESSION['shipping'][$key]['shipping_date'] = $objFormParam->getValue('deliv_date'.$shipping_id); } }