Completed
Branch master (9dda00)
by Michael
04:54 queued 02:33
created

NewbbOnlineHandler::render()   C

Complexity

Conditions 10
Paths 108

Size

Total Lines 55
Code Lines 43

Duplication

Lines 23
Ratio 41.82 %

Importance

Changes 0
Metric Value
cc 10
eloc 43
nc 108
nop 1
dl 23
loc 55
rs 6.6222
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 21 and the first side effect is on line 16.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * NewBB 5.0x,  the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (http://xoops.org)
6
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
7
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
8
 * @since          4.00
9
 * @package        module::newbb
10
 */
11
12
use Xmf\IPAddress;
13
14
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
15
16
include_once __DIR__ . '/../include/functions.config.php';
17
18
/**
19
 * Class NewbbOnlineHandler
20
 */
21
class NewbbOnlineHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
22
{
23
    public $db;
24
    public $forum_id;
25
    public $forumObject;
26
    public $topic_id;
27
    public $user_ids = [];
28
29
    /**
30
     * @param null|\NewbbForum $forum
31
     * @param null|Topic       $forumtopic
32
     */
33
    public function init($forum = null, $forumtopic = null)
0 ignored issues
show
Coding Style introduced by
init uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
34
    {
35
        //$this->db = XoopsDatabaseFactory::getDatabaseConnection();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
36
        $this->db = $GLOBALS['xoopsDB'];
37 View Code Duplication
        if (is_object($forum)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
            $this->forum_id     = $forum->getVar('forum_id');
39
            $this->forumObject = $forum;
40
        } else {
41
            $this->forum_id     = (int)$forum;
42
            $this->forumObject = $forum;
43
        }
44 View Code Duplication
        if (is_object($forumtopic)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
            $this->topic_id = $forumtopic->getVar('topic_id');
46
            if (empty($this->forum_id)) {
47
                $this->forum_id = $forumtopic->getVar('forum_id');
48
            }
49
        } else {
50
            $this->topic_id = (int)$forumtopic;
51
        }
52
53
        $this->update();
54
    }
55
56
    public function update()
0 ignored issues
show
Coding Style introduced by
update uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
57
    {
58
        global $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
59
60
        mt_srand((double)microtime() * 1000000);
61
        // set gc probabillity to 10% for now..
62
        if (mt_rand(1, 100) < 60) {
63
            $this->gc(150);
64
        }
65
        if (is_object($GLOBALS['xoopsUser'])) {
66
            $uid   = $GLOBALS['xoopsUser']->getVar('uid');
67
            $uname = $GLOBALS['xoopsUser']->getVar('uname');
68
            $name  = $GLOBALS['xoopsUser']->getVar('name');
69
        } else {
70
            $uid   = 0;
71
            $uname = '';
72
            $name  = '';
73
        }
74
75
        $xoops_onlineHandler = xoops_getHandler('online');
76
        $xoopsupdate         = $xoops_onlineHandler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), Xmf\IPAddress::fromRequest()->asReadable());
77
        if (!$xoopsupdate) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
78
            //xoops_error("newbb online upate error");
79
        }
80
81
        $uname = (empty($GLOBALS['xoopsModuleConfig']['show_realname']) || empty($name)) ? $uname : $name;
82
        $this->write($uid, $uname, time(), $this->forum_id, IPAddress::fromRequest()->asReadable(), $this->topic_id);
83
    }
84
85
    /**
86
     * @param $xoopsTpl
87
     */
88
    public function render(Smarty $xoopsTpl)
89
    {
90
        include_once __DIR__ . '/../include/functions.render.php';
91
        include_once __DIR__ . '/../include/functions.user.php';
92
        $criteria = null;
93 View Code Duplication
        if ($this->topic_id) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
            $criteria = new Criteria('online_topic', $this->topic_id);
95
        } elseif ($this->forum_id) {
96
            $criteria = new Criteria('online_forum', $this->forum_id);
97
        }
98
        $users     = $this->getAll($criteria);
99
        $num_total = count($users);
100
101
        $num_user     = 0;
102
        $users_id     = [];
103
        $users_online = [];
104 View Code Duplication
        for ($i = 0; $i < $num_total; ++$i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
105
            if (empty($users[$i]['online_uid'])) {
106
                continue;
107
            }
108
            $users_id[]                             = $users[$i]['online_uid'];
109
            $users_online[$users[$i]['online_uid']] = [
110
                'link'  => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'],
111
                'uname' => $users[$i]['online_uname']
112
            ];
113
            ++$num_user;
114
        }
115
        $num_anonymous           = $num_total - $num_user;
116
        $online                  = [];
117
        $online['image']         = newbbDisplayImage('whosonline');
118
        $online['num_total']     = $num_total;
119
        $online['num_user']      = $num_user;
120
        $online['num_anonymous'] = $num_anonymous;
121
        $administrator_list      = newbbIsModuleAdministrators($users_id);
122
        $moderator_list          = [];
123 View Code Duplication
        if ($member_list = array_diff(array_keys($administrator_list), $users_id)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
124
            if (is_object($this->forumObject)) {
125
                $moderator_list = $this->forumObject->getVar('forum_moderator');
126
            } else {
127
                $moderator_list = newbbIsForumModerators($member_list);
128
            }
129
        }
130
        foreach ($users_online as $uid => $user) {
131
            if (!empty($administrator_list[$uid])) {
132
                $user['level'] = 2;
133
            } elseif (!empty($moderator_list[$uid])) {
134
                $user['level'] = 1;
135
            } else {
136
                $user['level'] = 0;
137
            }
138
            $online['users'][] = $user;
139
        }
140
141
        $xoopsTpl->assign_by_ref('online', $online);
142
    }
143
144
    /**
145
     * Deprecated
146
     */
147
    public function showOnline()
148
    {
149
        include_once __DIR__ . '/../include/functions.render.php';
150
        include_once __DIR__ . '/../include/functions.user.php';
151
        $criteria = null;
152 View Code Duplication
        if ($this->topic_id) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
153
            $criteria = new Criteria('online_topic', $this->topic_id);
154
        } elseif ($this->forum_id) {
155
            $criteria = new Criteria('online_forum', $this->forum_id);
156
        }
157
        $users     = $this->getAll($criteria);
158
        $num_total = count($users);
159
160
        $num_user     = 0;
161
        $users_id     = [];
162
        $users_online = [];
163 View Code Duplication
        for ($i = 0; $i < $num_total; ++$i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
164
            if (empty($users[$i]['online_uid'])) {
165
                continue;
166
            }
167
            $users_id[]                             = $users[$i]['online_uid'];
168
            $users_online[$users[$i]['online_uid']] = [
169
                'link'  => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'],
170
                'uname' => $users[$i]['online_uname']
171
            ];
172
            ++$num_user;
173
        }
174
        $num_anonymous           = $num_total - $num_user;
175
        $online                  = [];
176
        $online['image']         = newbbDisplayImage('whosonline');
177
        $online['statistik']     = newbbDisplayImage('statistik');
178
        $online['num_total']     = $num_total;
179
        $online['num_user']      = $num_user;
180
        $online['num_anonymous'] = $num_anonymous;
181
        $administrator_list      = newbbIsModuleAdministrators($users_id);
182
        $moderator_list          = [];
183 View Code Duplication
        if ($member_list = array_diff($users_id, array_keys($administrator_list))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
184
            if (is_object($this->forumObject)) {
185
                $moderator_list = $this->forumObject->getVar('forum_moderator');
186
            } else {
187
                $moderator_list = newbbIsForumModerators($member_list);
188
            }
189
        }
190
191
        foreach ($users_online as $uid => $user) {
192
            if (in_array($uid, $administrator_list)) {
193
                $user['level'] = 2;
194
            } elseif (in_array($uid, $moderator_list)) {
195
                $user['level'] = 1;
196
            } else {
197
                $user['level'] = 0;
198
            }
199
            $online['users'][] = $user;
200
        }
201
202
        return $online;
203
    }
204
205
    /**
206
     * Write online information to the database
207
     *
208
     * @param  int    $uid      UID of the active user
209
     * @param  string $uname    Username
210
     * @param         $time
211
     * @param  string $forum_id Current forum_id
212
     * @param  string $ip       User's IP adress
213
     * @param         $topic_id
214
     * @return bool   TRUE on success
215
     * @internal param string $timestamp
216
     */
217
    public function write($uid, $uname, $time, $forum_id, $ip, $topic_id)
218
    {
219
        global $xoopsModule, $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
220
221
        $uid = (int)$uid;
222
        if ($uid > 0) {
223
            $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid;
224
        } else {
225
            $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid . " AND online_ip='" . $ip . "'";
226
        }
227
        list($count) = $this->db->fetchRow($this->db->queryF($sql));
228
        if ($count > 0) {
229
            $sql = 'UPDATE ' . $this->db->prefix('newbb_online') . " SET online_updated= '" . $time . "', online_forum = '" . $forum_id . "', online_topic = '" . $topic_id . "' WHERE online_uid = " . $uid;
230
            if ($uid == 0) {
231
                $sql .= " AND online_ip='" . $ip . "'";
232
            }
233
        } else {
234
            $sql = sprintf('INSERT INTO %s (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id);
235
        }
236
        if (!$this->db->queryF($sql)) {
237
            //xoops_error($this->db->error());
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
238
            return false;
239
        }
240
241
        /** @var XoopsOnlineHandler $xoops_onlineHandler */
242
        $xoops_onlineHandler = xoops_getHandler('online');
243
        $xoopsOnlineTable    = $xoops_onlineHandler->table;
244
245
        $sql = 'DELETE FROM '
246
               . $this->db->prefix('newbb_online')
247
               . ' WHERE'
248
               . ' ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM '
249
               . $xoopsOnlineTable
250
               . ' WHERE online_module ='
251
               . $xoopsModule->getVar('mid')
252
               . ' ) )'
253
               . ' OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM '
254
               . $xoopsOnlineTable
255
               . ' WHERE online_module ='
256
               . $xoopsModule->getVar('mid')
257
               . ' AND online_uid = 0 ) )';
258
259
        if ($result = $this->db->queryF($sql)) {
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
260
            return true;
261
        } else {
262
            //xoops_error($this->db->error());
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
263
            return false;
264
        }
265
    }
266
267
    /**
268
     * Garbage Collection
269
     *
270
     * Delete all online information that has not been updated for a certain time
271
     *
272
     * @param int $expire Expiration time in seconds
273
     */
274
    public function gc($expire)
275
    {
276
        global $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
277
        $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (time() - (int)$expire);
278
        $this->db->queryF($sql);
279
280
        $xoops_onlineHandler = xoops_getHandler('online');
281
        $xoops_onlineHandler->gc($expire);
282
    }
283
284
    /**
285
     * Get an array of online information
286
     *
287
     * @param  CriteriaElement $criteria {@link CriteriaElement}
0 ignored issues
show
Documentation introduced by
Should the type for parameter $criteria not be null|CriteriaElement?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
288
     * @return array           Array of associative arrays of online information
289
     */
290
    public function getAll(CriteriaElement $criteria = null)
291
    {
292
        $ret   = [];
293
        $limit = $start = 0;
294
        $sql   = 'SELECT * FROM ' . $this->db->prefix('newbb_online');
295
        if (is_object($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of returns inconsistent results on some PHP versions for interfaces; you could instead use ReflectionClass::implementsInterface.
Loading history...
296
            $sql   .= ' ' . $criteria->renderWhere();
297
            $limit = $criteria->getLimit();
298
            $start = $criteria->getStart();
299
        }
300
        $result = $this->db->query($sql, $limit, $start);
301
        if (!$result) {
302
            return $ret;
303
        }
304
        while ($myrow = $this->db->fetchArray($result)) {
305
            $ret[] = $myrow;
306
            if ($myrow['online_uid'] > 0) {
307
                $this->user_ids[] = $myrow['online_uid'];
308
            }
309
            unset($myrow);
310
        }
311
        $this->user_ids = array_unique($this->user_ids);
312
313
        return $ret;
314
    }
315
316
    /**
317
     * @param $uids
318
     * @return array
319
     */
320
    public function checkStatus($uids)
321
    {
322
        $online_users = [];
323
        $ret          = [];
324
        if (!empty($this->user_ids)) {
325
            $online_users = $this->user_ids;
326
        } else {
327
            $sql = 'SELECT online_uid FROM ' . $this->db->prefix('newbb_online');
328
            if (!empty($uids)) {
329
                $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('intval', $uids)) . ')';
330
            }
331
332
            $result = $this->db->query($sql);
333
            if (!$result) {
334
                return $ret;
335
            }
336
            while (list($uid) = $this->db->fetchRow($result)) {
337
                $online_users[] = $uid;
338
            }
339
        }
340
        foreach ($uids as $uid) {
341
            if (in_array($uid, $online_users)) {
342
                $ret[$uid] = 1;
343
            }
344
        }
345
346
        return $ret;
347
    }
348
349
    /**
350
     * Count the number of online users
351
     *
352
     * @param  CriteriaElement $criteria {@link CriteriaElement}
0 ignored issues
show
Documentation introduced by
Should the type for parameter $criteria not be null|CriteriaElement?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
353
     * @return bool
354
     */
355
    public function getCount(CriteriaElement $criteria = null)
356
    {
357
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online');
358
        if (is_object($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of returns inconsistent results on some PHP versions for interfaces; you could instead use ReflectionClass::implementsInterface.
Loading history...
359
            $sql .= ' ' . $criteria->renderWhere();
360
        }
361
        if (!$result = $this->db->query($sql)) {
362
            return false;
363
        }
364
        list($ret) = $this->db->fetchRow($result);
365
366
        return $ret;
367
    }
368
}
369