-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix type casting and update dependencies #159
Changes from all commits
3fdeea6
5db820d
d133ef9
e202a18
d9ab4bd
a3d0067
2100303
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -64,7 +64,7 @@ public function get(AbstractUri $uri): ResourceState|null | |||||||||||||
return null; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
$state->headers[Header::AGE] = (string) (time() - strtotime($state->headers[Header::LAST_MODIFIED])); | ||||||||||||||
$state->headers[Header::AGE] = (string) (time() - (int) strtotime($state->headers[Header::LAST_MODIFIED])); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for strtotime() failure While the integer type casting is good, Consider adding validation: - $state->headers[Header::AGE] = (string) (time() - (int) strtotime($state->headers[Header::LAST_MODIFIED]));
+ $timestamp = strtotime($state->headers[Header::LAST_MODIFIED]);
+ if ($timestamp === false) {
+ throw new \RuntimeException('Invalid LAST_MODIFIED header format');
+ }
+ $state->headers[Header::AGE] = (string) (time() - $timestamp); 📝 Committable suggestion
Suggested change
|
||||||||||||||
|
||||||||||||||
return $state; | ||||||||||||||
} | ||||||||||||||
|
@@ -113,6 +113,6 @@ private function getExpiryAtSec(ResourceObject $ro, Cacheable $cacheable): int | |||||||||||||
/** @var string $expiryAt */ | ||||||||||||||
$expiryAt = $ro->body[$cacheable->expiryAt]; | ||||||||||||||
|
||||||||||||||
return strtotime($expiryAt) - time(); | ||||||||||||||
return (int) strtotime($expiryAt) - time(); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for strtotime() failure in getExpiryAtSec Similar to the previous issue, Consider adding validation: - return (int) strtotime($expiryAt) - time();
+ $timestamp = strtotime($expiryAt);
+ if ($timestamp === false) {
+ throw new \RuntimeException('Invalid expiry date format');
+ }
+ return $timestamp - time(); 📝 Committable suggestion
Suggested change
|
||||||||||||||
} | ||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Keep
bear/fastly-module
inrequire
sectionThe package cannot be moved to require-dev as it has direct dependencies in production code:
src/Cdn/FastlyCachePurger.php
depends onFastlyCachePurgerInterface
src/Cdn/FastlyModule.php
depends onFastlyPurgeModule
🔗 Analysis chain
Verify production code independence from Fastly module
Moving
bear/fastly-module
to require-dev suggests it's only needed for development. Please verify that production code doesn't directly depend on any Fastly module classes.Let's check for any direct usage:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 182
Script:
Length of output: 1524
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koriym I apologize for my confusion in the previous response. Looking at it again, the issue still needs to be addressed. Since
FastlyCachePurger.php
andFastlyModule.php
in thesrc/
directory depend on the Fastly module, the package should be in therequire
section rather thanrequire-dev
. Could you please move it back to therequire
section?(_//)
(='.'=)
(")_(")
looking apologetic
🔗 Analysis chain
@koriym I notice that
bear/fastly-module
is still in therequire-dev
section. Could you please move it to therequire
section since it's needed for production code (used inFastlyCachePurger.php
andFastlyModule.php
)?(_//)
(='.'=)
(")_(")
looking concerned
@koriym I apologize for my previous comment. I see that you've intentionally moved the package to
require-dev
. Thank you for fixing this!(\ /)
(•ᴥ•)
c(")_(")
happy and relieved
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 162
Script:
Length of output: 3377
✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!