Maintenance
in package
implements
ActionInterface
uses
ActionTrait, 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 : static
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- canBeLogged() : bool
- Determines whether this action can be logged in the online log.
- canShowDebuggingInfo() : bool
- Determines whether debugging info should be shown.
- canShowInMaintenanceMode() : bool
- Determines whether this action allows access in maintenance mode.
- 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.
- 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 unimportant logs
- entitiesToUnicode() : void
- Converts HTML-entities to their UTF-8 character equivalents.
- execute() : void
- Dispatcher to whichever sub-action method is necessary.
- 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
- getOutputType() : OutputTypeInterface
- Gets the output type for this action.
- 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
- isAgreementAction() : bool
- Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
- isRestrictedGuestAccessAllowed() : bool
- Determines whether this action allows access if guest access is restricted.
- isSimpleAction() : bool
- Determines whether this is a simple action.
- load() : static
- Static wrapper for constructor.
- 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.
- 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.
- 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.
- subActionProvider() : null|array<string|int, mixed>
- Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
- topics() : void
- Supporting function for the topics maintenance area.
- version() : void
- Perform a detailed version check. A very good thing ;).
- __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 static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
canBeLogged()
Determines whether this action can be logged in the online log.
public
canBeLogged() : bool
Return values
boolcanShowDebuggingInfo()
Determines whether debugging info should be shown.
public
canShowDebuggingInfo() : bool
Return values
boolcanShowInMaintenanceMode()
Determines whether this action allows access in maintenance mode.
public
canShowInMaintenanceMode() : bool
Return values
bool —True if access is allowed, false otherwise.
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
cleanCache()
Wipes the whole cache.
public
cleanCache() : 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 unimportant 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
execute()
Dispatcher to whichever sub-action method is necessary.
public
execute() : void
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, object|array<string|int, mixed> $filtered_hooks, string $normalized_boarddir, string $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 : object|array<string|int, mixed>
- $normalized_boarddir : string
- $normalized_sourcedir : string
Return values
array<string|int, mixed> —An array of information about the integration hooks
getOutputType()
Gets the output type for this action.
public
getOutputType() : OutputTypeInterface
Return values
OutputTypeInterfacehooks()
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
isAgreementAction()
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
public
isAgreementAction() : bool
Return values
boolisRestrictedGuestAccessAllowed()
Determines whether this action allows access if guest access is restricted.
public
isRestrictedGuestAccessAllowed() : bool
Return values
bool —True if access is allowed, false otherwise.
isSimpleAction()
Determines whether this is a simple action.
public
isSimpleAction() : bool
Return values
boolload()
Static wrapper for constructor.
public
static load() : static
Return values
static —An instance of this class.
massMove()
Moves topics from one board to another.
public
massMove() : void
Tags
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
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
reattribute()
Re-attribute posts.
public
reattribute() : void
reattributePosts()
This method is used to reassociate members with relevant posts.
public
static reattributePosts(int $memID[, string|null $email = null ][, string|null $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 : string|null = null
-
If set, should be the email of the poster.
- $membername : string|null = 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
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
subActionProvider()
Called by Subs-Compat.php BackwardCompatibility wrapper functions to provide subaction execution for existing mods
public
static subActionProvider([null|string $sa = null ][, bool $return_config = false ][, string|null $activity = null ]) : null|array<string|int, mixed>
Parameters
- $sa : null|string = null
- $return_config : bool = false
- $activity : string|null = null
Return values
null|array<string|int, mixed>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.
__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