Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[LDAP] Allow adding and removing values to/from multi-valued attributes#21856

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

Merged
fabpot merged 1 commit intosymfony:masterfromjean-gui:master
Apr 4, 2018

Conversation

@jean-gui
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
LicenseMIT

EntryManagerInterface::update(Entry $entry) is extremely slow in some specific cases such as adding or removing members to or from huge groupOfNames if you also enable the memberOf overlay in OpenLDAP. Disabling memberOf does make things a lot better, but it is still slow compared to inserting/removing only the elements you want.

This PR adds two methods to Symfony\Component\Ldap\Adapter\ExtLdap\EntryManager taking advantage of ldap_mod_add and ldap_mod_del.

I thought about using them directly in the update method, but since you need to know what values to add and remove, it would be necessary to retrieve the old values from LDAP.

I'm also unsure whether these two methods should be in an interface. I think that adding them to EntryManagerInterface would break BC, but I could create another interface, similarly to RenameEntryInterface.

@nicolas-grekas
Copy link
Member

ping@csarrazi

@nicolas-grekasnicolas-grekas added this to the3.x milestoneMar 4, 2017
@csarrazi
Copy link
Contributor

I think that we could improve this by introducing a new API for handling changes.

Instead of using separate methods for different things, we should rather use a Command pattern, and provide a set of commands which could be implemented without breaking the interface each time we need to implement something.

This way, we could have a runCommand() method in the EntryManager, with a list of operations:

  • UpdateEntry
  • AddAttributes
  • RemoveAttributes
  • RenameEntry

This would support the current set, and we could deprecate the other methods afterwards.

What do you think about this@nicolas-grekas ?

@csarrazi
Copy link
Contributor

By the way, this means that theadd(),update(),remove() andrename() methods should all be deprecated, in favor of therunCommand() (OrexecuteCommand()) method.

@nicolas-grekas
Copy link
Member

ping@jean-gui

@jean-gui
Copy link
ContributorAuthor

I was actually waiting for your response to@csarrazi's ping. I'm not sure I have the necessary skills or time to implement this new API though. I'll try to, but am not making any promises.

@csarrazi
Copy link
Contributor

@jean-gui want me to take over that one?

@csarrazi
Copy link
Contributor

I won't have much time before next week, though.

@symfony/deciders What do you think about the suggestion, btw?

@jean-gui
Copy link
ContributorAuthor

@csarrazi If you can, sure!

@nicolas-grekas
Copy link
Member

Let's see how it goes for 3.4 :)

@nicolas-grekas
Copy link
Member

Status: needs work

@fabpot
Copy link
Member

@csarrazi Do you think you will have time to work on this one soon? If not, anybody else?

@csarrazi
Copy link
Contributor

Hi@fabpot. Unfortunately I won't have time to work on this anytime soon. I can spend some time reviewing PRs, but unfortunately I have little time to do anything else.

@nicolas-grekas
Copy link
Member

Moving to 4.1. Rebase on master might be needed, where PHP 7.1 features can be used btw.

@nicolas-grekasnicolas-grekas modified the milestones:3.4,4.1Oct 8, 2017
@fabpot
Copy link
Member

Anyway willing to take over this one? If not, I'm going to close.

@jean-gui
Copy link
ContributorAuthor

@fabpot If no one is willing to tackle the big refactoring suggested by@csarrazi, perhaps this PR could be considered for merging.

@csarrazi
Copy link
Contributor

We can do that. Like I mentioned before, I no longer contribute to Symfony on a regular basis.

One thing though. I would change the method name to removeAttributeValues / addAttributeValues.

Second, this PR should be updated to take into account changes in coding standards for Symfony 4 (PHP > 7.1.3 is used, so scalar type hinting can be used now).

By the way,$values should be type hinted as anarray.

@jean-gui
Copy link
ContributorAuthor

I'll try to do that today.

@jean-guijean-guiforce-pushed themaster branch 2 times, most recently from03932c6 toafd02ffCompareApril 4, 2018 16:47
Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

some small comments (mainly coding standard).

*
* @param Entry $entry
* @param string $attribute
* @param array $values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The 3@param entries can be removed (we don't add those if they don't add something that is not part of the PHP method signature already).

}

/**
* Adds values to an entry's multi-valued attribute from the Ldap server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LDAP


if (!@ldap_mod_add($con,$entry->getDn(),array($attribute =>$values))) {
thrownewLdapException(sprintf('Could not add values to entry "%s", attribute %s: %s',$entry->getDn(),
$attribute,ldap_error($con)));
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

missing dot at the end of the error message.

}

/**
* Removes values from an entry's multi-valued attribute from the Ldap server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LDAP

*
* @param Entry $entry
* @param string $attribute
* @param array $values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

same as above

if (!@ldap_mod_del($con,$entry->getDn(),array($attribute =>$values))) {
thrownewLdapException(sprintf('Could not remove values from entry "%s", attribute %s: %s',
$entry->getDn(),
$attribute,ldap_error($con)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should also be on one line, and dot missing at the end of the error message.

@jean-gui
Copy link
ContributorAuthor

Done. Should I add those new methods to EntryManagerInterface? Would that be a BC break?

@fabpot
Copy link
Member

Adding them to the interface would be a BC break.

@fabpot
Copy link
Member

One last thing before merging: can you add a note about these 2 new methods in the composer CHANGELOG file?

@jean-gui
Copy link
ContributorAuthor

Done (if src/Symfony/Component/Ldap/CHANGELOG.md is the file you meant).

I should probably submit a PR for the doc as well.

Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A PR on the docs would be the cherry on the cake :)

@fabpot
Copy link
Member

Thank you@jean-gui.

@fabpotfabpot merged commitfa9db29 intosymfony:masterApr 4, 2018
fabpot added a commit that referenced this pull requestApr 4, 2018
…valued attributes (jean-gui)This PR was merged into the 4.1-dev branch.Discussion----------[LDAP] Allow adding and removing values to/from multi-valued attributes| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| License       | MIT`EntryManagerInterface::update(Entry $entry)` is extremely slow in some specific cases such as adding or removing members to or from huge groupOfNames if you also enable the memberOf overlay in OpenLDAP. Disabling memberOf does make things a lot better, but it is still slow compared to inserting/removing only the elements you want.This PR adds two methods to Symfony\Component\Ldap\Adapter\ExtLdap\EntryManager taking advantage of ldap_mod_add and ldap_mod_del.I thought about using them directly in the update method, but since you need to know what values to add and remove, it would be necessary to retrieve the old values from LDAP.I'm also unsure whether these two methods should be in an interface. I think that adding them to EntryManagerInterface would break BC, but I could create another interface, similarly to RenameEntryInterface.Commits-------fa9db29 Allow adding and removing values to/from multi-valued attributes
jean-gui added a commit to jean-gui/symfony-docs that referenced this pull requestApr 4, 2018
jean-gui added a commit to jean-gui/symfony-docs that referenced this pull requestApr 10, 2018
jean-gui added a commit to jean-gui/symfony-docs that referenced this pull requestApr 10, 2018
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestApr 16, 2018
…tributes (jean-gui)This PR was merged into the master branch.Discussion----------Documented how to add or remove values of multi-valued attributesRelated tosymfony/symfony#21856<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/roadmap for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `master` for features of unreleased versions).-->Commits-------40df041 Documented how to add or remove values of multi-valued attributes
@fabpotfabpot mentioned this pull requestMay 7, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

5 participants

@jean-gui@nicolas-grekas@csarrazi@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp