Completed
Push — svgpagetools ( d7814e...a24eaf )
by Andreas
05:51
created

Draftdel::minimumPermission()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki\Action;
4
5
use dokuwiki\Action\Exception\ActionAbort;
6
7
/**
8
 * Class Draftdel
9
 *
10
 * Delete a draft
11
 *
12
 * @package dokuwiki\Action
13
 */
14
class Draftdel extends AbstractAction {
15
16
    /** @inheritdoc */
17
    public function minimumPermission() {
18
        return AUTH_EDIT;
19
    }
20
21
    /**
22
     * Delete an existing draft if any
23
     *
24
     * Reads draft information from $INFO. Redirects to show, afterwards.
25
     *
26
     * @throws ActionAbort
27
     */
28
    public function preProcess() {
29
        global $INFO;
30
        @unlink($INFO['draft']);
1 ignored issue
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
31
        $INFO['draft'] = null;
32
33
        throw new ActionAbort('redirect');
34
    }
35
36
}
37