SMTP email give compact() Undefined variable: etagMatches & timeMatches error on cakephp 3

25 Views Asked by At

I'm having problem when trying to send SMTP mail via cakephp3 with php 7.4

Notice: Notice (8): compact() [<a href='http://php.net/function.compact'>function.compact</a>]: Undefined variable: etagMatches in [/home/vendor/cakephp/cakephp/src/Network/Response.php, line 1281]

The function look like this:

 public function checkNotModified(Request $request)
    {
        $etags = preg_split('/\s*,\s*/', $request->header('If-None-Match'), null, PREG_SPLIT_NO_EMPTY);
        $modifiedSince = $request->header('If-Modified-Since');
        if ($responseTag = $this->etag()) {
            $etagMatches = in_array('*', $etags) || in_array($responseTag, $etags);
        }
        if ($modifiedSince) {
            $timeMatches = strtotime($this->modified()) === strtotime($modifiedSince);
        }
        $checks = compact('etagMatches', 'timeMatches');
        if (empty($checks)) {
            return false;
        }
        $notModified = !in_array(false, $checks, true);
        if ($notModified) {
            $this->notModified();
        }

        return $notModified;
    }

Is there any solution? (it was working fine before I don't know what changed)

0

There are 0 best solutions below