Skip to content

Fix #80: Add $options to Memcached::__construct()#80

Merged
samdark merged 14 commits into
yiisoft:masterfrom
Gerych1984:options
May 25, 2026
Merged

Fix #80: Add $options to Memcached::__construct()#80
samdark merged 14 commits into
yiisoft:masterfrom
Gerych1984:options

Conversation

@Gerych1984
Copy link
Copy Markdown
Contributor

@Gerych1984 Gerych1984 commented May 12, 2026

Q A
Is bugfix? ✔️
New feature? ✔️
Breaks BC?

Summary by CodeRabbit

  • New Features

    • Memcached cache now supports configuration of additional options via configuration parameters.
    • Invalid or unsupported options are properly validated and reported as exceptions.
  • Tests

    • Added comprehensive test coverage for Memcached options initialization and validation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b5eaaff3-a4fc-4a5d-bff7-e4cc3f5968a5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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.

@Gerych1984 Gerych1984 marked this pull request as draft May 12, 2026 08:02
@Gerych1984 Gerych1984 marked this pull request as ready for review May 12, 2026 08:04
Comment thread src/Memcached.php Outdated
Comment thread src/Memcached.php Outdated
@samdark samdark requested a review from Copilot May 14, 2026 06:02
Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.93%. Comparing base (c8f9581) to head (1b4b065).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #80      +/-   ##
============================================
+ Coverage     98.91%   98.93%   +0.02%     
- Complexity       43       45       +2     
============================================
  Files             1        1              
  Lines            92       94       +2     
============================================
+ Hits             91       93       +2     
  Misses            1        1              

☔ 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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for passing Memcached extension options through the cache wrapper constructor and Yii DI configuration.

Changes:

  • Adds an $options constructor argument and applies it via Memcached::setOptions().
  • Adds default options params and wires them into DI config.
  • Adds tests for valid and invalid Memcached options.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/Memcached.php Adds constructor support for Memcached options.
config/params.php Adds default empty options configuration.
config/di.php Passes configured options into the Memcached constructor.
tests/MemcachedTest.php Adds option-related tests and updates the test helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Memcached.php Outdated
Comment thread tests/MemcachedTest.php Outdated
Comment thread src/Memcached.php
Comment thread config/di.php
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

🧹 Nitpick comments (1)
tests/MemcachedTest.php (1)

534-534: 💤 Low value

Follow PSR-12 method modifier order.

The method declaration uses static public, but PSR-12 specifies the order should be public static.

♻️ Suggested fix
-    static public function optionsProvider(): array
+    public static function optionsProvider(): array
🤖 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 `@tests/MemcachedTest.php` at line 534, The method declaration uses non-PSR-12
modifier ordering; change the declaration of the optionsProvider method from
"static public function optionsProvider()" to use the canonical order "public
static function optionsProvider()" so the method signature in the
tests/MemcachedTest.php (function name: optionsProvider) follows PSR-12.
🤖 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 `@src/Memcached.php`:
- Around line 71-83: The code must explicitly detect when
$this->cache->setOptions($options) returns false in addition to catching
converted PHP errors; update the try block around
$this->cache->setOptions($options) (the call to setOptions on $this->cache) to
capture its return value, and if that value === false throw an
InvalidArgumentException (include diagnostic info such as
$this->cache->getResultMessage() and getResultCode() if available) so
configuration failures are not silently ignored; preserve the existing
ErrorException-to-InvalidArgumentException conversion and ensure
restore_error_handler() still runs in the finally block.

---

Nitpick comments:
In `@tests/MemcachedTest.php`:
- Line 534: The method declaration uses non-PSR-12 modifier ordering; change the
declaration of the optionsProvider method from "static public function
optionsProvider()" to use the canonical order "public static function
optionsProvider()" so the method signature in the tests/MemcachedTest.php
(function name: optionsProvider) follows PSR-12.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f93cbb98-91ea-4887-9865-c7098d221cd4

📥 Commits

Reviewing files that changed from the base of the PR and between 43b60ca and 65f49cf.

📒 Files selected for processing (4)
  • config/di.php
  • config/params.php
  • src/Memcached.php
  • tests/MemcachedTest.php

Comment thread src/Memcached.php Outdated
samdark and others added 3 commits May 14, 2026 09:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@vjik vjik left a comment

Choose a reason for hiding this comment

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

  • Add line to changelog
  • Add info about new options to readme

Comment thread src/Memcached.php Outdated
@Gerych1984 Gerych1984 marked this pull request as draft May 21, 2026 10:45
@samdark
Copy link
Copy Markdown
Member

samdark commented May 23, 2026

@Gerych1984 it still fails tests.

@Gerych1984 Gerych1984 marked this pull request as ready for review May 25, 2026 11:25
Comment thread src/Memcached.php
Comment thread src/Memcached.php
Comment thread CHANGELOG.md Outdated
Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
@samdark samdark changed the title Add options to memcached Fix #80: Add $options to Memcached::__construct() May 25, 2026
@samdark samdark merged commit 9204394 into yiisoft:master May 25, 2026
13 checks passed
@samdark
Copy link
Copy Markdown
Member

samdark commented May 25, 2026

👍

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.

4 participants