View Issue Details

IDProjectCategoryView StatusLast Update
0000224Bacula-Webbug-phppublic2017-10-09 09:11
ReporterfwulfAssigned Todavide 
PrioritynoneSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version7.4.0 
Target Version8.0.0-rc1Fixed in Version8.0.0-rc1 
Summary0000224: PHP notice in client report for Windows clients
DescriptionHello Davide,

We backup Linux and Windows clients, Bacula version is 9.0.3. For the Windows machines the client report shows a PHP notice on top: "Notice: Undefined offset: 1 in /var/www/bacula-web/application/models/clients.model.php on line 81". Client information block looks like this:

Client name: cgefi0067-fd
Client version: 7.4.4
Client os:
Client arch: Microsoft

I checked the source code and the database values. What causes the issue is that the relevant information is stored a bit different in field "uname" of table "client" depending on whether client is running Linux or Windows. I was able to fix it on our system by adding a couple of lines to the clients.model.php script. Assuming it's ok I copy & paste it to this message, maybe it is helpful:

...
    public static function getClientInfos($pdo, $client_id)
    {
        $client = array();
        $fields = array('name','uname');
        $where = array( "clientid = $client_id" );
        $statment = CDBQuery::get_Select(array('table'=> 'Client', 'fields' => $fields, 'where' => $where ));

        $result = CDBUtils::runQuery($statment, $pdo);

        foreach ($result->fetchAll() as $client) {

            $uname = explode(',', $client['uname']); //new
            $is_win = end($uname); //new

            if ($is_win == "Win32" or $is_win == "Win64") { //new
                $client['arch'] = $uname[1]; //new
                $uname = explode(' ', $uname[0]); //new
                $client['version'] = $uname[0]; //new
                $uname = array_slice($uname, 2); //new
                $client['os'] = implode(' ', $uname); //new
            } else { //new
                $uname = explode(' ', $client['uname']);
                $client['version'] = $uname[0];
                $uname = explode(',', $uname[2]);
                $temp = explode('-', $uname[0]);
                $client['arch'] = $temp[0];
                $client['os'] = $uname[1];
            } //new
        }

        return $client;
    }
}

Thanks and best regards,
Frank

PS: And many thanks for creating/maintaining Bacula-Web.
TagsNo tags attached.

Activities

davide

2017-10-07 07:47

manager   ~0000687

Hi,
Can you send me the output of this query please ?
SELECT uname FROM Client WHERE Client.name = 'cgefi0067-fd';

Thanks for your feedback

P.S: I appreciate your feedback, hopefully you'll enjoy next release :)

fwulf

2017-10-07 11:38

reporter   ~0000691

Hi Davide,
Output is:

7.4.4 (28Sep16) Microsoft Windows 7 Enterprise Edition Service Pack 1 (build 7601), 64-bit,Cross-compile,Win64


Thanks and best regards,
Frank

davide

2017-10-09 09:09

manager   ~0000693

Fixed in commit 79ed8d2

davide

2017-10-09 09:11

manager   ~0000694

Hi,

This fix will be available in next version 8.0.0-RC1.
 
Thanks for your feedback

Davide

Issue History

Date Modified Username Field Change
2017-10-06 17:29 fwulf New Issue
2017-10-07 07:42 davide Target Version => 8.0.0-rc1
2017-10-07 07:42 davide Summary PHP notice "Undefined offset: 1 in ... clients.model.php on line 81" in client report for Windows clients => PHP notice in client report for Windows clients
2017-10-07 07:42 davide Description Updated View Revisions
2017-10-07 07:47 davide Assigned To => davide
2017-10-07 07:47 davide Status new => feedback
2017-10-07 07:47 davide Note Added: 0000687
2017-10-07 11:38 fwulf Note Added: 0000691
2017-10-07 11:38 fwulf Status feedback => assigned
2017-10-09 09:09 davide Note Added: 0000693
2017-10-09 09:11 davide Status assigned => resolved
2017-10-09 09:11 davide Resolution open => fixed
2017-10-09 09:11 davide Fixed in Version => 8.0.0-rc1
2017-10-09 09:11 davide Note Added: 0000694