yiisoft / yii2-debug

Debug Extension for Yii 2
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
202 stars 149 forks source link

Mailpanel should store message in request data #497

Open SamMousa opened 1 year ago

SamMousa commented 1 year ago

The mailpanel currently writes message files directly to the file storage. It then only stores the filename in the request data as part of its return value to save().

This breaks containment as the LogTarget now has to reach into the data from save() to find a key it does not own for proper cleanup of mail files:

if (isset($manifest[$tag]['mailFiles'])) {
    foreach ($manifest[$tag]['mailFiles'] as $mailFile) {
        @unlink(Yii::getAlias($this->module->panels['mail']->mailPath) . "/$mailFile");
    }
}

I propose we store the actual mail data in the structure saved by the LogTarget. This also makes it easier to replace the log target with another implementation like the one in #489 or #495.

Performance wise it shouldn't matter since both are still written to disk and reading from disk isn't that expensive. The (negligible) performance loss would occur when viewing a specific debug entry while not on the mail panel (it would load the full mail data but not use it).

samdark commented 1 year ago

Good idea.