-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add sizes() methods to protocol interface and implmentations #379
Conversation
Damn, I expected this to be a quick/easy fix. Up to now I was only using/exploring the library via composer. Sorry to have bothered you with this already. I'll set myself a proper testing environment up. :) |
Hi @didi1357 , I'm happily pressing the test button as often as it takes :) Best regards & happy coding, |
Hey, no need to press the button yet. :D I ran into an issue where you might have some valuable hint(s):
The response seems to be fine, but the dissection in Another thing also in that function which seems a bit fishy imho is this construct:
Without understanding the idea of that code: Are you sure, that the return inside the while is correct? It should either be an if, or no return inside, shouldn't it? |
Hey, I think I'm done with this issue. The problem wasn't my implementation of the feature, but the broken MSGN implementation. No clue why I used that one for my test at first. I added a test using UID which worked against my server. As it needs a real server, it's no unit test but just a file which should give anyone also trying that a head start. Other than that, I tried to adapt your coding style as good as possible. Let me know if there is something you'd still like to have changed to get this merged. :) |
My SizeTest.php seems to break the Unit Test system. I will either need to remove it or move it to another folder. Any preference from your side? |
Hi @didi1357, php-imap/src/Connection/Protocols/ImapProtocol.php Lines 698 to 703 in 46ef2a6
Looking at the git history, it always has been a while loop instead of an if. Since it behaves like an if Regarding the "Empty response" error: My current theory: Testing the If you want to dive in, checkout barbushin's amazing work: I hope I could answer your questions. Best regards & happy coding, Edit: |
How do we proceed with that? Do you implement that on master? Do I fix it on this branch? I'd suggest we go one by one => No fix on this branch. I'd even say it was my fault to tell you this within this issue. However I'd appreciate a decision of you.
Please take a look closer at my log. However, I'd also suggest to go one by one with this problem and leave that out of the scope of this PR.
Definitely. You need a working 24/7 IMAP server as test infrastructure to properly do this with a unit test. Also seems out of scope of this PR to me. To me the question is more about whether the file should be somewhere outside of the unit tests in this repository or just completely dropped. Both solutions are okay to me. I'd also just appreciate a decision of you about this. I'll unfortunately not have the time to implement a whole test infrastructure :S Best regards and especially: A BIG THANK YOU for your fast response. This is definitely not to be taken as granted for an open source project like this one! |
I don't expect a test case at all. I'm glad you took on the task to implement the method - I don't expect from you to do something I don't even have an idea of :) I managed to verify and fix my suspected search issue - so it looks like we were describing two different bugs. The exception "Empty response" isn't really descriptive and can certainly be improved. However similar to my fix (allowing the response to be empty (https://github.com/Webklex/php-imap/blob/master/src/Connection/Protocols/ImapProtocol.php#L1199)) there might be similar occasions were such a behavior is actually wanted. I'm not so sure if a 24/7 server is actually required. If I understand this correctly, you can "boot" a docker container as a step inside the github actions and keep it active during the unit test. Yes we are going all over the place inside this pr, but that's alright. If you want to fix something else or tackle a certain feature, I agree and recommend to create a separate issue / pr in order to give others a chance to join or discover it later on. Best regards, |
P.s.: regarding php-imap/src/Connection/Protocols/ImapProtocol.php Lines 698 to 703 in 46ef2a6
If you like to convert that |
Hey, I
Let me know if there is anything still to be done to get this merged. Br, Didi |
Hi @didi1357, One question regarding: https://github.com/didi1357/php-imap/blob/master/src/Message.php#L238 This will cause one additional request for every message to be fetched. How about moving the fetch logic to Something like this: case "size":
if (!isset($this->attributes[$name])) {
$this->fetchSize();
}
return $this->attributes[$name]; https://github.com/didi1357/php-imap/blob/master/src/Message.php#L609-L616 private function fetchSize(): void {
$sequence_id = $this->getSequenceId();
$sizes = $this->client->getConnection()->sizes([$sequence_id], $this->sequence)->validatedData();
if (!isset($sizes[$sequence_id])) {
throw new MessageSizeFetchingException("sizes did not set an array entry for the supplied sequence_id", 0);
}
$this->attributes["size"] = $sizes[$sequence_id];
} Doing so will spare the request and only fetch the size if its requested. This will probably save a couple of Btw: did you meant to include the local test case under examples? Best regards & happy coding, |
Hey, awesome. I didn't look deep enough into this logic, but this definitely makes sense. I'll implement accordingly. Yes. I moved it there, as all files in the tests folder seem to be run by the unit test system and unfortunately my test isn't compatible to that as it needs an IMAP server. |
Awesome, thank you :) |
Implemented as teased in Issue #378.
Relates to Issue #278.