Skip to content

fix: 管理画面の会員一覧で LIMIT が適用されない不具合を修正 (#1398)#1399

Merged
nanasess merged 4 commits into
EC-CUBE:masterfrom
nanasess:issue-1398
May 26, 2026
Merged

fix: 管理画面の会員一覧で LIMIT が適用されない不具合を修正 (#1398)#1399
nanasess merged 4 commits into
EC-CUBE:masterfrom
nanasess:issue-1398

Conversation

@nanasess
Copy link
Copy Markdown
Contributor

@nanasess nanasess commented May 25, 2026

Summary

Closes #1398

PR #1116 (5559b6a0, 2025-01-10) で SC_Query::setLimitOffset() が MDB2 connection への即時反映から \$this->limit / \$this->offset への保存のみに変更された結果, \$objQuery->getAll() に生 SQL を直接渡す SC_Helper_Customer::sfGetSearchData() では LIMIT/OFFSET が一切付与されず, 管理画面の会員一覧 (/admin/customer/) で dtb_customer の全件が取得・表示される回帰が発生していました。

修正方針 (Issue 修正案 A: 局所修正)

呼び出し側で \$objQuery->dbFactory->addLimitOffset() を直接適用し, SC_Query::setLimitOffset() の内部実装に依存せず確実に LIMIT/OFFSET を SQL へ注入します。

  • SC_Query::getSql() が内部で行っている処理と同等
  • 既存に同パターン (LC_Page_Admin_Home::page(), SC_Product::getProductsClassFullByProductId(), ItemSearch) の先例あり
  • 他の setLimitOffset() 呼び出し箇所は SC_Query::select() / getOne() 等の getSql() 経由メソッドで結果を受けているため LIMIT が SQL に反映されており, 本件の影響は受けない

コミット

  1. test: 回帰防止用の PHPUnit / E2E テストを追加
  2. fix: 本体修正 (SC_Helper_Customer::sfGetSearchData())

Test plan

  • PHPUnit (sqlite3): tests/class/helper/SC_Helper_Customer/ 4 テスト pass
    • 修正前: testSfGetSearchDataRespectsLimit / testSfGetSearchDataPaginationReturnsDifferentRows が fail (LIMIT/OFFSET 未適用を検知)
    • 修正後: 4 テスト pass
  • PHPUnit 全体 (sqlite3): 1772 tests, 2670 assertions OK (skipped 19, incomplete 2 はいずれも既存)
  • E2E (sqlite3, ローカル, 31 件フィクスチャ): e2e-tests/test/admin/customer/list_pagination.test.ts pass
    • 修正前: Expected 10 / Received 31 で fail (回帰再現を E2E でも確認)
    • 修正後: pass
  • CI: MySQL / PostgreSQL / SQLite3 × PHP 7.4-8.5 のマトリクス全 green を確認

補足

.github/workflows/e2e-tests.yml--customers=1--customers=30 に変更しています。これは追加した E2E (ページネーション動作確認) に 10 件以上の会員データが必要なためです。他の E2E は MAX(customer_id) 等で最新会員を取得しており, フィクスチャ件数の増加による影響はありません。

Summary by CodeRabbit

  • Bug Fixes

    • 会員一覧のページング処理を修正し、検索時のLIMIT/オフセットが正しく反映されるようにしました。
  • Tests

    • 管理画面の会員一覧ページング回帰テストを追加しました。
    • 会員検索の単体テストを追加し、LIMIT・ページング・全件取得モードの動作を検証します。
  • Chores

    • テスト用データ生成数を増やし(顧客数を30件に拡大)テストの再現性を高めました。

Review Change Stack

nanasess added 2 commits May 25, 2026 16:17
PR EC-CUBE#1116 で生じた SC_Helper_Customer::sfGetSearchData() の LIMIT 不適用回帰を
回帰防止できるテストを追加する。

- PHPUnit (tests/class/helper/SC_Helper_Customer/): page_max / linemax / OFFSET /
  limitMode の 4 観点を網羅。修正前は LIMIT/OFFSET 検証 2 件が必ず fail する。
- E2E (e2e-tests/test/admin/customer/list_pagination.test.ts): 30 件のフィクスチャで
  ページャを操作し, ページ毎に異なる会員 ID が返ることを確認。
- .github/workflows/e2e-tests.yml: 上記 E2E の前提として --customers 数を
  1 → 30 に増加。他テストは MAX(customer_id) で最新会員を取得しており影響なし。
PR EC-CUBE#1116 で SC_Query::setLimitOffset() の挙動が MDB2 connection への即時反映
から $this->limit/$this->offset への保存のみへ変更された。
これらの値は SC_Query::getSql() 経由でしか SQL に注入されないため,
$objQuery->getAll() に生 SQL を直接渡す SC_Helper_Customer::sfGetSearchData()
では LIMIT/OFFSET が一切付与されず, 管理画面の会員一覧
(/admin/customer/) で dtb_customer の全件が取得・表示される回帰が発生していた。

呼び出し側で $objQuery->dbFactory->addLimitOffset() を直接適用することで,
SC_Query::setLimitOffset() の内部実装に依存せず確実に LIMIT/OFFSET を
SQL へ注入する。SC_Query::getSql() が内部で行っているのと同等の処理であり,
LC_Page_Admin_Home::page() や SC_Product::getProductsClassFullByProductId()
等にも同パターンの先例がある。

他の setLimitOffset() 呼び出し箇所は SC_Query::select() / SC_Query::getOne()
等の getSql() 経由のメソッドで結果を受けており, LIMIT/OFFSET が正常に
SQL へ反映されるため本件の影響は受けない。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

📝 Walkthrough

Walkthrough

sfGetSearchData() が生成する生SQLへ明示的に LIMIT/OFFSET を適用するよう修正し、その挙動を検証する単体テストと管理画面向けE2E回帰テストを追加、E2E用フィクスチャを30件に増やした。

Changes

Pagination Fix and Validation

Layer / File(s) Summary
SQL Pagination Logic Fix
data/class/helper/SC_Helper_Customer.php
sfGetSearchData() が生成した生SQLを $sql に保持し、$limitMode == '' の場合に dbFactory->addLimitOffset($sql, $page_max, $offset) で LIMIT/OFFSET を付与して getAll() に渡すように変更。
Unit Tests for sfGetSearchData Pagination
tests/class/helper/SC_Helper_Customer/SC_Helper_Customer_sfGetSearchDataTest.php
新規テストクラスを追加。setUp() でデータ作成、buildSearchParam() と4つのテストで LIMIT 適用、linemax、ページ間重複、limitMode='all' の振る舞いを検証。
E2E Regression Test for Customer List Pagination
e2e-tests/test/admin/customer/list_pagination.test.ts
管理画面の会員一覧で search_page_max=10 を選択してページング表示と顧客IDの重複が発生しないことを検証する Playwright テストを追加。
Test Fixture Scaling
.github/workflows/e2e-tests.yml
E2E ワークフロー内の eccube:fixtures:generate に渡す --customers1 から 30 に増加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 小さな野ウサギが跳ねて言う、
LIMIT を付けて行を数えるよ、
テストは増え、フィクスチャも三十、
ページは分かれ、ID は重ならず、
バグは隠れ場を失った。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは「fix: 管理画面の会員一覧で LIMIT が適用されない不具合を修正 (#1398)」で、Issue #1398 の主要な課題を正確に反映しており、修正対象と修正内容を明確に述べています。
Linked Issues check ✅ Passed SC_Helper_Customer::sfGetSearchData() への addLimitOffset 適用、PHPUnit・E2E テスト追加により、Issue #1398 の問題解消(LIMIT が SQL に反映されない回帰修正)と期待結果(ページネーション正常化)の要件を完全に満たしています。
Out of Scope Changes check ✅ Passed e2e-tests/test/admin/customer/list_pagination.test.ts のフィクスチャ件数変更(1→30)と .github/workflows/e2e-tests.yml の customers パラメータ変更(1→30)は、テスト対象環境のスケール拡大であり、回帰テスト有効性強化のための範囲内の変更です。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.88%. Comparing base (32bc080) to head (7e9bebc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1399      +/-   ##
==========================================
+ Coverage   55.30%   55.88%   +0.58%     
==========================================
  Files          87       87              
  Lines       11089    11090       +1     
==========================================
+ Hits         6133     6198      +65     
+ Misses       4956     4892      -64     
Flag Coverage Δ
tests 55.88% <100.00%> (+0.58%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e-tests/test/admin/customer/list_pagination.test.ts`:
- Line 18: Fix the space-before-function-paren ESLint violation on the
collectCustomerIds function declaration: update the declaration of async
function collectCustomerIds(page: Page): Promise<string[]> to match the
project's ESLint rule (remove the extra space before the opening parenthesis or
add it if your config requires it) so the function signature conforms to the
configured space-before-function-paren rule.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6b967806-50b9-4b20-8c54-316e231e68f3

📥 Commits

Reviewing files that changed from the base of the PR and between 1837233 and 3d1e273.

📒 Files selected for processing (4)
  • .github/workflows/e2e-tests.yml
  • data/class/helper/SC_Helper_Customer.php
  • e2e-tests/test/admin/customer/list_pagination.test.ts
  • tests/class/helper/SC_Helper_Customer/SC_Helper_Customer_sfGetSearchDataTest.php

Comment thread e2e-tests/test/admin/customer/list_pagination.test.ts Outdated
CodeRabbit からの指摘 (EC-CUBE#1399 review):
list_pagination.test.ts の collectCustomerIds 関数宣言が
.eslintrc.json の `space-before-function-paren: { named: always }`
ルールに違反していたため, 関数名と括弧の間にスペースを追加。
@nanasess nanasess requested a review from seasoftjapan May 25, 2026 07:34
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
e2e-tests/test/admin/customer/list_pagination.test.ts (1)

26-47: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

E2E実行要件(MySQL/PostgreSQL + Playwright 1.52.0)の整合確認

  • 本リポジトリの Playwright は package.json / package-lock.json で 1.56.0 になっており、ガイドライン指定の 1.52.0 と不一致です(要件に合わせてバージョンを揃える/PRで使用バージョンを明記)。
  • ガイドライン要件どおり、MySQL/PostgreSQL 環境でローカル実行した根拠として「実行コマンド・環境(DB種別/設定)・成功ログ」をPRに追記してください。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/test/admin/customer/list_pagination.test.ts` around lines 26 - 47,
The repository's Playwright version (package.json / package-lock.json) is 1.56.0
but the project guideline requires 1.52.0 and the PR lacks local-run evidence;
update package.json and package-lock.json to use Playwright 1.52.0 (or
explicitly state and justify using 1.56.0) and regenerate lockfile so tests
install the correct version, and then append to this PR a short runnable proof
for the e2e test (e2e-tests/test/admin/customer/list_pagination.test.ts)
including the exact command used to run Playwright, the DB type and
connection/configuration (MySQL or PostgreSQL and relevant settings), and the
success log output or a screenshot demonstrating the test passed locally.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@e2e-tests/test/admin/customer/list_pagination.test.ts`:
- Around line 26-47: The repository's Playwright version (package.json /
package-lock.json) is 1.56.0 but the project guideline requires 1.52.0 and the
PR lacks local-run evidence; update package.json and package-lock.json to use
Playwright 1.52.0 (or explicitly state and justify using 1.56.0) and regenerate
lockfile so tests install the correct version, and then append to this PR a
short runnable proof for the e2e test
(e2e-tests/test/admin/customer/list_pagination.test.ts) including the exact
command used to run Playwright, the DB type and connection/configuration (MySQL
or PostgreSQL and relevant settings), and the success log output or a screenshot
demonstrating the test passed locally.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75fa2c85-023a-4261-a752-0c74baa88749

📥 Commits

Reviewing files that changed from the base of the PR and between 3d1e273 and dce500a.

📒 Files selected for processing (1)
  • e2e-tests/test/admin/customer/list_pagination.test.ts

Copy link
Copy Markdown
Contributor

@seasoftjapan seasoftjapan left a comment

Choose a reason for hiding this comment

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

nanasess:issue-1398 をチェックアウトして動作を確認した。問題ない。
実装を確認した。問題ない。
テストはコードまで確認できていないが、確認内容は妥当な内容だと思う。

@nanasess nanasess enabled auto-merge May 25, 2026 12:22
@nanasess nanasess merged commit fbc45f7 into EC-CUBE:master May 26, 2026
335 of 337 checks passed
@nanasess nanasess deleted the issue-1398 branch May 26, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

管理画面の会員一覧 (/admin/customer/) で LIMIT が適用されず全件取得される (PR #1116 起因の回帰)

2 participants