Issues (2160)

main/link/link_goto.php (2 issues)

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
/**
5
 * This page is used to launch an event when a user clicks
6
 * on a page linked in a course.
7
 * - It gets name of URL
8
 * - It calls the event function
9
 * - It redirects the user to the linked page.
10
 *
11
 * Need the liens.id, user.user_id et cours.code when called
12
 * ?link_id=$myrow[0]&link_url=$myrow[1]
13
 * url is given to avoid a new select
14
 *
15
 * @author Thomas Depraetere, Hugues Peeters, Christophe Gesch� - original versions
16
 */
17
require_once __DIR__.'/../inc/global.inc.php';
18
$this_section = SECTION_COURSES;
19
20
$linkId = isset($_GET['link_id']) ? $_GET['link_id'] : 0;
21
22
$linkInfo = Link::getLinkInfo($linkId);
23
if ($linkInfo) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $linkInfo of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
24
    $linkUrl = html_entity_decode(Security::remove_XSS($linkInfo['url']));
25
    // Launch event
26
    Event::event_link($linkId);
0 ignored issues
show
The method event_link() does not exist on Event. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
    Event::/** @scrutinizer ignore-call */ 
27
           event_link($linkId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
28
    header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
29
    header("Cache-Control: post-check=0, pre-check=0", false);
30
    header("Pragma: no-cache"); // HTTP/1.0
31
    header("Location: $linkUrl");
32
    exit;
33
}
34