Passed
Pull Request — master (#18)
by Michael
02:50
created

include/onuninstall.php (3 issues)

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Xoopspoll uninstall functions.php
14
 *
15
 * @copyright:: {@link https://xoops.org/ XOOPS Project}
16
 * @license  ::   {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @package  ::   xoopspoll
18
 * @since    ::     1.40
19
 * @author   ::    zyspec <[email protected]>
20
 * @param XoopsModule $module
21
 * @return bool
22
 */
23
24
use XoopsModules\Newbb;
25
use XoopsModules\Xoopspoll\{
26
    Utility
27
};
28
29
/**
30
 * @param \XoopsModule $module
31
 * @return bool
32
 */
33
function xoops_module_pre_uninstall_xoopspoll(\XoopsModule $module)
0 ignored issues
show
The parameter $module is not used and could be removed. ( Ignorable by Annotation )

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

33
function xoops_module_pre_uninstall_xoopspoll(/** @scrutinizer ignore-unused */ \XoopsModule $module)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
{
35
    /* make sure that any polls associated with xoopspoll are cleared from newbb */
36
    /** @var \XoopsModuleHandler $moduleHandler */
37
    $moduleHandler = xoops_getHandler('module');
38
    $newbbModule   = $moduleHandler->getByDirname('newbb');
39
    $success       = true;
40
    if (is_object($newbbModule) && $newbbModule->getVar('isactive')) {
41
        /** @var Newbb\TopicHandler $topicHandler */
42
        $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
0 ignored issues
show
The type XoopsModules\Newbb\Helper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
43
        $criteria     = new \Criteria('topic_haspoll', 0, '>');
44
        $s1           = $topicHandler->updateAll('poll_id', 0, $criteria);  // clear any polls associated with forum topic
45
        $s2           = $topicHandler->updateAll('topic_haspoll', 0, $criteria); // clear haspoll indicator in forum
46
        $success      = $s1 && $s2;
47
    }
48
49
    return $success;
50
}
51
52
/**
53
 * @param XoopsModule $module
54
 * @return bool
55
 */
56
function xoops_module_uninstall_xoopspoll(\XoopsModule $module)
0 ignored issues
show
The parameter $module is not used and could be removed. ( Ignorable by Annotation )

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

56
function xoops_module_uninstall_xoopspoll(/** @scrutinizer ignore-unused */ \XoopsModule $module)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
{
58
    /* clear the voted cookie(s) for the admin user's machine when module is uninstalled */
59
    //    xoops_load('pollUtility', 'xoopspoll');
60
    $success = Utility::setVoteCookie('', null, time() - 3600);
61
62
    return $success;
63
}
64