Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[LDAP] Add "applyOperations" method to EntryManager#27069
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
| /** | ||
| * @param string $dn | ||
| * @param iterable|array|ModificationInterface[] $modifications |
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 thinkiterable|ModificationInterface[] is sufficient here. the indent is a bit off though
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.
here are some minor comments
ping@csarrazi since you're our LDAP referent :)
| publicfunctionremove(Entry$entry); | ||
| /** | ||
| * @param string $dn |
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.
should be removed (duplicates the signature
| /** | ||
| * @param string $dn | ||
| * @param iterable|array|ModificationInterface[] $modifications |
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.
no need for "array"
| * @param string $dn | ||
| * @param iterable|array|ModificationInterface[] $modifications | ||
| * | ||
| * @return bool |
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.
conflicts with:void
| * | ||
| * @return bool | ||
| * | ||
| * @throws LdapException |
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.
hinting when would be great
| * @param string $dn | ||
| * @param iterable|array|ModificationInterface[] $modifications | ||
| * | ||
| * @return bool |
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.
(see previous comments that apply to this docblock also)
| } | ||
| if (!@ldap_modify_batch($this->getConnectionResource(),$dn,$modificationsMapped)) { | ||
| thrownewLdapException( |
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.
should be on one line
| if (!@ldap_modify_batch($this->getConnectionResource(),$dn,$modificationsMapped)) { | ||
| thrownewLdapException( | ||
| sprintf('Could execute batch modification on "%s": %s',$dn,ldap_error($this->getConnectionResource())) |
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.
Couldnot?
& missing dot at end of message
| privatefunctionassertValidModificationType(int$type):void | ||
| { | ||
| if (!in_array($type,$this->validModificationTypes,true)) { | ||
| thrownewLdapException(sprintf('%s is not a valid modification type.',$type)); |
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.
missing double quotes around %s
| LDAP_MODIFY_BATCH_REPLACE, | ||
| ); | ||
| publicfunction__construct($modificationType,string$attribute,array$values =null) |
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.
missing type hint on $modificationType?
| interface ModificationInterface | ||
| { | ||
| /** | ||
| * @return array |
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.
should be removed
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 the whole Interface or only the docblock?
mablae commentedApr 29, 2018
@nicolas-grekas Thanks for your feedback. I will correct these spots. Sorry for steeling your time with inconsistent Docblocks. I was not sure about introducing the ModificationInterface at all. Maybe that's over engineered? |
csarrazi commentedApr 30, 2018
I'm really not fond of adding new methods to I'm absolutely not against adding new methods directly to the Also, I would also remove the I feel that in the long term, would should use the That was actually the design that I wished for at first, but this was never done due to time constraints. |
mablae commentedApr 30, 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.
Ok.
Is
I also thought about this direction but it will be much more work, like UnitOfWork state management, correct? What to do? Simplify the current approach like you suggested or close the PR for the moment? Thanks for your review! |
csarrazi commentedApr 30, 2018
Keep the current approach for now, just remove the method from the interface. Regarding UpdateOperation, the remove is only applied to a single attribute value, or all values for a single attribute, but this is in reality a form of update. In LDAP, entries are the first class objects. Attributes are directly embedded within an entry, which means that all these operations (add, remove, remove_all, update) are actually all part of the same update. |
mablae commentedApr 30, 2018
Okay, thanks! I will update the PR tonight. |
mablae commentedApr 30, 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.
@csarrazi I updated the code as you have suggested. Test Results because LDAP is not covered by Travis: I have used an openldap docker image for testing and pointed the bootstrap directory to the fixtures. @csarrazi How do you run the tests? Maybe including this docker stuff in |
csarrazi commentedApr 30, 2018
@mablae You can use the csarrazi/symfony-ldap Docker container, if you want to test easily :) This is what I actually run for testing on my end: docker run -d --name ldap -p 3389:389 \ -v"/Users/csarrazi/Projects/csarrazi/symfony/src/Symfony/Component/Ldap/Tests/Fixtures/data:/init-ldap.d" \ -e"LDAP_SUFFIX=dc=symfony,dc=com" \ -e"LDAP_ROOTDN=cn=admin,dc=symfony,dc=com" \ -e"LDAP_ROOTPW=symfony" \ csarrazi/symfony-ldap |
| * | ||
| * @throws UpdateOperationException in case of an error | ||
| */ | ||
| publicfunctionapplyOperations(string$dn,iterable$modifications):void |
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.
$operations
| */ | ||
| publicfunctionapplyOperations(string$dn,iterable$modifications):void | ||
| { | ||
| $modificationsMapped =array(); |
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.
$mappedOperations
| publicfunctionapplyOperations(string$dn,iterable$modifications):void | ||
| { | ||
| $modificationsMapped =array(); | ||
| foreach ($modificationsas$modification) { |
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.
$operations as $operation
mablae commentedMay 1, 2018
Docs PR added, too |
mablae commentedMay 3, 2018
From my side it's ready, what do you think,@csarrazi ? |
csarrazi commentedMay 4, 2018
LGTM. Sorry for the late answer, the week has been pretty busy, as always :) |
mablae commentedMay 9, 2018
Someone please remove "Need work" in that case. 😄 If anything is missing or can made better just let me know. We even have still some time until |
csarrazi commentedMay 13, 2018
Ping@nicolas-grekas |
fabpot 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.
with some minor comments (mainly CS)
| /** | ||
| * @param int $operationType An LDAP_MODIFY_BATCH_* constant | ||
| * @param string $attribute The attribute to batch modify on | ||
| * @param array|null $values |
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.
This@param can be removed (as it does not add anything that is not already in the signature)
| /** | ||
| * @param string $dn Distinguished name to apply operations on | ||
| * @param iterable|UpdateOperation[] $operations An array or iterable of Modification instances |
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 suppose thatModification should beUpdateOperation here.
| } | ||
| /** | ||
| * @param string $dn Distinguished name to apply operations on |
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 this one can be removed.$dn in this context is pretty clear.
Also introduce new UpdateOperation class.
mablae commentedMay 13, 2018
Thanks@fabpot ! I have updated the code according to your suggestions and rebased/squashed it against current master. |
fabpot commentedMay 18, 2018
Thank you@mablae. |
…ablae)This PR was merged into the 4.2-dev branch.Discussion----------[LDAP] Add "applyOperations" method to EntryManager| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#27039| License | MIT| Doc PR |symfony/symfony-docs#9715This PR adds a new method called `applyOperations` to the LDAP `EntryManager` class.Internally it is mapping the new `UpdateOperation` object to the `ldap_modify_batch` method.Tests green against openldap.Thanks for any feedback.Todo: * [x] Add Docs PRCommits-------8fc09c7 Add applyOperations batch method to EntryManager
This PR was merged into the master branch.Discussion----------[LDAP] Add docs for applyOperations methodSee PRsymfony/symfony#27069Commits-------74fed75 [LDAP] Add docs for applyOperations method

Uh oh!
There was an error while loading.Please reload this page.
This PR adds a new method called
applyOperationsto the LDAPEntryManagerclass.Internally it is mapping the new
UpdateOperationobject to theldap_modify_batchmethod.Tests green against openldap.
Thanks for any feedback.
Todo: