Issues (1964)

html/user/submit_status.php (2 issues)

Labels
Severity
1
<?php
2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2011 University of California
5
//
6
// BOINC is free software; you can redistribute it and/or modify it
7
// under the terms of the GNU Lesser General Public License
8
// as published by the Free Software Foundation,
9
// either version 3 of the License, or (at your option) any later version.
10
//
11
// BOINC is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
// See the GNU Lesser General Public License for more details.
15
//
16
// You should have received a copy of the GNU Lesser General Public License
17
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
19
// web interfaces for viewing and controlling batches
20
// DEPRECATED: replaced by submit.php
21
22
require_once("../inc/util.inc");
23
require_once("../inc/boinc_db.inc");
24
require_once("../inc/result.inc");
25
require_once("../inc/submit_db.inc");
26
27
function show_batch($user) {
28
    $batch_id = get_int('batch_id');
29
    $batch = BoincBatch::lookup_id($batch_id);
30
    if (!$batch || $batch->user_id != $user->id) {
31
        error_page("no batch");
32
    }
33
    page_head("Batch $batch->id");
34
    $results = BoincResult::enum("batch=$batch->id order by workunitid");
35
    result_table_start(true, true, null);
36
    foreach ($results as $result) {
37
        show_result_row($result, true, true, true);
38
    }
39
    end_table();
40
    page_tail();
41
}
42
43
function show_batches($user) {
44
    $batches = BoincBatch::enum("user_id=$user->id");
45
    page_head("Batches");
46
    start_table();
47
    table_header("Batch ID", "Submitted", "# jobs");
48
    foreach ($batches as $batch) {
49
        echo "<tr>
50
            <td><a href=submit_status.php?action=show_batch&batch_id=$batch->id>$batch->id</a></td>
51
            <td>".time_str($batch->create_time)."</td>
52
            <td>$batch->njobs</td>
53
            </tr>
54
        ";
55
    }
56
    end_table();
57
    page_tail();
58
}
59
60
$user = get_logged_in_user();
0 ignored issues
show
Are you sure the assignment to $user is correct as get_logged_in_user() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
61
62
$action = get_str('action', true);
63
switch ($action) {
64
case '': show_batches($user); break;
0 ignored issues
show
The call to show_batches() has too few arguments starting with limit. ( Ignorable by Annotation )

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

64
case '': /** @scrutinizer ignore-call */ show_batches($user); break;

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
65
case 'show_batch': show_batch($user);
66
}
67
?>
68