Skip to content

Commit

Permalink
Fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Dec 11, 2024
1 parent 4183a07 commit d5fdc4c
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 25 deletions.
23 changes: 21 additions & 2 deletions data/class/SC_CartSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions data/class/SC_Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion data/class/SC_Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion data/class/helper/SC_Helper_Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion data/class/helper/SC_Helper_Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions data/class/helper/SC_Helper_Maker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions data/class/helper/SC_Helper_Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'];

Expand Down
2 changes: 1 addition & 1 deletion data/class/helper/SC_Helper_Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] ?? '');

Check warning on line 213 in data/class/helper/SC_Helper_Session.php

View check run for this annotation

Codecov / codecov/patch

data/class/helper/SC_Helper_Session.php#L213

Added line #L213 was not covered by tests

if (empty($_REQUEST[TRANSACTION_ID_NAME]) || empty($_SESSION[TRANSACTION_ID_NAME])) {
$ret = false;
Expand Down
2 changes: 1 addition & 1 deletion data/class/pages/cart/LC_Page_Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function action()
}

// 前頁のURLを取得
$this->lfGetCartPrevUrl($_SESSION, $_SERVER['HTTP_REFERER']);
$this->lfGetCartPrevUrl($_SESSION, $_SERVER['HTTP_REFERER'] ?? '');
$this->tpl_prev_url = (isset($_SESSION['cart_prev_url'])) ? $_SESSION['cart_prev_url'] : '';

// 全てのカートの内容を取得する
Expand Down
2 changes: 1 addition & 1 deletion data/class/pages/mypage/LC_Page_Mypage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion data/class/pages/products/LC_Page_Products_Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/class/pages/products/LC_Page_Products_List.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? '';
}

// 商品名検索条件
Expand Down
4 changes: 2 additions & 2 deletions data/class/pages/shopping/LC_Page_Shopping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
8 changes: 6 additions & 2 deletions data/class/pages/shopping/LC_Page_Shopping_Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit d5fdc4c

Please sign in to comment.