Skip to content

Updated folder methods#249

Open
jboomer007 wants to merge 3 commits into
Garethp:masterfrom
jboomer007:Updated-Folder-Methods
Open

Updated folder methods#249
jboomer007 wants to merge 3 commits into
Garethp:masterfrom
jboomer007:Updated-Folder-Methods

Conversation

@jboomer007

Copy link
Copy Markdown

No description provided.

Added Updated Folder Method
@marclaporte

Copy link
Copy Markdown

@jboomer007

I know it's been a while since your PR. I'd like to clean up list, improve things and get a new release.

Code has changed somewhat since your PR: https://github.com/Garethp/php-ews/commits/master/

Do you think it's still valid?

Thanks!

CC @kambereBr if you can opine)

@kambereBr

Copy link
Copy Markdown

@jboomer007 are you trying to replace the magic method by removing the @method UpdateFolder($request) annotation (line 78, ExchangeWebServices.php) and adding a concrete updateFolder() method instead?

If so, I’m concerned this would cause a major regression:

  • Current magic method : full UpdateFolder SOAP support (any folder properties)

  • Proposed change : hardcoded to only update DisplayName

That would break code relying on updates to other folder properties.

FYI: Magic method removal has already been started in PR #265, but the goal should be maintaining the same capabilities, not reducing functionality.

Thank you!

@jboomer007

jboomer007 commented Aug 27, 2025 via email

Copy link
Copy Markdown
Author

@Garethp

Garethp commented Aug 30, 2025

Copy link
Copy Markdown
Owner

While I think there might be scope to have a simpler method for updating folders, I think a method that updates a single property on a folder might be too narrow-scope to fit in with the simpler API usages that I've built. Taking a look at the other update* type methods that I've written, they tend to accept a wider range of changes rather than targeting specific items. I'm happy to be convinced otherwise, but that would be my take on it at the moment.

@marclaporte

Copy link
Copy Markdown

@jboomer007 @kambereBr any wisdom? :-)

@kambereBr

Copy link
Copy Markdown

@jboomer007 wanted to check back in on this since it's been a while. So based on what @Garethp said, I think we can still keep the rename working, just not hardcode it to only the name. Basically do it the same way updateItems() works, you pass the change in yourself instead of it being fixed to one field.

If you have time to update the PR that way, I'll be happy to see it move forward. If not just let me know and I'll open a new PR with this approach so it's not stuck forever. Either way works for me, just want to get this moving.

Thank you!

@jboomer007

Copy link
Copy Markdown
Author

Here is the update that allows for you to pass an array of properties. Its a rough but works

@jboomer007

Copy link
Copy Markdown
Author

@jboomer007 wanted to check back in on this since it's been a while. So based on what @Garethp said, I think we can still keep the rename working, just not hardcode it to only the name. Basically do it the same way updateItems() works, you pass the change in yourself instead of it being fixed to one field.

If you have time to update the PR that way, I'll be happy to see it move forward. If not just let me know and I'll open a new PR with this approach so it's not stuck forever. Either way works for me, just want to get this moving.

Thank you!

This has been updated. I gave a sample in the documentation for the function

Comment thread src/API.php
return Utilities\ensureIsArray($this->getFolder($folderId->toArray(true)));
}

if ($response instanceof FolderInfoResponseMessageType) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@jboomer007 thanks for the new commit. A few small things still need to be sorted out before we ask for another review from @Garethp

First, there's a bug here: you check $response instanceof FolderInfoResponseMessageType but I don't see that class imported anywhere at the top of API.php. That will throw a "class not found" or similar error the first time an update actually succeeds, you will need to add use garethp\ews\API\Message\FolderInfoResponseMessageType;.

Comment thread src/API.php
public function updateFolder(BaseFolderIdType $folderId, $foldersFields, $options = [])
{
$folderChange = $folderId->toArray(true);
$folderChange['Updates'] =['SetFolderField' => $foldersFields];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Second, it's still only handling SetFolderField. To really match how updateItems() works, it would need to support DeleteFolderField and AppendToFolderField too, and ideally more than one field change per call. Right now it's wider than before but still a step short of that.

Comment thread src/API.php
// ("Value cannot be null. (Parameter 'participantResolver')") on
// cold/app-only mailboxes. The write succeeds, so verify the folder
// instead of failing outright; rethrow anything else.
if (stripos($e->getMessage(), 'internal server error') === false) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Last one, the try/catch around "internal server error" worries me a bit. Matching on a string inside the exception message and then treating it as a success feels risky, that same message could show up for a real failure too and we'd silently swallow it. Can you say more about when you're hitting that error? Might be better to fix the actual cause than catch around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants