Completed
Pull Request — master (#26)
by Richard
02:24
created

NewbbReadHandler::clearDuplicate()   B

Complexity

Conditions 8
Paths 9

Size

Total Lines 54
Code Lines 31

Duplication

Lines 30
Ratio 55.56 %

Importance

Changes 0
Metric Value
cc 8
eloc 31
nc 9
nop 0
dl 30
loc 54
rs 7.4119
c 0
b 0
f 0

How to fix   Long Method   

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 44 and the first side effect is on line 34.

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
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                  Copyright (c) 2000-2016 XOOPS.org                        //
6
//                       <https://xoops.org/>                             //
7
//  ------------------------------------------------------------------------ //
8
//  This program is free software; you can redistribute it and/or modify     //
9
//  it under the terms of the GNU General Public License as published by     //
10
//  the Free Software Foundation; either version 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
//  Author: phppp (D.J., [email protected])                                  //
28
//  URL: https://xoops.org                                                    //
29
//  Project: Article Project                                                 //
30
//  ------------------------------------------------------------------------ //
31
32
// defined('XOOPS_ROOT_PATH') || exit('Restricted access.');
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...
33
34
defined('NEWBB_FUNCTIONS_INI') || include $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
35
36
/**
37
 * A handler for read/unread handling
38
 *
39
 * @package       newbb
40
 *
41
 * @author        D.J. (phppp, http://xoopsforge.com)
42
 * @copyright     copyright (c) 2005 XOOPS.org
43
 */
44
class Read extends XoopsObject
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...
45
{
46
    /**
47
     * @internal param $type
48
     */
49
    public function __construct()
50
    {
51
        // parent::__construct("newbb_reads_" . $type);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
52
        parent::__construct();
53
        $this->initVar('read_id', XOBJ_DTYPE_INT);
54
        $this->initVar('uid', XOBJ_DTYPE_INT);
55
        $this->initVar('read_item', XOBJ_DTYPE_INT);
56
        $this->initVar('post_id', XOBJ_DTYPE_INT);
57
        $this->initVar('read_time', XOBJ_DTYPE_INT);
58
    }
59
}
60
61
/**
62
 * Class NewbbReadHandler
63
 */
64
class NewbbReadHandler extends XoopsPersistableObjectHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
65
{
66
    /**
67
     * Object type.
68
     * <ul>
69
     *  <li>forum</li>
70
     *  <li>topic</li>
71
     * </ul>
72
     *
73
     * @var string
74
     */
75
    public $type;
76
77
    /**
78
     * seconds records will persist.
79
     * assigned from $GLOBALS['xoopsModuleConfig']["read_expire"]
80
     * <ul>
81
     *  <li>positive days = delete all read records exist in the tables before expire time // irmtfan add comment</li>
82
     *  <li>0 = never expires // irmtfan change comment</li>
83
     *  <li>-1 or any negative days = never records // irmtfan change comment</li>
84
     * </ul>
85
     *
86
     * @var integer
87
     */
88
    public $lifetime;
89
90
    /**
91
     * storage mode for records.
92
     * assigned from $GLOBALS['xoopsModuleConfig']["read_mode"]
93
     * <ul>
94
     *  <li>0 = never records</li>
95
     *  <li>1 = uses cookie</li>
96
     *  <li>2 = stores in database</li>
97
     * </ul>
98
     *
99
     * @var integer
100
     */
101
    public $mode;
102
103
    /**
104
     * @param XoopsDatabase|null $db
105
     * @param                    $type
106
     */
107
    public function __construct(XoopsDatabase $db, $type)
108
    {
109
        $type = ('forum' === $type) ? 'forum' : 'topic';
110
        parent::__construct($db, 'newbb_reads_' . $type, 'Read' . $type, 'read_id', 'post_id');
111
        $this->type  = $type;
112
        $newbbConfig = newbbLoadConfig();
113
        // irmtfan if read_expire = 0 dont clean
114
        $this->lifetime = isset($newbbConfig['read_expire']) ? (int)$newbbConfig['read_expire'] * 24 * 3600 : 30 * 24 * 3600;
115
        $this->mode     = isset($newbbConfig['read_mode']) ? $newbbConfig['read_mode'] : 2;
116
    }
117
118
    /**
119
     * Clear garbage
120
     *
121
     * Delete all expired and duplicated records
122
     */
123
    // START irmtfan rephrase function to 1- add clearDuplicate and 2- dont clean when read_expire = 0
124
    public function clearGarbage()
125
    {
126
        // irmtfan clear duplicaed rows
127
        if (!$result = $this->clearDuplicate()) {
128
            return false;
129
        }
130
131
        $sql = 'DELETE bb FROM ' . $this->table . ' AS bb' . ' LEFT JOIN ' . $this->table . ' AS aa ON bb.read_item = aa.read_item ' . ' WHERE aa.post_id > bb.post_id';
132
        if (!$result = $this->db->queryF($sql)) {
133
            //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...
134
            return false;
135
        }
136
        // irmtfan if read_expire = 0 dont clean
137
        if (empty($this->lifetime)) {
138
            return true;
139
        }
140
        // irmtfan move here and rephrase
141
        $expire = time() - (int)$this->lifetime;
142
        $sql    = 'DELETE FROM ' . $this->table . ' WHERE read_time < ' . $expire;
143
        if (!$result = $this->db->queryF($sql)) {
144
            //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...
145
            return false;
146
        }
147
148
        return true;
149
    }
150
151
    // END irmtfan rephrase function to 1- add clearDuplicate and 2- dont clean when read_expire = 0
152
153
    /**
154
     * @param                  $read_item
155
     * @param  null            $uid
156
     * @return bool|mixed|null
157
     */
158
    public function getRead($read_item, $uid = null)
159
    {
160
        if (empty($this->mode)) {
161
            return null;
162
        }
163
        if (1 == $this->mode) {
164
            return $this->getReadCookie($read_item);
165
        } else {
166
            return $this->getReadDb($read_item, $uid);
167
        }
168
    }
169
170
    /**
171
     * @param $item_id
172
     * @return mixed
173
     */
174
    public function getReadCookie($item_id)
175
    {
176
        $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT';
177
        $cookie_var  = $item_id;
178
        // irmtfan set true to return array
179
        $lastview = newbbGetCookie($cookie_name, true);
180
181
        return @$lastview[$cookie_var];
182
    }
183
184
    /**
185
     * @param $read_item
186
     * @param $uid
187
     * @return bool|null
188
     */
189
    public function getReadDb($read_item, $uid)
0 ignored issues
show
Coding Style introduced by
getReadDb 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...
190
    {
191 View Code Duplication
        if (empty($uid)) {
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...
192
            if (is_object($GLOBALS['xoopsUser'])) {
193
                $uid = $GLOBALS['xoopsUser']->getVar('uid');
194
            } else {
195
                return false;
196
            }
197
        }
198
        $sql = 'SELECT post_id ' . ' FROM ' . $this->table . ' WHERE read_item = ' . (int)$read_item . '     AND uid = ' . (int)$uid;
199
        if (!$result = $this->db->queryF($sql, 1)) {
200
            return null;
201
        }
202
        list($post_id) = $this->db->fetchRow($result);
203
204
        return $post_id;
205
    }
206
207
    /**
208
     * @param                  $read_item
209
     * @param                  $post_id
210
     * @param  null            $uid
211
     * @return bool|mixed|void
212
     */
213
    public function setRead($read_item, $post_id, $uid = null)
214
    {
215
        if (empty($this->mode)) {
216
            return true;
217
        }
218
        if (1 == $this->mode) {
219
            return $this->setReadCookie($read_item, $post_id);
220
        } else {
221
            return $this->setReadDb($read_item, $post_id, $uid);
222
        }
223
    }
224
225
    /**
226
     * @param $read_item
227
     * @param $post_id
228
     */
229
    public function setReadCookie($read_item, $post_id)
230
    {
231
        $cookie_name          = ('forum' === $this->type) ? 'LF' : 'LT';
232
        $lastview             = newbbGetCookie($cookie_name, true);
233
        $lastview[$read_item] = time();
234
        newbbSetCookie($cookie_name, $lastview);
0 ignored issues
show
Documentation introduced by
$lastview is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
235
    }
236
237
    /**
238
     * @param $read_item
239
     * @param $post_id
240
     * @param $uid
241
     * @return bool|mixed
242
     */
243
    public function setReadDb($read_item, $post_id, $uid)
0 ignored issues
show
Coding Style introduced by
setReadDb 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...
244
    {
245 View Code Duplication
        if (empty($uid)) {
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...
246
            if (is_object($GLOBALS['xoopsUser'])) {
247
                $uid = $GLOBALS['xoopsUser']->getVar('uid');
248
            } else {
249
                return false;
250
            }
251
        }
252
253
        $sql = 'UPDATE ' . $this->table . ' SET post_id = ' . (int)$post_id . ',' . '     read_time =' . time() . ' WHERE read_item = ' . (int)$read_item . '     AND uid = ' . (int)$uid;
254
        if ($this->db->queryF($sql) && $this->db->getAffectedRows()) {
255
            return true;
256
        }
257
        $object = $this->create();
258
        $object->setVar('read_item', $read_item);
259
        $object->setVar('post_id', $post_id);
260
        $object->setVar('uid', $uid);
261
        $object->setVar('read_time', time());
262
263
        return parent::insert($object);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (insert() instead of setReadDb()). Are you sure this is correct? If so, you might want to change this to $this->insert().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
264
    }
265
266
    /**
267
     * @param             $items
268
     * @param  null       $uid
269
     * @return array|null
270
     */
271
    public function isReadItems(&$items, $uid = null)
272
    {
273
        $ret = null;
274
        if (empty($this->mode)) {
275
            return $ret;
276
        }
277
278
        if (1 == $this->mode) {
279
            $ret = $this->isReadItemsCookie($items);
280
        } else {
281
            $ret = $this->isReadItemsDb($items, $uid);
282
        }
283
284
        return $ret;
285
    }
286
287
    /**
288
     * @param $items
289
     * @return array
290
     */
291
    public function isReadItemsCookie(&$items)
0 ignored issues
show
Coding Style introduced by
isReadItemsCookie 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...
292
    {
293
        $cookie_name = ('forum' === $this->type) ? 'LF' : 'LT';
294
        $cookie_vars = newbbGetCookie($cookie_name, true);
295
296
        $ret = [];
297
        foreach ($items as $key => $last_update) {
298
            $ret[$key] = (max(@$GLOBALS['last_visit'], @$cookie_vars[$key]) >= $last_update);
299
        }
300
301
        return $ret;
302
    }
303
304
    /**
305
     * @param $items
306
     * @param $uid
307
     * @return array
308
     */
309
    public function isReadItemsDb(&$items, $uid)
0 ignored issues
show
Coding Style introduced by
isReadItemsDb 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...
310
    {
311
        $ret = [];
312
        if (empty($items)) {
313
            return $ret;
314
        }
315
316 View Code Duplication
        if (empty($uid)) {
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...
317
            if (is_object($GLOBALS['xoopsUser'])) {
318
                $uid = $GLOBALS['xoopsUser']->getVar('uid');
319
            } else {
320
                return $ret;
321
            }
322
        }
323
324
        $criteria = new CriteriaCompo(new Criteria('uid', $uid));
325
        $criteria->add(new Criteria('read_item', '(' . implode(', ', array_map('intval', array_keys($items))) . ')', 'IN'));
326
        $itemsObject = $this->getAll($criteria, ['read_item', 'post_id']);
327
328
        $items_list = [];
329
        foreach (array_keys($itemsObject) as $key) {
330
            $items_list[$itemsObject[$key]->getVar('read_item')] = $itemsObject[$key]->getVar('post_id');
331
        }
332
        unset($itemsObject);
333
334
        foreach ($items as $key => $last_update) {
335
            $ret[$key] = (@$items_list[$key] >= $last_update);
336
        }
337
338
        return $ret;
339
    }
340
341
    // START irmtfan add clear duplicated rows function
342
343
    /**
344
     * @return bool
345
     */
346
    public function clearDuplicate()
347
    {
348
        /**
349
         * This is needed for the following query GROUP BY clauses to work in MySQL 5.7.
350
         * This is a TEMPORARY fix. Needing this function is bad in the first place, but
351
         * needing sloppy SQL to make it work is worse.
352
         * @todo The schema itself should preclude the duplicates
353
         */
354
        $sql = "SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''))";
355
        $this->db->queryF($sql);
356
357
        $sql = 'CREATE TABLE ' . $this->table . '_duplicate LIKE ' . $this->table . '; ';
358 View Code Duplication
        if (!$result = $this->db->queryF($sql)) {
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...
359
            xoops_error($this->db->error() . '<br>' . $sql);
360
361
            return false;
362
        }
363
        $sql = 'INSERT ' . $this->table . '_duplicate SELECT * FROM ' . $this->table . ' GROUP BY read_item, uid; ';
364 View Code Duplication
        if (!$result = $this->db->queryF($sql)) {
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...
365
            xoops_error($this->db->error() . '<br>' . $sql);
366
367
            return false;
368
        }
369
        $sql = 'RENAME TABLE ' . $this->table . ' TO ' . $this->table . '_with_duplicate; ';
370 View Code Duplication
        if (!$result = $this->db->queryF($sql)) {
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...
371
            xoops_error($this->db->error() . '<br>' . $sql);
372
373
            return false;
374
        }
375
        $sql = 'RENAME TABLE ' . $this->table . '_duplicate TO ' . $this->table . '; ';
376 View Code Duplication
        if (!$result = $this->db->queryF($sql)) {
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...
377
            xoops_error($this->db->error() . '<br>' . $sql);
378
379
            return false;
380
        }
381
        $sql    = 'SHOW INDEX FROM ' . $this->table . " WHERE KEY_NAME = 'read_item_uid'";
382
        $result = $this->db->queryF($sql);
383
        if (empty($result)) {
384
            $sql .= 'ALTER TABLE ' . $this->table . ' ADD INDEX read_item_uid ( read_item, uid ); ';
385 View Code Duplication
            if (!$result = $this->db->queryF($sql)) {
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...
386
                xoops_error($this->db->error() . '<br>' . $sql);
387
388
                return false;
389
            }
390
        }
391
        $sql = 'DROP TABLE ' . $this->table . '_with_duplicate; ';
392 View Code Duplication
        if (!$result = $this->db->queryF($sql)) {
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...
393
            xoops_error($this->db->error() . '<br>' . $sql);
394
395
            return false;
396
        }
397
398
        return true;
399
    }
400
    // END irmtfan add clear duplicated rows function
401
}
402