Documentation

Maintenance
in package
implements ActionInterface Uses BackwardCompatibility

Forum maintenance. Important stuff.

Table of Contents

Interfaces

ActionInterface
Interface for all action classes.

Properties

$activity  : string
$subaction  : string
$subactions  : array<string|int, mixed>
$obj  : object
$backcompat  : array<string|int, mixed>

Methods

adminBoardRecount()  : void
Backward compatibility wrapper for the recount activity.
call()  : void
Convenience method to load() and execute() an instance of this class.
changeMsgBodyLength()  : void
Convert the column "body" of the table {db_prefix}messages from TEXT to MEDIUMTEXT and vice versa.
cleanCache()  : void
Wipes the whole cache.
convertEntities()  : void
Backward compatibility wrapper for the convertentities activity.
convertMsgBody()  : void
Backward compatibility wrapper for the convertmsgbody activity.
database()  : void
Supporting function for the database maintenance area.
destroy()  : void
Oh noes! I'd document this but that would give it away.
emptyLogs()  : void
Empties all uninmportant logs
entitiesToUnicode()  : void
Converts HTML-entities to their UTF-8 character equivalents.
execute()  : void
Dispatcher to whichever sub-action method is necessary.
exportStatic()  : void
Provides a way to export a class's public static properties and methods to global namespace.
getIntegrationHooksData()  : array<string|int, mixed>
Callback function for the integration hooks list (list_integration_hooks) Gets all of the hooks in the system and their status
hooks()  : void
Generates a list of integration hooks for display Accessed through ?action=admin;area=maintain;sa=hooks; Allows for removal or disabling of selected hooks
list_integration_hooks()  : void
Backward compatibility wrapper for the hooks sub-action.
load()  : object
Static wrapper for constructor.
maintainCleanCache()  : void
Backward compatibility wrapper for the cleancache activity.
maintainDatabase()  : void
Backward compatibility wrapper for the database sub-action.
maintainEmptyUnimportantLogs()  : void
Backward compatibility wrapper for the logs activity.
maintainFindFixErrors()  : void
Backward compatibility wrapper for the repair activity.
maintainMassMoveTopics()  : void
Backward compatibility wrapper for the massmove activity.
maintainMembers()  : void
Backward compatibility wrapper for the members sub-action.
maintainPurgeInactiveMembers()  : void
Backward compatibility wrapper for the purgeinactive activity.
maintainReattributePosts()  : void
Backward compatibility wrapper for the reattribute activity.
maintainRecountPosts()  : void
Backward compatibility wrapper for the recountposts activity.
maintainRemoveOldDrafts()  : void
Backward compatibility wrapper for the olddrafts activity.
maintainRemoveOldPosts()  : void
Backward compatibility wrapper for the pruneold activity.
maintainRoutine()  : void
Backward compatibility wrapper for the routine sub-action.
maintainTopics()  : void
Backward compatibility wrapper for the topics sub-action.
massMove()  : void
Moves topics from one board to another.
members()  : void
Supporting function for the members maintenance area.
optimize()  : void
Optimizes all tables in the database and lists how much was saved.
optimizeTables()  : void
Backward compatibility wrapper for the optimize activity.
pruneDrafts()  : void
Removing old drafts
prunePosts()  : void
Removing old posts doesn't take much as we really pass through.
purgeInactiveMembers()  : void
Removing old members. Done and out!
reattribute()  : void
Re-attribute posts.
reattributePosts()  : array<string|int, mixed>
This method is used to reassociate members with relevant posts.
rebuildSettings()  : void
Rebuilds Settings.php to make it nice and pretty.
rebuildSettingsFile()  : void
Backward compatibility wrapper for the rebuild_settings activity.
recountBoards()  : void
Recount many forum totals that can be recounted automatically without harm.
recountPosts()  : void
Recalculate all members post counts it requires the admin_forum permission.
repair()  : void
Find and fix all errors on the forum.
routine()  : void
Supporting function for the routine maintenance area.
topics()  : void
Supporting function for the topics maintenance area.
version()  : void
Perform a detailed version check. A very good thing ;).
versionDetail()  : void
Backward compatibility wrapper for the version activity.
__construct()  : mixed
Constructor. Protected to force instantiation via self::load().
getDefinedFunctionsInFile()  : array<string|int, mixed>
getFileRecursive()  : array<string|int, mixed>
Gets all of the files in a directory and its children directories
getIntegrationHooks()  : array<string|int, mixed>
Parses modSettings to create integration hook array
parseIntegrationHook()  : array<string|int, mixed>
Parses each hook data and returns an array.

Properties

$activity

public string $activity

The requested activity within the sub-action. This should be set by the constructor.

$subaction

public string $subaction = 'routine'

The requested sub-action. This should be set by the constructor.

$subactions

public static array<string|int, mixed> $subactions = ['routine' => ['function' => 'routine', 'template' => 'maintain_routine', 'activities' => ['version' => 'version', 'repair' => 'repair', 'recount' => 'recountBoards', 'rebuild_settings' => 'rebuildSettings', 'logs' => 'emptyLogs', 'cleancache' => 'cleanCache']], 'database' => ['function' => 'database', 'template' => 'maintain_database', 'activities' => ['optimize' => 'optimize', 'convertentities' => 'entitiesToUnicode', 'convertmsgbody' => 'changeMsgBodyLength']], 'members' => ['function' => 'members', 'template' => 'maintain_members', 'activities' => ['reattribute' => 'reattribute', 'purgeinactive' => 'purgeInactiveMembers', 'recountposts' => 'recountPosts']], 'topics' => ['function' => 'topics', 'template' => 'maintain_topics', 'activities' => ['massmove' => 'massMove', 'pruneold' => 'prunePosts', 'olddrafts' => 'pruneDrafts']], 'hooks' => ['function' => 'hooks'], 'destroy' => ['function' => 'destroy', 'activities' => []]]

Available sub-actions.

$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' => 'ManageMaintenance', 'getIntegrationHooksData' => 'getIntegrationHooksData', 'reattributePosts' => 'reattributePosts', 'maintainRoutine' => 'MaintainRoutine', 'maintainDatabase' => 'MaintainDatabase', 'maintainMembers' => 'MaintainMembers', 'maintainTopics' => 'MaintainTopics', 'list_integration_hooks' => 'list_integration_hooks', 'versionDetail' => 'VersionDetail', 'maintainFindFixErrors' => 'MaintainFindFixErrors', 'adminBoardRecount' => 'AdminBoardRecount', 'rebuildSettingsFile' => 'RebuildSettingsFile', 'maintainEmptyUnimportantLogs' => 'MaintainEmptyUnimportantLogs', 'maintainCleanCache' => 'MaintainCleanCache', 'optimizeTables' => 'OptimizeTables', 'convertEntities' => 'ConvertEntities', 'convertMsgBody' => 'ConvertMsgBody', 'maintainReattributePosts' => 'MaintainReattributePosts', 'maintainPurgeInactiveMembers' => 'MaintainPurgeInactiveMembers', 'maintainRecountPosts' => 'MaintainRecountPosts', 'maintainMassMoveTopics' => 'MaintainMassMoveTopics', 'maintainRemoveOldPosts' => 'MaintainRemoveOldPosts', 'maintainRemoveOldDrafts' => 'MaintainRemoveOldDrafts']]

BackwardCompatibility settings for this class.

Methods

adminBoardRecount()

Backward compatibility wrapper for the recount activity.

public static adminBoardRecount() : void

call()

Convenience method to load() and execute() an instance of this class.

public static call() : void

changeMsgBodyLength()

Convert the column "body" of the table {db_prefix}messages from TEXT to MEDIUMTEXT and vice versa.

public changeMsgBodyLength() : void

It requires the admin_forum permission. This is needed only for MySQL. During the conversion from MEDIUMTEXT to TEXT it check if any of the posts exceed the TEXT length and if so it aborts. This action is linked from the maintenance screen (if it's applicable). Accessed by ?action=admin;area=maintain;sa=database;activity=convertmsgbody.

Tags
uses
template_convert_msgbody()

cleanCache()

Wipes the whole cache.

public cleanCache() : void

convertEntities()

Backward compatibility wrapper for the convertentities activity.

public static convertEntities() : void

convertMsgBody()

Backward compatibility wrapper for the convertmsgbody activity.

public static convertMsgBody() : void

database()

Supporting function for the database maintenance area.

public database() : void

destroy()

Oh noes! I'd document this but that would give it away.

public destroy() : void

emptyLogs()

Empties all uninmportant logs

public emptyLogs() : void

entitiesToUnicode()

Converts HTML-entities to their UTF-8 character equivalents.

public entitiesToUnicode() : void

This requires the admin_forum permission. Pre-condition: UTF-8 has been set as database and global character set.

It is divided in steps of 10 seconds. This action is linked from the maintenance screen (if applicable). It is accessed by ?action=admin;area=maintain;sa=database;activity=convertentities.

Tags
uses
template_convert_entities()

execute()

Dispatcher to whichever sub-action method is necessary.

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:

  1. Use this trait in the class.
  2. 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.

getIntegrationHooksData()

Callback function for the integration hooks list (list_integration_hooks) Gets all of the hooks in the system and their status

public static getIntegrationHooksData(int $start, int $per_page, string $sort, mixed $filtered_hooks, mixed $normalized_boarddir, mixed $normalized_sourcedir) : array<string|int, mixed>
Parameters
$start : int

The item to start with (for pagination purposes)

$per_page : int

How many items to display on each page

$sort : string

A string indicating how to sort things

$filtered_hooks : mixed
$normalized_boarddir : mixed
$normalized_sourcedir : mixed
Return values
array<string|int, mixed>

An array of information about the integration hooks

hooks()

Generates a list of integration hooks for display Accessed through ?action=admin;area=maintain;sa=hooks; Allows for removal or disabling of selected hooks

public hooks() : void

list_integration_hooks()

Backward compatibility wrapper for the hooks sub-action.

public static list_integration_hooks() : void

load()

Static wrapper for constructor.

public static load() : object
Return values
object

An instance of this class.

maintainCleanCache()

Backward compatibility wrapper for the cleancache activity.

public static maintainCleanCache() : void

maintainDatabase()

Backward compatibility wrapper for the database sub-action.

public static maintainDatabase() : void

maintainEmptyUnimportantLogs()

Backward compatibility wrapper for the logs activity.

public static maintainEmptyUnimportantLogs() : void

maintainFindFixErrors()

Backward compatibility wrapper for the repair activity.

public static maintainFindFixErrors() : void

maintainMassMoveTopics()

Backward compatibility wrapper for the massmove activity.

public static maintainMassMoveTopics() : void

maintainMembers()

Backward compatibility wrapper for the members sub-action.

public static maintainMembers() : void

maintainPurgeInactiveMembers()

Backward compatibility wrapper for the purgeinactive activity.

public static maintainPurgeInactiveMembers() : void

maintainReattributePosts()

Backward compatibility wrapper for the reattribute activity.

public static maintainReattributePosts() : void

maintainRecountPosts()

Backward compatibility wrapper for the recountposts activity.

public static maintainRecountPosts() : void

maintainRemoveOldDrafts()

Backward compatibility wrapper for the olddrafts activity.

public static maintainRemoveOldDrafts() : void

maintainRemoveOldPosts()

Backward compatibility wrapper for the pruneold activity.

public static maintainRemoveOldPosts() : void

maintainRoutine()

Backward compatibility wrapper for the routine sub-action.

public static maintainRoutine() : void

maintainTopics()

Backward compatibility wrapper for the topics sub-action.

public static maintainTopics() : void

massMove()

Moves topics from one board to another.

public massMove() : void
Tags
uses
template_not_done()

to pause the process.

members()

Supporting function for the members maintenance area.

public members() : void

optimize()

Optimizes all tables in the database and lists how much was saved.

public optimize() : void

It requires the admin_forum permission. It shows as the maintain_forum admin area. It is accessed from ?action=admin;area=maintain;sa=database;activity=optimize. It also updates the optimize scheduled task such that the tables are not automatically optimized again too soon.

Tags
uses
template_optimize()

optimizeTables()

Backward compatibility wrapper for the optimize activity.

public static optimizeTables() : void

pruneDrafts()

Removing old drafts

public pruneDrafts() : void

prunePosts()

Removing old posts doesn't take much as we really pass through.

public prunePosts() : void

purgeInactiveMembers()

Removing old members. Done and out!

public purgeInactiveMembers() : void
Tags
todo

refactor

reattribute()

Re-attribute posts.

public reattribute() : void

reattributePosts()

This method is used to reassociate members with relevant posts.

public static reattributePosts(int $memID[, bool|string $email = null ][, bool|string $membername = null ][, bool $post_count = false ]) : array<string|int, mixed>

Does not check for any permissions. If $post_count is set, the member's post count is increased.

Parameters
$memID : int

The ID of the original poster.

$email : bool|string = null

If set, should be the email of the poster.

$membername : bool|string = null

If set, the membername of the poster.

$post_count : bool = false

Whether to adjust post counts.

Return values
array<string|int, mixed>

The numbers of messages, topics, and reports updated.

rebuildSettings()

Rebuilds Settings.php to make it nice and pretty.

public rebuildSettings() : void

rebuildSettingsFile()

Backward compatibility wrapper for the rebuild_settings activity.

public static rebuildSettingsFile() : void

recountBoards()

Recount many forum totals that can be recounted automatically without harm.

public recountBoards() : void

it requires the admin_forum permission. It shows the maintain_forum admin area.

Totals recounted:

  • fixes for topics with wrong num_replies.
  • updates for num_posts and num_topics of all boards.
  • recounts instant_messages but not unread_messages.
  • repairs messages pointing to boards with topics pointing to other boards.
  • updates the last message posted in boards and children.
  • updates member count, latest member, topic count, and message count.

The function redirects back to ?action=admin;area=maintain when complete. It is accessed via ?action=admin;area=maintain;sa=database;activity=recount.

recountPosts()

Recalculate all members post counts it requires the admin_forum permission.

public recountPosts() : void
  • recounts all posts for members found in the message table
  • updates the members post count record in the members table
  • honors the boards post count flag
  • does not count posts in the recycle bin
  • zeros post counts for all members with no posts in the message table
  • runs as a delayed loop to avoid server overload
  • uses the not_done template in Admin.template

The function redirects back to action=admin;area=maintain;sa=members when complete. It is accessed via ?action=admin;area=maintain;sa=members;activity=recountposts

repair()

Find and fix all errors on the forum.

public repair() : void

routine()

Supporting function for the routine maintenance area.

public routine() : void

topics()

Supporting function for the topics maintenance area.

public topics() : void

version()

Perform a detailed version check. A very good thing ;).

public version() : void

The function parses the comment headers in all files for their version information, and outputs that for some javascript to check with simplemachines.org. It does not connect directly with simplemachines.org, but rather expects the client to.

It requires the admin_forum permission. Uses the view_versions admin area. Accessed through ?action=admin;area=maintain;sa=routine;activity=version.

versionDetail()

Backward compatibility wrapper for the version activity.

public static versionDetail() : void

__construct()

Constructor. Protected to force instantiation via self::load().

protected __construct() : mixed

getDefinedFunctionsInFile()

protected static getDefinedFunctionsInFile(string $file) : array<string|int, mixed>
Parameters
$file : string
Return values
array<string|int, mixed>

getFileRecursive()

Gets all of the files in a directory and its children directories

protected static getFileRecursive(string $dirname) : array<string|int, mixed>
Parameters
$dirname : string

The path to the directory

Return values
array<string|int, mixed>

An array containing information about the files found in the specified directory and its children

getIntegrationHooks()

Parses modSettings to create integration hook array

protected getIntegrationHooks() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of information about the integration hooks

parseIntegrationHook()

Parses each hook data and returns an array.

protected static parseIntegrationHook(string $hook, string $rawData) : array<string|int, mixed>
Parameters
$hook : string
$rawData : string

A string as it was saved to the DB.

Return values
array<string|int, mixed>

everything found in the string itself


        
On this page

Search results