Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle] Allow user to specify folder for flock#26923
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas left a comment
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.
looks like a good idea to me
ping@jderusse for 2nd review
what about adding some tests?
| foreach ($resourceStoresas$storeDsn) { | ||
| $storeDsn =$container->resolveEnvPlaceholders($storeDsn,null,$usedEnvs); | ||
| switch (true) { | ||
| case'flock' ===$storeDsn: |
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 think we should keep this case, and add a new one after
| switch (true) { | ||
| case'flock' ===$storeDsn: | ||
| $storeDefinition =newReference('lock.store.flock'); | ||
| case0 ===strpos($storeDsn,'flock'): |
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.
case 0 === strpos($storeDsn, 'flock://'): + substr instead of str_replace below
| if ($isMatched) { | ||
| $storeDefinition =newDefinition(FlockStore::class); | ||
| $storeDefinition->setPublic(false); |
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.
not required anymore, this is the default since 4.0
| $storeDefinition =newDefinition(FlockStore::class); | ||
| $storeDefinition->setPublic(false); | ||
| $storeDefinition->setArguments(array($flockPath)); | ||
| $container->setDefinition($storeDefinitionId ='lock.flock.store.'.$container->hash($storeDsn),$storeDefinition); |
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.
anticipating for#26921, the service name should start with a dot
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 suggest this:
$storeDefinitionId ='.lock.flock.store.'.$container->hash($storeDsn);$container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath);
jderusse left a comment
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.
Great idea, I like the use of DSN for such purpose.
Nothing to add to@nicolas-grekas 's comments :)
MaksSlesarenko commentedApr 16, 2018
updated pr. |
| case'flock' ===$storeDsn: | ||
| $storeDefinition =newReference('lock.store.flock'); | ||
| break; | ||
| case0 ===strpos($storeDsn,'flock'): |
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.
'flock://'
| case0 ===strpos($storeDsn,'flock'): | ||
| $flockPath =substr($storeDsn,8); | ||
| $storeDefinitionId ='lock.flock.store.'.$container->hash($storeDsn); |
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.
'.lock.flock.store.'.$container->hash($storeDsn); as per@nicolas-grekas 's comment
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.
Can someone enlighten me about purpose of the starting dot?
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.
MaksSlesarenko commentedApr 20, 2018
up |
nicolas-grekas commentedApr 20, 2018
see fabbot failure :) |
| $flockPath =substr($storeDsn,8); | ||
| $storeDefinitionId ='.lock.flock.store.'.$container->hash($storeDsn); | ||
| $container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath); |
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.
missinguse statement for theFlockStore class
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.
done
MaksSlesarenko commentedMay 8, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Is there anything else I forgot to fix? |
| $storeDefinitionId ='.lock.flock.store.'.$container->hash($storeDsn); | ||
| $container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath); | ||
| $storeDefinition =newReference($storeDefinitionId); |
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 we need the reference? I mean if I don't miss anything, we do not reuse it anyway, so something like this should work the same:
$flockPath =substr($storeDsn,8);$storeDefinitionId ='.lock.flock.store.'.$container->hash($storeDsn);$storeDefinition =$container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath);
MaksSlesarenkoMay 11, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Same can be said for both 'flock' and 'semaphore' cases. But I'm not sure that this PR is correct place for such refactoring. Besides '$storeDefinitions' already contains 'Reference' objects so it would be not cool to add strings or non-Reference type
MaksSlesarenko commentedMay 21, 2018
up |
fabpot commentedSep 4, 2018
Thank you@MaksSlesarenko. |
…ck (MaksSlesarenko)This PR was merged into the 4.2-dev branch.Discussion----------[FrameworkBundle] Allow user to specify folder for flock| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| License | MIT| Doc PR |In case multiple applications running on same server allow user to specify folder for flockexample:```framework: lock:` 'flock://var/flock' # var/flock will be provided as path to flock constructor lock: 'flock:///var/flock' # /var/flock will be provided as path to flock constructor lock: flock # works as usual, null is provided to constructor and system temp folder is used```Commits-------244d762 added ability to specify folder for flock
…rence (HypeMC)This PR was submitted for the 4.2 branch but it was squashed and merged into the 4.3 branch instead (closes#11466).Discussion----------Add flock:// option to framework lock configuration referenceFixes#9779 & extends#11465 .Documents the `flock://` option which was added withsymfony/symfony#26923 .**NOTE 1**: The xml configuration doesn't currently work, seesymfony/symfony#31197**NOTE 2**: This PR has all the changes that#11465 has plus some symfony 4.2 specific additions, so#11465 should probably be merged first.Commits-------d9125fd Add flock:// option to framework lock configuration reference
Uh oh!
There was an error while loading.Please reload this page.
In case multiple applications running on same server allow user to specify folder for flock
example: