Skip to content

Children/subfolders is empty but hasChildren is true #453

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

Closed
netkant opened this issue Nov 18, 2023 · 2 comments
Closed

Children/subfolders is empty but hasChildren is true #453

netkant opened this issue Nov 18, 2023 · 2 comments

Comments

@netkant
Copy link

netkant commented Nov 18, 2023

Describe the bug
$folder->getChildren()->total() is 0

Used config
See code to reproduce (maybe I'm doing something wrong?)

Code to Reproduce
The troubling code section which produces the reported bug.

$cm = new ClientManager([
    'accounts' => [
        'myaccount' => [
            'host'       => 'myhost.com',
            'port'       => 993,
            'protocol'   => 'imap',
            'encryption' => 'ssl',
            'username'   => 'myusername',
            'password'   => 'mypassword',
        ]
    ]
]);

$client = $cm->account('myaccount');
$folder = $client->getFolder('TestFolder');
var_dump($folder->hasChildren()); // bool(true)
var_dump($folder->getChildren()->total()); // int(0) <-- bug?

Expected behavior
In my case I expect var_dump($folder->getChildren()->total()); to be int(1)

Desktop / Server (please complete the following information):

  • OS: Linux Server Debian
  • PHP: 8.2.10 (fpm)
  • Provider: Gmail / Mailcow
@netkant
Copy link
Author

netkant commented Nov 18, 2023

Hello again,

After looking into the source code, I realize why the expected results is "wrong".

The $client->getFolder(...) method calls getFolders(false, ...)

so I managed to make a "workaround" to get what I need like this:

$folders = $client->getFolders(true, 'TestFolder');
$folder  = $folders->first();
var_dump($folder->getChildren()->all());

Resulting in:

array(1) {
  [0]=>
  object(Webklex\PHPIMAP\Folder)#860 (12) {
  ...

But although I now managed to get a list of subfolders and var_dump($folder->getChildren()); gives me this:

object(Webklex\PHPIMAP\Support\FolderCollection)#918 (3) {
  ["items":protected]=>
  array(1) {
    [0]=>
    object(Webklex\PHPIMAP\Folder)#919 (12) {

The var_dump($folder->getChildren()->total()); still gives me:

int(0)

@Webklex
Copy link
Owner

Webklex commented Jan 17, 2025

Hi @netkant ,
many thanks for your report. I'm fairly certain the issue has been fixed within the last release. Please update to the latest release and try again. If the issue still persists, please reopen this issue :)

Best regards & happy coding,

@Webklex Webklex closed this as completed Jan 17, 2025
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

No branches or pull requests

2 participants