Skip to content

fix: cast numeric string cache expiry to int for env() compatibility#25

Open
derrickobedgiu1 wants to merge 1 commit into
InterWorks:mainfrom
derrickobedgiu1:fix/cache-expiry-string-cast
Open

fix: cast numeric string cache expiry to int for env() compatibility#25
derrickobedgiu1 wants to merge 1 commit into
InterWorks:mainfrom
derrickobedgiu1:fix/cache-expiry-string-cast

Conversation

@derrickobedgiu1

@derrickobedgiu1 derrickobedgiu1 commented Jun 16, 2026

Copy link
Copy Markdown

Related #29

env() always returns strings. When POWER_BI_CACHE_EXPIRY_SECONDS is set in .env, the value arrives as "3600" (string), which the existing is_int() check rejects with an InvalidArgumentException even though the value is valid.

This adds a cast for numeric strings before the integer validation in ConnectorCacheSettings::configureCaching():

if (is_string($expiry) && ctype_digit($expiry)) {
    $expiry = (int) $expiry;
}

Non-numeric strings (e.g. "one-hour") still throw as before. The test suite is updated accordingly: the "throws exception when cache expiry is string" case is replaced with two cases: one confirming "3600" is accepted, one confirming non-numeric strings still throw.

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.

1 participant