RepairBoards
in package
implements
ActionInterface
Uses
BackwardCompatibility
This is here for the "repair any errors" feature in the admin center.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $errorTests : array<string|int, mixed>
- $loops : int
- $salvage_board : int
- $salvage_category : int
- $salvage_created : bool
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Does the job.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- load() : object
- Static wrapper for constructor.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- createSalvageArea() : void
- Create a salvage area for repair purposes, if one doesn't already exist.
- findForumErrors() : array<string|int, mixed>
- Checks for errors in steps, until 5 seconds have passed.
- fixCommentMissingReport() : void
- Callback to remove comments made on non-existent reports.
- fixGroupRequestMissingGroup() : void
- Callback to remove requests to join non-existent groups.
- fixGroupRequestMissingMember() : void
- Callback to remove requests to join a group made by non-existent members.
- fixMissingBoards() : void
- Callback to give a home to topics that have no board.
- fixMissingCachedSubject() : void
- Callback to fix missing log_search_subjects entries for a topic.
- fixMissingCaledarTopics() : void
- Callback to remove broken links to topics from calendar events.
- fixMissingCategories() : void
- Callback to give a home to boards that have no category.
- fixMissingLogBoards() : void
- Callback to remove log_boards entries for non-existent boards.
- fixMissingLogBoardsMembers() : void
- Callback to remove log_boards entries for non-existent members.
- fixMissingLogMarkRead() : void
- Callback to remove log_mark_read entries for non-existent boards.
- fixMissingLogMarkReadMembers() : void
- Callback to remove log_mark_read entries for non-existent members.
- fixMissingLogPollVote() : void
- Callback to remove poll votes made in non-existent polls.
- fixMissingLogTopics() : void
- Callback to remove log_topics entries for non-existent topics.
- fixMissingLogTopicsMembers() : void
- Callback to remove log_topics entries for non-existent members.
- fixMissingMemberVote() : void
- Callback to remove poll votes made by non-existent members.
- fixMissingMessages() : void
- Callback to remove all topics that have zero messages in the messages table.
- fixMissingNotifyMembers() : void
- Callback to remove log_notify entries for non-existent members.
- fixMissingParents() : void
- Callback to let our salvage board adopt orphaned child boards.
- fixMissingPMs() : void
- Callback to remove non-existent personal messages from the recipients' inboxes.
- fixMissingPollOptions() : void
- Callback to fix missing poll options.
- fixMissingPolls() : void
- Callback to remove non-existent polls from topics.
- fixMissingPollTopics() : void
- Callback to fix polls that have no topic.
- fixMissingPosters() : void
- Callback to give an author to messages that don't have one.
- fixMissingRecipients() : void
- Callback to remove non-existent recipients from personal messages.
- fixMissingSenders() : void
- Callback to fix the assigned authorship of PMs from non-existent senders.
- fixMissingTopicForCache() : void
- Callback to remove log_search_subjects entries for non-existent topics.
- fixMissingTopics() : void
- Callback to fix missing topics.
- fixReportMissingComments() : void
- Callback to remove non-existent comments from reports.
- fixTopicStats() : bool
- Callback to fix missing first and last message IDs for a topic.
- fixTopicStats2() : bool
- Callback to fix the recorded number of replies to a topic.
- fixTopicStats3() : void
- Callback to fix the recorded number of unapproved replies to a topic.
- missingCachedSubjectMessage() : bool
- Callback to get a message about missing log_search_subjects entries for a topic.
- pauseRepairProcess() : void
- Shows the not_done template to avoid CGI timeouts and similar.
- topicStatsMessage() : bool
- Callback to get a message about missing first and last message IDs for a topic.
- topicStatsMessage2() : bool
- Callback to get a message about an incorrect record of the number of replies to a topic.
Properties
$errorTests
public
array<string|int, mixed>
$errorTests
= [
// Make a last-ditch-effort check to get rid of topics with zeros..
'zero_topics' => ['check_query' => '
SELECT COUNT(*)
FROM {db_prefix}topics
WHERE id_topic = 0', 'check_type' => 'count', 'fix_it_query' => '
UPDATE {db_prefix}topics
SET id_topic = NULL
WHERE id_topic = 0', 'message' => 'repair_zero_ids'],
// ... and same with messages.
'zero_messages' => ['check_query' => '
SELECT COUNT(*)
FROM {db_prefix}messages
WHERE id_msg = 0', 'check_type' => 'count', 'fix_it_query' => '
UPDATE {db_prefix}messages
SET id_msg = NULL
WHERE id_msg = 0', 'message' => 'repair_zero_ids'],
// Find messages that don't have existing topics.
'missing_topics' => ['substeps' => ['step_size' => 1000, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}messages'], 'check_query' => '
SELECT m.id_topic, m.id_msg
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
WHERE m.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND t.id_topic IS NULL
ORDER BY m.id_topic, m.id_msg', 'fix_query' => '
SELECT
m.id_board, m.id_topic, MIN(m.id_msg) AS myid_first_msg, MAX(m.id_msg) AS myid_last_msg,
COUNT(*) - 1 AS my_num_replies
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
WHERE t.id_topic IS NULL
GROUP BY m.id_topic, m.id_board', 'fix_processing' => 'fixMissingTopics', 'force_fix' => ['stats_topics'], 'messages' => ['repair_missing_topics', 'id_msg', 'id_topic']],
// Find topics with no messages.
'missing_messages' => [
'substeps' => ['step_size' => 1000, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}topics'],
'check_query' => '
SELECT t.id_topic, COUNT(m.id_msg) AS num_msg
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic)
WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY t.id_topic
HAVING COUNT(m.id_msg) = 0',
// Remove all topics that have zero messages in the messages table.
'fix_collect' => ['index' => 'id_topic', 'process' => 'fixMissingMessages'],
'messages' => ['repair_missing_messages', 'id_topic'],
],
'poll_options_missing_poll' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_poll)
FROM {db_prefix}poll_choices'], 'check_query' => '
SELECT o.id_poll, count(*) as amount, t.id_topic, t.id_board, t.id_member_started AS id_poster, m.member_name AS poster_name
FROM {db_prefix}poll_choices AS o
LEFT JOIN {db_prefix}polls AS p ON (p.id_poll = o.id_poll)
LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = o.id_poll)
LEFT JOIN {db_prefix}members AS m ON (m.id_member = t.id_member_started)
WHERE o.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND p.id_poll IS NULL
GROUP BY o.id_poll, t.id_topic, t.id_board, t.id_member_started, m.member_name', 'fix_processing' => 'fixMissingPollOptions', 'force_fix' => ['stats_topics'], 'messages' => ['repair_poll_options_missing_poll', 'id_poll', 'amount']],
'polls_missing_topics' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_poll)
FROM {db_prefix}polls'], 'check_query' => '
SELECT p.id_poll, p.id_member, p.poster_name, t.id_board
FROM {db_prefix}polls AS p
LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll)
WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND t.id_poll IS NULL', 'fix_processing' => 'fixMissingPollTopics', 'force_fix' => ['stats_topics'], 'messages' => ['repair_polls_missing_topics', 'id_poll', 'id_topic']],
'stats_topics' => ['substeps' => ['step_size' => 200, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}topics'], 'check_query' => '
SELECT
t.id_topic, t.id_first_msg, t.id_last_msg,
CASE WHEN MIN(ma.id_msg) > 0 THEN
CASE WHEN MIN(mu.id_msg) > 0 THEN
CASE WHEN MIN(mu.id_msg) < MIN(ma.id_msg) THEN MIN(mu.id_msg) ELSE MIN(ma.id_msg) END ELSE
MIN(ma.id_msg) END ELSE
MIN(mu.id_msg) END AS myid_first_msg,
CASE WHEN MAX(ma.id_msg) > 0 THEN MAX(ma.id_msg) ELSE MIN(mu.id_msg) END AS myid_last_msg,
t.approved, mf.approved, mf.approved AS firstmsg_approved
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}messages AS ma ON (ma.id_topic = t.id_topic AND ma.approved = 1)
LEFT JOIN {db_prefix}messages AS mu ON (mu.id_topic = t.id_topic AND mu.approved = 0)
LEFT JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved
ORDER BY t.id_topic', 'fix_processing' => 'fixTopicStats', 'message_function' => 'topicStatsMessage'],
// Find topics with incorrect num_replies.
'stats_topics2' => ['substeps' => ['step_size' => 300, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}topics'], 'check_query' => '
SELECT
t.id_topic, t.num_replies, mf.approved,
CASE WHEN COUNT(ma.id_msg) > 0 THEN CASE WHEN mf.approved > 0 THEN COUNT(ma.id_msg) - 1 ELSE COUNT(ma.id_msg) END ELSE 0 END AS my_num_replies
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}messages AS ma ON (ma.id_topic = t.id_topic AND ma.approved = 1)
LEFT JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY t.id_topic, t.num_replies, mf.approved
ORDER BY t.id_topic', 'fix_processing' => 'fixTopicStats2', 'message_function' => 'topicStatsMessage2'],
// Find topics with incorrect unapproved_posts.
'stats_topics3' => ['substeps' => ['step_size' => 1000, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}topics'], 'check_query' => '
SELECT
t.id_topic, t.unapproved_posts, COUNT(mu.id_msg) AS my_unapproved_posts
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}messages AS mu ON (mu.id_topic = t.id_topic AND mu.approved = 0)
WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY t.id_topic, t.unapproved_posts
HAVING unapproved_posts != COUNT(mu.id_msg)
ORDER BY t.id_topic', 'fix_processing' => 'fixTopicStats3', 'messages' => ['repair_topic_wrong_unapproved_number', 'id_topic', 'unapproved_posts']],
// Find topics with nonexistent boards.
'missing_boards' => ['substeps' => ['step_size' => 1000, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}topics'], 'check_query' => '
SELECT t.id_topic, t.id_board
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE b.id_board IS NULL
AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
ORDER BY t.id_board, t.id_topic', 'fix_query' => '
SELECT t.id_board, COUNT(*) AS my_num_topics, COUNT(m.id_msg) AS my_num_posts
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic)
WHERE b.id_board IS NULL
AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY t.id_board', 'fix_processing' => 'fixMissingBoards', 'messages' => ['repair_missing_boards', 'id_topic', 'id_board']],
// Find boards with nonexistent categories.
'missing_categories' => ['check_query' => '
SELECT b.id_board, b.id_cat
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
WHERE c.id_cat IS NULL
ORDER BY b.id_cat, b.id_board', 'fix_collect' => ['index' => 'id_cat', 'process' => 'fixMissingCategories'], 'messages' => ['repair_missing_categories', 'id_board', 'id_cat']],
// Find messages with nonexistent members.
'missing_posters' => [
'substeps' => ['step_size' => 2000, 'step_max' => '
SELECT MAX(id_msg)
FROM {db_prefix}messages'],
'check_query' => '
SELECT m.id_msg, m.id_member
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE mem.id_member IS NULL
AND m.id_member != 0
AND m.id_msg BETWEEN {STEP_LOW} AND {STEP_HIGH}
ORDER BY m.id_msg',
// Last step-make sure all non-guest posters still exist.
'fix_collect' => ['index' => 'id_msg', 'process' => 'fixMissingPosters'],
'messages' => ['repair_missing_posters', 'id_msg', 'id_member'],
],
// Find boards with nonexistent parents.
'missing_parents' => ['check_query' => '
SELECT b.id_board, b.id_parent
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}boards AS p ON (p.id_board = b.id_parent)
WHERE b.id_parent != 0
AND (p.id_board IS NULL OR p.id_board = b.id_board)
ORDER BY b.id_parent, b.id_board', 'fix_collect' => ['index' => 'id_parent', 'process' => 'fixMissingParents'], 'messages' => ['repair_missing_parents', 'id_board', 'id_parent']],
'missing_polls' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_poll)
FROM {db_prefix}topics'], 'check_query' => '
SELECT t.id_poll, t.id_topic
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}polls AS p ON (p.id_poll = t.id_poll)
WHERE t.id_poll != 0
AND t.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND p.id_poll IS NULL', 'fix_collect' => ['index' => 'id_poll', 'process' => 'fixMissingPolls'], 'messages' => ['repair_missing_polls', 'id_topic', 'id_poll']],
'missing_calendar_topics' => ['substeps' => ['step_size' => 1000, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}calendar'], 'check_query' => '
SELECT cal.id_topic, cal.id_event
FROM {db_prefix}calendar AS cal
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = cal.id_topic)
WHERE cal.id_topic != 0
AND cal.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND t.id_topic IS NULL
ORDER BY cal.id_topic', 'fix_collect' => ['index' => 'id_topic', 'process' => 'fixMissingCaledarTopics'], 'messages' => ['repair_missing_calendar_topics', 'id_event', 'id_topic']],
'missing_log_topics' => ['substeps' => ['step_size' => 150, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_topics'], 'check_query' => '
SELECT lt.id_topic
FROM {db_prefix}log_topics AS lt
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = lt.id_topic)
WHERE t.id_topic IS NULL
AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', 'fix_collect' => ['index' => 'id_topic', 'process' => 'fixMissingLogTopics'], 'messages' => ['repair_missing_log_topics', 'id_topic']],
'missing_log_topics_members' => ['substeps' => ['step_size' => 150, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_topics'], 'check_query' => '
SELECT lt.id_member
FROM {db_prefix}log_topics AS lt
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lt.id_member)
WHERE mem.id_member IS NULL
AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY lt.id_member', 'fix_collect' => ['index' => 'id_member', 'process' => 'fixMissingLogTopicsMembers'], 'messages' => ['repair_missing_log_topics_members', 'id_member']],
'missing_log_boards' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_boards'], 'check_query' => '
SELECT lb.id_board
FROM {db_prefix}log_boards AS lb
LEFT JOIN {db_prefix}boards AS b ON (b.id_board = lb.id_board)
WHERE b.id_board IS NULL
AND lb.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY lb.id_board', 'fix_collect' => ['index' => 'id_board', 'process' => 'fixMissingLogBoards'], 'messages' => ['repair_missing_log_boards', 'id_board']],
'missing_log_boards_members' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_boards'], 'check_query' => '
SELECT lb.id_member
FROM {db_prefix}log_boards AS lb
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lb.id_member)
WHERE mem.id_member IS NULL
AND lb.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY lb.id_member', 'fix_collect' => ['index' => 'id_member', 'process' => 'fixMissingLogBoardsMembers'], 'messages' => ['repair_missing_log_boards_members', 'id_member']],
'missing_log_mark_read' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_mark_read'], 'check_query' => '
SELECT lmr.id_board
FROM {db_prefix}log_mark_read AS lmr
LEFT JOIN {db_prefix}boards AS b ON (b.id_board = lmr.id_board)
WHERE b.id_board IS NULL
AND lmr.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY lmr.id_board', 'fix_collect' => ['index' => 'id_board', 'process' => 'fixMissingLogMarkRead'], 'messages' => ['repair_missing_log_mark_read', 'id_board']],
'missing_log_mark_read_members' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_mark_read'], 'check_query' => '
SELECT lmr.id_member
FROM {db_prefix}log_mark_read AS lmr
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lmr.id_member)
WHERE mem.id_member IS NULL
AND lmr.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY lmr.id_member', 'fix_collect' => ['index' => 'id_member', 'process' => 'fixMissingLogMarkReadMembers'], 'messages' => ['repair_missing_log_mark_read_members', 'id_member']],
'missing_pms' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_pm)
FROM {db_prefix}pm_recipients'], 'check_query' => '
SELECT pmr.id_pm
FROM {db_prefix}pm_recipients AS pmr
LEFT JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)
WHERE pm.id_pm IS NULL
AND pmr.id_pm BETWEEN {STEP_LOW} AND {STEP_HIGH}
GROUP BY pmr.id_pm', 'fix_collect' => ['index' => 'id_pm', 'process' => 'fixMissingPMs'], 'messages' => ['repair_missing_pms', 'id_pm']],
'missing_recipients' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}pm_recipients'], 'check_query' => '
SELECT pmr.id_member
FROM {db_prefix}pm_recipients AS pmr
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = pmr.id_member)
WHERE pmr.id_member != 0
AND pmr.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND mem.id_member IS NULL
GROUP BY pmr.id_member', 'fix_collect' => ['index' => 'id_member', 'process' => 'fixMissingRecipients'], 'messages' => ['repair_missing_recipients', 'id_member']],
'missing_senders' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_pm)
FROM {db_prefix}personal_messages'], 'check_query' => '
SELECT pm.id_pm, pm.id_member_from
FROM {db_prefix}personal_messages AS pm
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = pm.id_member_from)
WHERE pm.id_member_from != 0
AND pm.id_pm BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND mem.id_member IS NULL', 'fix_collect' => ['index' => 'id_pm', 'process' => 'fixMissingSenders'], 'messages' => ['repair_missing_senders', 'id_pm', 'id_member_from']],
'missing_notify_members' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_notify'], 'check_query' => '
SELECT ln.id_member
FROM {db_prefix}log_notify AS ln
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = ln.id_member)
WHERE ln.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND mem.id_member IS NULL
GROUP BY ln.id_member', 'fix_collect' => ['index' => 'id_member', 'process' => 'fixMissingNotifyMembers'], 'messages' => ['repair_missing_notify_members', 'id_member']],
'missing_cached_subject' => ['substeps' => ['step_size' => 100, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}topics'], 'check_query' => '
SELECT t.id_topic, fm.subject
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS fm ON (fm.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic)
WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND lss.id_topic IS NULL', 'fix_full_processing' => 'fixMissingCachedSubject', 'message_function' => 'missingCachedSubjectMessage'],
'missing_topic_for_cache' => ['substeps' => ['step_size' => 50, 'step_max' => '
SELECT MAX(id_topic)
FROM {db_prefix}log_search_subjects'], 'check_query' => '
SELECT lss.id_topic, lss.word
FROM {db_prefix}log_search_subjects AS lss
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = lss.id_topic)
WHERE lss.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND t.id_topic IS NULL', 'fix_collect' => ['index' => 'id_topic', 'process' => 'fixMissingTopicForCache'], 'messages' => ['repair_missing_topic_for_cache', 'word']],
'missing_member_vote' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_polls'], 'check_query' => '
SELECT lp.id_poll, lp.id_member
FROM {db_prefix}log_polls AS lp
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lp.id_member)
WHERE lp.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND lp.id_member > 0
AND mem.id_member IS NULL', 'fix_collect' => ['index' => 'id_member', 'process' => 'fixMissingMemberVote'], 'messages' => ['repair_missing_log_poll_member', 'id_poll', 'id_member']],
'missing_log_poll_vote' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_poll)
FROM {db_prefix}log_polls'], 'check_query' => '
SELECT lp.id_poll, lp.id_member
FROM {db_prefix}log_polls AS lp
LEFT JOIN {db_prefix}polls AS p ON (p.id_poll = lp.id_poll)
WHERE lp.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND p.id_poll IS NULL', 'fix_collect' => ['index' => 'id_poll', 'process' => 'fixMissingLogPollVote'], 'messages' => ['repair_missing_log_poll_vote', 'id_member', 'id_poll']],
'report_missing_comments' => ['substeps' => ['step_size' => 500, 'step_max' => '
SELECT MAX(id_report)
FROM {db_prefix}log_reported'], 'check_query' => '
SELECT lr.id_report, lr.subject
FROM {db_prefix}log_reported AS lr
LEFT JOIN {db_prefix}log_reported_comments AS lrc ON (lrc.id_report = lr.id_report)
WHERE lr.id_report BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND lrc.id_report IS NULL', 'fix_collect' => ['index' => 'id_report', 'process' => 'fixReportMissingComments'], 'messages' => ['repair_report_missing_comments', 'id_report', 'subject']],
'comments_missing_report' => ['substeps' => ['step_size' => 200, 'step_max' => '
SELECT MAX(id_report)
FROM {db_prefix}log_reported_comments'], 'check_query' => '
SELECT lrc.id_report, lrc.membername
FROM {db_prefix}log_reported_comments AS lrc
LEFT JOIN {db_prefix}log_reported AS lr ON (lr.id_report = lrc.id_report)
WHERE lrc.id_report BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND lr.id_report IS NULL', 'fix_collect' => ['index' => 'id_report', 'process' => 'fixCommentMissingReport'], 'messages' => ['repair_comments_missing_report', 'id_report', 'membername']],
'group_request_missing_member' => ['substeps' => ['step_size' => 200, 'step_max' => '
SELECT MAX(id_member)
FROM {db_prefix}log_group_requests'], 'check_query' => '
SELECT lgr.id_member
FROM {db_prefix}log_group_requests AS lgr
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = lgr.id_member)
WHERE lgr.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND mem.id_member IS NULL
GROUP BY lgr.id_member', 'fix_collect' => ['index' => 'id_member', 'process' => 'fixGroupRequestMissingMember'], 'messages' => ['repair_group_request_missing_member', 'id_member']],
'group_request_missing_group' => ['substeps' => ['step_size' => 200, 'step_max' => '
SELECT MAX(id_group)
FROM {db_prefix}log_group_requests'], 'check_query' => '
SELECT lgr.id_group
FROM {db_prefix}log_group_requests AS lgr
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = lgr.id_group)
WHERE lgr.id_group BETWEEN {STEP_LOW} AND {STEP_HIGH}
AND mg.id_group IS NULL
GROUP BY lgr.id_group', 'fix_collect' => ['index' => 'id_group', 'process' => 'fixGroupRequestMissingGroup'], 'messages' => ['repair_group_request_missing_group', 'id_group']],
]
All the tests we might want to do.
This array is defined like so:
string check_query: Query to be executed when testing if errors exist.
string check_type: Defines how it knows if a problem was found. If set to count looks for the first variable from check_query being > 0. Anything else it looks for some results. If not set assumes you want results.
string fix_it_query: When doing fixes if an error was detected this query is executed to "fix" it.
string fix_query: The query to execute to get data when doing a fix. If not set check_query is used again.
array fix_collect: This array is used if the fix is basically gathering all broken ids and then doing something with them.
- string index: The value returned from the main query and passed to the processing function.
- string process: Name of a function that will be passed an array of ids to execute the fix on.
string fix_processing: Name of a function called for each row returned from fix_query to execute whatever fixes are required.
string fix_full_processing: As above but does the while loop and everything itself, except the freeing.
array force_fix: If this is set then the error types included within this array will also be assumed broken. These are only processed if they occur after the primary error in the array.
In all cases where a function name is provided, the findForumErrors() method will first look for a method of this class with that name. If no such method exists, it will ask Utils::getCallable() to figure out what to call.
MOD AUTHORS: If you want to add tests to this array so that SMF can fix data for your mod, use the integrate_repair_boards hook.
$loops
public
int
$loops
= 0
Tracks how many loops we have done for pauseRepairProcess().
$salvage_board
public
int
$salvage_board
$salvage_category
public
int
$salvage_category
$salvage_created
public
bool
$salvage_created
= false
Whether the salvage area has been created yet.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'RepairBoards']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Does the job.
public
execute() : void
exportStatic()
Provides a way to export a class's public static properties and methods to global namespace.
public
static exportStatic() : void
To do so:
- Use this trait in the class.
- At the END of the class's file, call its exportStatic() method.
Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.
Regarding the $backcompat items:
A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].
$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.
$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.
Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
createSalvageArea()
Create a salvage area for repair purposes, if one doesn't already exist.
protected
createSalvageArea() : void
Uses the forum's default language, and checks based on that name.
findForumErrors()
Checks for errors in steps, until 5 seconds have passed.
protected
findForumErrors([bool $do_fix = false ]) : array<string|int, mixed>
It keeps track of the errors it did find, so that the actual repair won't have to recheck everything.
Parameters
- $do_fix : bool = false
-
Whether to fix the errors or just return the info.
Return values
array<string|int, mixed> —The errors found.
fixCommentMissingReport()
Callback to remove comments made on non-existent reports.
protected
fixCommentMissingReport(mixed $reports) : void
Parameters
- $reports : mixed
fixGroupRequestMissingGroup()
Callback to remove requests to join non-existent groups.
protected
fixGroupRequestMissingGroup(mixed $groups) : void
Parameters
- $groups : mixed
fixGroupRequestMissingMember()
Callback to remove requests to join a group made by non-existent members.
protected
fixGroupRequestMissingMember(mixed $members) : void
Parameters
- $members : mixed
fixMissingBoards()
Callback to give a home to topics that have no board.
protected
fixMissingBoards(mixed $row) : void
Parameters
- $row : mixed
fixMissingCachedSubject()
Callback to fix missing log_search_subjects entries for a topic.
protected
fixMissingCachedSubject(mixed $result) : void
Parameters
- $result : mixed
fixMissingCaledarTopics()
Callback to remove broken links to topics from calendar events.
protected
fixMissingCaledarTopics(mixed $events) : void
Parameters
- $events : mixed
fixMissingCategories()
Callback to give a home to boards that have no category.
protected
fixMissingCategories(mixed $cats) : void
Parameters
- $cats : mixed
fixMissingLogBoards()
Callback to remove log_boards entries for non-existent boards.
protected
fixMissingLogBoards(mixed $boards) : void
Parameters
- $boards : mixed
fixMissingLogBoardsMembers()
Callback to remove log_boards entries for non-existent members.
protected
fixMissingLogBoardsMembers(mixed $members) : void
Parameters
- $members : mixed
fixMissingLogMarkRead()
Callback to remove log_mark_read entries for non-existent boards.
protected
fixMissingLogMarkRead(mixed $boards) : void
Parameters
- $boards : mixed
fixMissingLogMarkReadMembers()
Callback to remove log_mark_read entries for non-existent members.
protected
fixMissingLogMarkReadMembers(mixed $members) : void
Parameters
- $members : mixed
fixMissingLogPollVote()
Callback to remove poll votes made in non-existent polls.
protected
fixMissingLogPollVote(mixed $polls) : void
Parameters
- $polls : mixed
fixMissingLogTopics()
Callback to remove log_topics entries for non-existent topics.
protected
fixMissingLogTopics(mixed $topics) : void
Parameters
- $topics : mixed
fixMissingLogTopicsMembers()
Callback to remove log_topics entries for non-existent members.
protected
fixMissingLogTopicsMembers(mixed $members) : void
Parameters
- $members : mixed
fixMissingMemberVote()
Callback to remove poll votes made by non-existent members.
protected
fixMissingMemberVote(mixed $members) : void
Parameters
- $members : mixed
fixMissingMessages()
Callback to remove all topics that have zero messages in the messages table.
protected
fixMissingMessages(mixed $topics) : void
Parameters
- $topics : mixed
fixMissingNotifyMembers()
Callback to remove log_notify entries for non-existent members.
protected
fixMissingNotifyMembers(mixed $members) : void
Parameters
- $members : mixed
fixMissingParents()
Callback to let our salvage board adopt orphaned child boards.
protected
fixMissingParents(mixed $parents) : void
Parameters
- $parents : mixed
fixMissingPMs()
Callback to remove non-existent personal messages from the recipients' inboxes.
protected
fixMissingPMs(mixed $pms) : void
Parameters
- $pms : mixed
fixMissingPollOptions()
Callback to fix missing poll options.
protected
fixMissingPollOptions(mixed $row) : void
Parameters
- $row : mixed
fixMissingPolls()
Callback to remove non-existent polls from topics.
protected
fixMissingPolls(mixed $polls) : void
Parameters
- $polls : mixed
fixMissingPollTopics()
Callback to fix polls that have no topic.
protected
fixMissingPollTopics(mixed $row) : void
Parameters
- $row : mixed
fixMissingPosters()
Callback to give an author to messages that don't have one.
protected
fixMissingPosters(mixed $msgs) : void
Parameters
- $msgs : mixed
fixMissingRecipients()
Callback to remove non-existent recipients from personal messages.
protected
fixMissingRecipients(mixed $members) : void
Parameters
- $members : mixed
fixMissingSenders()
Callback to fix the assigned authorship of PMs from non-existent senders.
protected
fixMissingSenders(mixed $guestMessages) : void
Specifically, such PMs will be shown to have been sent from a guest.
Parameters
- $guestMessages : mixed
fixMissingTopicForCache()
Callback to remove log_search_subjects entries for non-existent topics.
protected
fixMissingTopicForCache(mixed $deleteTopics) : void
Parameters
- $deleteTopics : mixed
fixMissingTopics()
Callback to fix missing topics.
protected
fixMissingTopics(mixed $row) : void
Parameters
- $row : mixed
fixReportMissingComments()
Callback to remove non-existent comments from reports.
protected
fixReportMissingComments(mixed $reports) : void
Parameters
- $reports : mixed
fixTopicStats()
Callback to fix missing first and last message IDs for a topic.
protected
fixTopicStats(mixed $row) : bool
Parameters
- $row : mixed
Return values
boolfixTopicStats2()
Callback to fix the recorded number of replies to a topic.
protected
fixTopicStats2(mixed $row) : bool
Parameters
- $row : mixed
Return values
boolfixTopicStats3()
Callback to fix the recorded number of unapproved replies to a topic.
protected
fixTopicStats3(mixed $row) : void
Parameters
- $row : mixed
missingCachedSubjectMessage()
Callback to get a message about missing log_search_subjects entries for a topic.
protected
missingCachedSubjectMessage(mixed $row) : bool
Parameters
- $row : mixed
Return values
boolpauseRepairProcess()
Shows the not_done template to avoid CGI timeouts and similar.
protected
pauseRepairProcess(array<string|int, mixed> $to_fix, string $current_step_description[, int $max_substep = 0 ][, bool $force = false ]) : void
Called when 3 or more seconds have passed while searching for errors.
Parameters
- $to_fix : array<string|int, mixed>
-
An array of information about what to fix.
- $current_step_description : string
-
Description of the current step.
- $max_substep : int = 0
-
The maximum substep to reach before pausing.
- $force : bool = false
-
Whether to force pausing even if we don't need to.
topicStatsMessage()
Callback to get a message about missing first and last message IDs for a topic.
protected
topicStatsMessage(mixed $row) : bool
Parameters
- $row : mixed
Return values
booltopicStatsMessage2()
Callback to get a message about an incorrect record of the number of replies to a topic.
protected
topicStatsMessage2(mixed $row) : bool
Parameters
- $row : mixed