News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Test failed occurs when updating the forum to 2.1.3

Started by jsx, November 21, 2022, 04:29:35 PM

Previous topic - Next topic

jsx

Hi.

I want to update the forum from 2.1.2 to 2.1.3, but Test failed occurred here:



./Sources/ModerationCenter.php

1.

Code (Find) Select Expand
* @version 2.1.0
Code (Replace) Select Expand
* @version 2.1.3

2.

Code (Find) Select Expand

/**
 * Browse all the reported users...
 */
function ReportedMembers()
{
    global $txt, $context, $scripturl, $smcFunc;

    loadTemplate('ModerationCenter');

    // Set an empty var for the server response.
    $context['report_member_action'] = '';

    // Put the open and closed options into tabs, because we can...
    $context[$context['moderation_menu_name']]['tab_data'] = array(
        'title' => $txt['mc_reported_members'],
        'help' => '',
        'description' => $txt['mc_reported_members_desc'],
    );

    isAllowedTo('moderate_forum');

    // Set up the comforting bits...
    $context['page_title'] = $txt['mc_reported_members'];
    $context['sub_template'] = 'reported_members';

    // Are we viewing open or closed reports?
    $context['view_closed'] = isset($_GET['sa']) && $_GET['sa'] == 'closed' ? 1 : 0;

    // Are we doing any work?
    if ((isset($_GET['ignore']) || isset($_GET['close'])) && isset($_GET['rid']))
    {
        checkSession('get');
        $_GET['rid'] = (int) $_GET['rid'];

        // Update the report...
        $smcFunc['db_query']('', '
            UPDATE {db_prefix}log_reported
            SET ' . (isset($_GET['ignore']) ? 'ignore_all = {int:ignore_all}' : 'closed = {int:closed}') . '
            WHERE id_report = {int:id_report}',
            array(
                'ignore_all' => isset($_GET['ignore']) ? (int) $_GET['ignore'] : 0,
                'closed' => isset($_GET['close']) ? (int) $_GET['close'] : 0,
                'id_report' => $_GET['rid'],
            )
        );

        // Get the board, topic and message for this report
        $request = $smcFunc['db_query']('', '
            SELECT id_member, membername
            FROM {db_prefix}log_reported
            WHERE id_report = {int:id_report}',
            array(
                'id_report' => $_GET['rid'],
            )
        );

        // Set up the data for the log...
        $extra = array('report' => $_GET['rid']);
        list($extra['member'], $extra['membername']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);

        // Stick this in string format for consistency
        $extra['member'] = (string) $extra['member'];

        // Tell the user about it.
        $context['report_member_action'] = isset($_GET['ignore']) ? (!empty($_GET['ignore']) ? 'ignore' : 'unignore') : (!empty($_GET['close']) ? 'close' : 'open');

        // Log this action
        logAction($context['report_member_action'] . '_user_report', $extra);

        // Time to update.
        updateSettings(array('last_mod_report_action' => time()));
        recountOpenReports('members');
    }
    elseif (isset($_POST['close']) && isset($_POST['close_selected']))
    {
        checkSession();

        // All the ones to update...
        $toClose = array();
        foreach ($_POST['close'] as $rid)
            $toClose[] = (int) $rid;

        if (!empty($toClose))
        {
            // Get the data for each of these reports
            $request = $smcFunc['db_query']('', '
                SELECT id_report, id_member, membername
                FROM {db_prefix}log_reported
                WHERE id_report IN ({array_int:report_list})',
                array(
                    'report_list' => $toClose,
                )
            );

            $logs = array();
            while ($reports = $smcFunc['db_fetch_assoc']($request))
            {
                $logs[] = array(
                    'action' => 'close_user_report',
                    'log_type' => 'moderate',
                    'extra' => array(
                        'report' => $reports['id_report'],
                        'membername' => $reports['membername'],
                        'member' => (string) $reports['id_member'],
                    ),
                );
            }

            $smcFunc['db_free_result']($request);

            // Log the closing of all the reports
            logActions($logs);

            $smcFunc['db_query']('', '
                UPDATE {db_prefix}log_reported
                SET closed = {int:is_closed}
                WHERE id_report IN ({array_int:report_list})',
                array(
                    'report_list' => $toClose,
                    'is_closed' => 1,
                )
            );

            // Time to update.
            updateSettings(array('last_mod_report_action' => time()));
            recountOpenReports('members');
        }

        // Go on and tell the result.
        $context['report_member_action'] = 'close_all';
    }

    // How many entries are we viewing?
    $request = $smcFunc['db_query']('', '
        SELECT COUNT(*)
        FROM {db_prefix}log_reported AS lr
        WHERE lr.closed = {int:view_closed}
            AND lr.id_board = {int:not_a_reported_post}',
        array(
            'view_closed' => $context['view_closed'],
            'not_a_reported_post' => 0,
        )
    );
    list ($context['total_reports']) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);

    // So, that means we can page index, yes?
    $context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reportedmembers' . ($context['view_closed'] ? ';sa=closed' : ''), $_GET['start'], $context['total_reports'], 10);
    $context['start'] = $_GET['start'];

    // By George, that means we in a position to get the reports, golly good.
    $request = $smcFunc['db_query']('', '
        SELECT lr.id_report, lr.id_member, lr.time_started, lr.time_updated, lr.num_reports, lr.closed, lr.ignore_all,
            COALESCE(mem.real_name, lr.membername) AS user_name, COALESCE(mem.id_member, 0) AS id_user
        FROM {db_prefix}log_reported AS lr
            LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lr.id_member)
        WHERE lr.closed = {int:view_closed}
            AND lr.id_board = {int:not_a_reported_post}
        ORDER BY lr.time_updated DESC
        LIMIT {int:limit}, {int:max}',
        array(
            'view_closed' => $context['view_closed'],
            'not_a_reported_post' => 0,
            'limit' => $context['start'],
            'max' => 10,
        )
    );
    $context['reports'] = array();
    $report_ids = array();
    for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
    {
        $report_ids[] = $row['id_report'];
        $context['reports'][$row['id_report']] = array(
            'id' => $row['id_report'],
            'report_href' => $scripturl . '?action=moderate;area=reportedmembers;report=' . $row['id_report'],
            'user' => array(
                'id' => $row['id_user'],
                'name' => $row['user_name'],
                'link' => $row['id_user'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_user'] . '">' . $row['user_name'] . '</a>' : $row['user_name'],
                'href' => $scripturl . '?action=profile;u=' . $row['id_user'],
            ),
            'comments' => array(),
            'time_started' => timeformat($row['time_started']),
            'last_updated' => timeformat($row['time_updated']),
            'num_reports' => $row['num_reports'],
            'closed' => $row['closed'],
            'ignore' => $row['ignore_all']
        );
    }
    $smcFunc['db_free_result']($request);

    // Now get all the people who reported it.
    if (!empty($report_ids))
    {
        $request = $smcFunc['db_query']('', '
            SELECT lrc.id_comment, lrc.id_report, lrc.time_sent, lrc.comment,
                COALESCE(mem.id_member, 0) AS id_member, COALESCE(mem.real_name, lrc.membername) AS reporter
            FROM {db_prefix}log_reported_comments AS lrc
                LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lrc.id_member)
            WHERE lrc.id_report IN ({array_int:report_list})',
            array(
                'report_list' => $report_ids,
            )
        );
        while ($row = $smcFunc['db_fetch_assoc']($request))
        {
            $context['reports'][$row['id_report']]['comments'][] = array(
                'id' => $row['id_comment'],
                'message' => $row['comment'],
                'time' => timeformat($row['time_sent']),
                'member' => array(
                    'id' => $row['id_member'],
                    'name' => empty($row['reporter']) ? $txt['guest'] : $row['reporter'],
                    'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['reporter'] . '</a>' : (empty($row['reporter']) ? $txt['guest'] : $row['reporter']),
                    'href' => $row['id_member'] ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
                ),
            );
        }
        $smcFunc['db_free_result']($request);
    }

    $context['report_manage_bans'] = allowedTo('manage_bans');
}

/**
 * Act as an entrace for all group related activity.

Code (Replace) Select Expand

/**
 * Act as an entrace for all group related activity.

Can I update the forum?

Kindred

You'll have to manually apply the failed auto code
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

jsx

Basically Test failed is in the second point. So I need to remove all this code in the ModerationCenter.php file

/**
 * Browse all the reported users...
 */
function ReportedMembers()
{
global $txt, $context, $scripturl, $smcFunc;

loadTemplate('ModerationCenter');

// Set an empty var for the server response.
$context['report_member_action'] = '';

// Put the open and closed options into tabs, because we can...
$context[$context['moderation_menu_name']]['tab_data'] = array(
'title' => $txt['mc_reported_members'],
'help' => '',
'description' => $txt['mc_reported_members_desc'],
);

isAllowedTo('moderate_forum');

// Set up the comforting bits...
$context['page_title'] = $txt['mc_reported_members'];
$context['sub_template'] = 'reported_members';

// Are we viewing open or closed reports?
$context['view_closed'] = isset($_GET['sa']) && $_GET['sa'] == 'closed' ? 1 : 0;

// Are we doing any work?
if ((isset($_GET['ignore']) || isset($_GET['close'])) && isset($_GET['rid']))
{
checkSession('get');
$_GET['rid'] = (int) $_GET['rid'];

// Update the report...
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_reported
SET ' . (isset($_GET['ignore']) ? 'ignore_all = {int:ignore_all}' : 'closed = {int:closed}') . '
WHERE id_report = {int:id_report}',
array(
'ignore_all' => isset($_GET['ignore']) ? (int) $_GET['ignore'] : 0,
'closed' => isset($_GET['close']) ? (int) $_GET['close'] : 0,
'id_report' => $_GET['rid'],
)
);

// Get the board, topic and message for this report
$request = $smcFunc['db_query']('', '
SELECT id_member, membername
FROM {db_prefix}log_reported
WHERE id_report = {int:id_report}',
array(
'id_report' => $_GET['rid'],
)
);

// Set up the data for the log...
$extra = array('report' => $_GET['rid']);
list($extra['member'], $extra['membername']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

// Stick this in string format for consistency
$extra['member'] = (string) $extra['member'];

// Tell the user about it.
$context['report_member_action'] = isset($_GET['ignore']) ? (!empty($_GET['ignore']) ? 'ignore' : 'unignore') : (!empty($_GET['close']) ? 'close' : 'open');

// Log this action
logAction($context['report_member_action'] . '_user_report', $extra);

// Time to update.
updateSettings(array('last_mod_report_action' => time()));
recountOpenReports('members');
}
elseif (isset($_POST['close']) && isset($_POST['close_selected']))
{
checkSession();

// All the ones to update...
$toClose = array();
foreach ($_POST['close'] as $rid)
$toClose[] = (int) $rid;

if (!empty($toClose))
{
// Get the data for each of these reports
$request = $smcFunc['db_query']('', '
SELECT id_report, id_member, membername
FROM {db_prefix}log_reported
WHERE id_report IN ({array_int:report_list})',
array(
'report_list' => $toClose,
)
);

$logs = array();
while ($reports = $smcFunc['db_fetch_assoc']($request))
{
$logs[] = array(
'action' => 'close_user_report',
'log_type' => 'moderate',
'extra' => array(
'report' => $reports['id_report'],
'membername' => $reports['membername'],
'member' => (string) $reports['id_member'],
),
);
}

$smcFunc['db_free_result']($request);

// Log the closing of all the reports
logActions($logs);

$smcFunc['db_query']('', '
UPDATE {db_prefix}log_reported
SET closed = {int:is_closed}
WHERE id_report IN ({array_int:report_list})',
array(
'report_list' => $toClose,
'is_closed' => 1,
)
);

// Time to update.
updateSettings(array('last_mod_report_action' => time()));
recountOpenReports('members');
}

// Go on and tell the result.
$context['report_member_action'] = 'close_all';
}

// How many entries are we viewing?
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}log_reported AS lr
WHERE lr.closed = {int:view_closed}
AND lr.id_board = {int:not_a_reported_post}',
array(
'view_closed' => $context['view_closed'],
'not_a_reported_post' => 0,
)
);
list ($context['total_reports']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

// So, that means we can page index, yes?
$context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=reportedmembers' . ($context['view_closed'] ? ';sa=closed' : ''), $_GET['start'], $context['total_reports'], 10);
$context['start'] = $_GET['start'];

// By George, that means we in a position to get the reports, golly good.
$request = $smcFunc['db_query']('', '
SELECT lr.id_report, lr.id_member, lr.time_started, lr.time_updated, lr.num_reports, lr.closed, lr.ignore_all,
COALESCE(mem.real_name, lr.membername) AS user_name, COALESCE(mem.id_member, 0) AS id_user
FROM {db_prefix}log_reported AS lr
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lr.id_member)
WHERE lr.closed = {int:view_closed}
AND lr.id_board = {int:not_a_reported_post}
ORDER BY lr.time_updated DESC
LIMIT {int:limit}, {int:max}',
array(
'view_closed' => $context['view_closed'],
'not_a_reported_post' => 0,
'limit' => $context['start'],
'max' => 10,
)
);
$context['reports'] = array();
$report_ids = array();
for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
{
$report_ids[] = $row['id_report'];
$context['reports'][$row['id_report']] = array(
'id' => $row['id_report'],
'report_href' => $scripturl . '?action=moderate;area=reportedmembers;report=' . $row['id_report'],
'user' => array(
'id' => $row['id_user'],
'name' => $row['user_name'],
'link' => $row['id_user'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_user'] . '">' . $row['user_name'] . '</a>' : $row['user_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_user'],
),
'comments' => array(),
'time_started' => timeformat($row['time_started']),
'last_updated' => timeformat($row['time_updated']),
'num_reports' => $row['num_reports'],
'closed' => $row['closed'],
'ignore' => $row['ignore_all']
);
}
$smcFunc['db_free_result']($request);

// Now get all the people who reported it.
if (!empty($report_ids))
{
$request = $smcFunc['db_query']('', '
SELECT lrc.id_comment, lrc.id_report, lrc.time_sent, lrc.comment,
COALESCE(mem.id_member, 0) AS id_member, COALESCE(mem.real_name, lrc.membername) AS reporter
FROM {db_prefix}log_reported_comments AS lrc
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lrc.id_member)
WHERE lrc.id_report IN ({array_int:report_list})',
array(
'report_list' => $report_ids,
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$context['reports'][$row['id_report']]['comments'][] = array(
'id' => $row['id_comment'],
'message' => $row['comment'],
'time' => timeformat($row['time_sent']),
'member' => array(
'id' => $row['id_member'],
'name' => empty($row['reporter']) ? $txt['guest'] : $row['reporter'],
'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['reporter'] . '</a>' : (empty($row['reporter']) ? $txt['guest'] : $row['reporter']),
'href' => $row['id_member'] ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
),
);
}
$smcFunc['db_free_result']($request);
}

$context['report_manage_bans'] = allowedTo('manage_bans');
}

/**
 * Act as an entrace for all group related activity.

And then should I leave only this part?

/**
 * Act as an entrace for all group related activity.

After saving and uploading the file to the server then can I update the forum?

landyvlad

I don't think your assumption is correct - please wait for someone in the know to respond before doing that :)
"Put as much effort into your question as you'd expect someone to give in an answer"

Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

Be the person your dog thinks you are.

Kindred

I haven't checked the exact update code -- but yes, that's what the code you displayed says.  Get rid of that entire function.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Sesquipedalian

Since the test failed, you must have some custom code in ModerationCenter.php that interfered with the automatic update.

Fortunately, this particular change is quite easy to make manually. All you need to do is delete the entire ReportedMembers() function. You can see the exact changes here.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

jsx

I removed this code from the ModerationCenter.php file and uploaded the file to the server and before upgrading I still saw Test Failed but I updated the forum and it's fine. Thank you for your help.

jsx

After the update, I noticed such a bug that SMF 2.1.3 Update appeared 12 times in the package list.



So I'm going to remove 11 items, leave only one.

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

jsx

You mean that I clicked on the update 12 times? I only clicked install once and the forum updated to 2.1.3

woolly bugger

my upgrade test fails at the same point.

here are mods installed... don't see which would cause the problemYou cannot view this attachment.

Nevermind... it was the TapaCrap  mod that caused the issues ... as usual...




pikeman

#11
During the update, an identical error was reported to me, which I solved by manually changing the file.


The error seems to be caused by Tapatalk, the third line was added by them.

            'time_started' => timeformat($row['time_started']),
            'last_updated' => timeformat($row['time_updated']),
            'timestamp_started' => $row['time_started'],

I deleted that line, hope Tapatalk will work without problems.




After the update, the following error appeared next to the user name in the list of present members:

data-adi="buffer_remove_this;">

jsx

It looks like the code I've put in is from Tapatalk SMF 2.1 Plugin 5.1.3, because when I try to uninstall this mod I get an error in the ModerationCenter.php file

pikeman

Quote from: pikeman on November 22, 2022, 01:01:10 PMAfter the update, the following error appeared next to the user name in the list of present members:

data-adi="buffer_remove_this;">

This error is caused by the mod Avatars Display Integration, before 2.1.3. was not there.

Pipke

Quote from: pikeman on November 22, 2022, 02:38:33 PM
Quote from: pikeman on November 22, 2022, 01:01:10 PMAfter the update, the following error appeared next to the user name in the list of present members:

data-adi="buffer_remove_this;">

This error is caused by the mod Avatars Display Integration, before 2.1.3. was not there.


I have updated this mod Avatars Display Integration, remove old version and install the v1.5.4, it should be fine then.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

casey_mrc

Thanks for posting this.

I, too, have the "test failure" message when test updating "ModerationCenter.php" from SMF v2.1.2 to v2.1.3

Yes, I also have the extra line in that file,

'timestamp_started' => $row['time_started'],

so that explains the failure!!

Question, if this extra line was added by my currently installed TapaTalk plugin v5.1.3, is is best to uninstall that plugin first (which should remove the "errant" extra line of code?), then perform the forum upgrade, then install the latest Tapatalk plugin v5.1.4 (as well as the usual removal of the mobiquo folder)?

If that line is not removed by uninstalling TT v5.1.3, perhaps I should just remove that errant line manually, perform the the SMF v2.1.3 update and then install TT v5.1.4?

Thanks for advance for any advice, coding is not my strongpoint!

Oldiesmann

Your best bet would be to uninstall Tapatalk then reinstall it if you need it (SMF 2.1 is designed so it will work on a variety of screen sizes, so there's not a lot of need for Tapatalk anymore)
Michael Eshom
Christian Metal Fans

casey_mrc

Thanks Oldiesmann.

If it was purely up to me, I would simply uninstall Tapatalk and not re-install, but I have a number of active users who only use Tapatalk to access the forum.

Aleksi "Lex" Kilpinen

I would not really recommend Tapatalk, simply because of how it works. It's not bad in the way that I'd really actively tell people to stop using it, but it's bad in a multitude of ways that any security conscious admin would avoid anyhow...
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: