-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.3] Static Code Analysis for Components #17085
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
Changes from 1 commit
24839fb
017ba7f
eaada24
4bdc26b
e39154e
c3a4f7f
0016474
918a018
18ce233
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…e is_dir instead of file_exists
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,8 @@ public function __construct($savePath = null) | |
$baseDir = ltrim(strrchr($savePath, ';'), ';'); | ||
} | ||
|
||
if ($baseDir && !file_exists($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) { | ||
throw new \RuntimeException('Session Storage was not able to create a folder: '.$baseDir); | ||
if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) { | ||
throw new \RuntimeException(sprintf('The Session Storage was not able to create a directory: %s', $baseDir)); | ||
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. did anyone report the need for these exceptions? I'm sure something already fails when the dir can't be created. Did you experience any "unclear" error? 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. Nope, it was no reports about this. Yep, had to support couple cases when settings were misconfigured and these exceptions pointing problematic configurations really fast. In 99.9% of cases (I guess) exceptions will not make any harm due to default settings. 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. Ok then , thanks for the argument :) 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. Glad to share =) Will apply wording adjustments for all exceptions. |
||
} | ||
|
||
ini_set('session.save_path', $savePath); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,8 @@ public function load(TemplateReferenceInterface $template) | |
|
||
$content = $storage->getContent(); | ||
|
||
if (!file_exists($dir) && !@mkdir($dir, 0777, true) && !is_dir($dir)) { | ||
throw new \RuntimeException('Cache Loader was not able to create a folder: '.$dir); | ||
if (!is_dir($dir) && !@mkdir($dir, 0777, true) && !is_dir($dir)) { | ||
throw new \RuntimeException(sprintf('Cache Loader was not able to create a directory: %s', $dir)); | ||
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. sometimes you have 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. Agree, will adjust. 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. Adjusted |
||
} | ||
|
||
file_put_contents($path, $content); | ||
|
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.
Does this add anything? If the directory doesn't exists, writeCacheFile already throws an exception...
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.
Do you mean "Failed to write cache file"?
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.
Yes
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.
I'd rather expect the component to separate exceptions: because case "directory can not be created" and "file not dumped/file not renamed" needs different investigations.