Skip to content
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

Undefined variable section in Message class #5

Open
Gizmo091 opened this issue Aug 9, 2022 · 2 comments
Open

Undefined variable section in Message class #5

Gizmo091 opened this issue Aug 9, 2022 · 2 comments
Assignees
Milestone

Comments

@Gizmo091
Copy link

Gizmo091 commented Aug 9, 2022

Q A
javanile/php-imap2 version 0.1.7
PHP version 7.4.3
IMAP provider imap.gmail.com

Summary

Trying to use imap2_bodystruct, the function throw a notice for an undefined variable called section.

Current behavior

A call to imap2_bodystruct function trigger an "undefined variable" notice.

Notice: Undefined variable: section in .../vendor/javanile/php-imap2/src/Message.php on line 186

Indeed, the $section variable is never declared or instantiated.

 public static function bodyStruct($imap, $messageNum, $flags = 0)
    {
        if (is_a($imap, Connection::class)) {
            $client = $imap->getClient();
            #$client->setDebug(true);

            $messages = $client->fetch($imap->getMailboxName(), $messageNum, false, ['BODY['.$section.']']);

            if ($section) {
                return $messages[$messageNum]->bodypart[$section];
            }

            return $messages[$messageNum]->body;
        }

        return imap_fetchstructure($imap, $messageNum, $flags);
    }
@francescobianco
Copy link
Member

Hi @Gizmo091 , could you please test our new version https://github.com/javanile/php-imap2/releases/tag/0.1.9

@tnaumann-wecg
Copy link

Hi @francescobianco, I can confirm that this bug still exists in v0.1.10.
Like @Gizmo091 already noted, the variable $section is never initialized in the bodyStruct function. The Section is actually passed as $flag argument (which is unused in this function): https://github.com/javanile/php-imap2/blob/0.1.10/bootstrap.php#L945

@cjwnz cjwnz mentioned this issue Mar 23, 2023
kosta90s referenced this issue in arbor-education/php-imap2 Oct 30, 2023
from dicode-nl/php-imap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants