MediaSubscriptionSender::sendMediaDiff()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 4
nop 5
dl 0
loc 26
rs 9.1928
c 0
b 0
f 0
1
<?php
2
3
4
namespace dokuwiki\Subscriptions;
5
6
7
class MediaSubscriptionSender extends SubscriptionSender
8
{
9
10
    /**
11
     * Send the diff for some media change
12
     *
13
     * @fixme this should embed thumbnails of images in HTML version
14
     *
15
     * @param string   $subscriber_mail The target mail address
16
     * @param string   $template        Mail template ('uploadmail', ...)
17
     * @param string   $id              Media file for which the notification is
18
     * @param int|bool $rev             Old revision if any
19
     * @param int|bool $current_rev     New revision if any
20
     */
21
    public function sendMediaDiff($subscriber_mail, $template, $id, $rev = false, $current_rev = false)
22
    {
23
        global $conf;
24
25
        $file = mediaFN($id);
26
        list($mime, /* $ext */) = mimetype($id);
27
28
        $trep = [
29
            'MIME' => $mime,
30
            'MEDIA' => ml($id, $current_rev?('rev='.$current_rev):'', true, '&', true),
31
            'SIZE' => filesize_h(filesize($file)),
32
        ];
33
34
        if ($rev && $conf['mediarevisions']) {
35
            $trep['OLD'] = ml($id, "rev=$rev", true, '&', true);
36
        } else {
37
            $trep['OLD'] = '---';
38
        }
39
40
        $headers = ['Message-Id' => $this->getMessageID($id, @filemtime($file))];
41
        if ($rev) {
42
            $headers['In-Reply-To'] = $this->getMessageID($id, $rev);
0 ignored issues
show
Documentation introduced by
$rev is of type integer|boolean, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
        }
44
45
        $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers);
46
    }
47
}
48