Managing Connections
- protected function getConnectionNamespace() — Return a namespace for this object's connections in the connection cache. Generally, the database name is appropriate. Two connections are considered equivalent if they have the same connection namespace and mode.
- protected function getEstablishedConnection($mode) — Get an existing, cached connection for this object.
- protected function setEstablishedConnection($mode, $connection, $force_unique) — Store a connection in the connection cache.
- public function setForcedConnection($connection) — Force an object to use a specific connection.
Configuring Storage
- protected function establishLiveConnection($mode)
- protected function getConfiguration()
- public function getConfigOption($option_name) — Determine the setting of a configuration option for this class of objects.
- public function getTableName()
- public static function pushStorageNamespace($namespace)
- public static function popStorageNamespace()
- public static function getDefaultStorageNamespace()
- public static function getStorageNamespace()
- public function getApplicationName()
Loading Objects
- public function load($id) — Load an object by ID. You need to invoke this as an instance method, not a class method, because PHP doesn't have late static binding (until PHP 5.3.0). For example:
- public function loadAll() — Loads all of the objects, unconditionally.
- public function loadAllWhere($pattern, ...) — Load all objects which match a WHERE clause. You provide everything after the 'WHERE'; Lisk handles everything up to it. For example:
- public function loadOneWhere($pattern, ...) — Load a single object identified by a 'WHERE' clause. You provide everything after the 'WHERE', and Lisk builds the first half of the query. See loadAllWhere(). This method is similar, but returns a single result instead of a list.
- public function reload() — Reload an object from the database, discarding any changes to persistent properties. This is primarily useful after entering a transaction but before applying changes to an object.
- public function loadFromArray($row) — Initialize this object's properties from a dictionary. Generally, you load single objects with loadOneWhere(), but sometimes it may be more convenient to pull data from elsewhere directly (e.g., a complicated join via @{method:queryData}) and then load from an array representation.
- public function loadAllFromArray($rows) — Initialize a list of objects from a list of dictionaries. Usually you load lists of objects with @{method:loadAllWhere}, but sometimes that isn't flexible enough. One case is if you need to do joins to select the right objects:
Examining Objects
- public function getID() — Retrieve the unique ID identifying this object. This value will be null if the object hasn't been persisted and you didn't set it manually.
- public function hasProperty($property) — Test if a property exists.
- protected function getAllLiskProperties() — Retrieve a list of all object properties. This list only includes properties that are declared as protected, and it is expected that all properties returned by this function should be persisted to the database. Properties that should not be persisted must be declared as private.
- protected function checkProperty($property) — Check if a property exists on this object.
- public function establishConnection($mode, $force_new) — Get or build the database connection for this object.
- protected function getAllLiskPropertyValues() — Convert this object into a property dictionary. This dictionary can be restored into an object by using @{method:loadFromArray} (unless you're using legacy features with CONFIG_CONVERT_CAMELCASE, but in that case you should just go ahead and die in a fire).
Writing Objects
- public function setID($id) — Set unique ID identifying this object. You normally don't need to call this method unless with `IDS_MANUAL`.
- public function save()
- public function replace() — Save this object, forcing the query to use REPLACE regardless of object state.
- public function insert() — Save this object, forcing the query to use INSERT regardless of object state.
- public function update() — Save this object, forcing the query to use UPDATE regardless of object state.
- public function delete() — Delete this object, permanently.
- protected function insertRecordIntoDatabase($mode) — Internal implementation of INSERT and REPLACE.
Hooks and Callbacks
- public function getIDKey() — Retrieve the primary key column, "id" by default. If you can not reasonably name your ID column "id", override this method.
- public function generatePHID()
- protected function willWriteData(&$data)
- protected function didWriteData() — Hook to perform actions after data has been written to the database.
- protected function willSaveObject() — Hook to make internal object state changes prior to INSERT, REPLACE or UPDATE.
- protected function willReadData(&$data)
- protected function didReadData() — Hook to perform an action on data after it is read from the database.
- protected function willDelete() — Hook to perform an action before the deletion of an object.
- protected function didDelete() — Hook to perform an action after the deletion of an object.
- protected function readField($field) — Reads the value from a field. Override this method for custom behavior of @{method:getField} instead of overriding getField directly.
- protected function writeField($field, $value) — Writes a value to a field. Override this method for custom behavior of setField($value) instead of overriding setField directly.
Utilities
- protected function applyLiskDataSerialization(&$data, $deserialize) — Applies configured serialization to a dictionary of values.
- public function __call($method, $args) — Black magic. Builds implied get*() and set*() for all properties.
- public function __set($name, $value) — Warns against writing to undeclared property.
- public static function loadNextCounterValue($conn_w, $counter_name) — Increments a named counter and returns the next value.
- public static function loadCurrentCounterValue($conn_r, $counter_name) — Returns the current value of a named counter.
- public static function overwriteCounterValue($conn_w, $counter_name, $counter_value) — Overwrite a named counter, forcing it to a specific value.
Managing Transactions
- public function beginReadLocking() — Begins read-locking selected rows with SELECT ... FOR UPDATE, so that other connections can not read them (this is an enormous oversimplification of FOR UPDATE semantics; consult the MySQL documentation for details). To end read locking, call @{method:endReadLocking}. For example:
- public function endReadLocking() — Ends read-locking that began at an earlier @{method:beginReadLocking} call.
- public function beginWriteLocking() — Begins write-locking selected rows with SELECT ... LOCK IN SHARE MODE, so that other connections can not update or delete them (this is an oversimplification of LOCK IN SHARE MODE semantics; consult the MySQL documentation for details). To end write locking, call @{method:endWriteLocking}.
- public function endWriteLocking() — Ends write-locking that began at an earlier @{method:beginWriteLocking} call.
Isolation for Unit Testing
- public static function beginIsolateAllLiskEffectsToCurrentProcess()
- public static function endIsolateAllLiskEffectsToCurrentProcess()
- public static function shouldIsolateAllLiskEffectsToCurrentProcess()
- private function establishIsolatedConnection($mode)
- public static function beginIsolateAllLiskEffectsToTransactions()
- public static function endIsolateAllLiskEffectsToTransactions()
- public static function shouldIsolateAllLiskEffectsToTransactions()
Managing Recipients
- public function buildRecipientList() — Get all of the recipients for this mail, after preference filters are applied. This list has all objects to whom delivery will be attempted.
Other Methods
- public function __construct()
- protected function getDatabaseName()
- protected function loadRawDataWhere($pattern)
- public function getPHID()
- public function makeEphemeral() — Make an object read-only.
- private function isEphemeralCheck()
- protected function shouldInsertWhenSaved() — Method used to determine whether to insert or update when saving.
- public function getPHIDType()
- public function openTransaction() — Increase transaction stack depth.
- public function saveTransaction() — Decrease transaction stack depth, saving work.
- public function killTransaction() — Decrease transaction stack depth, discarding work.
- public static function closeInactiveConnections($idle_window) — Close any connections with no recent activity.
- public static function closeAllConnections()
- public static function closeIdleConnections()
- private static function closeConnection($key)
- private function getBinaryColumns()
- public function getSchemaColumns()
- public function getSchemaKeys()
- public function getColumnMaximumByteLength($column)
- public function getSchemaPersistence()
- public function getAphrontRefDatabaseName()
- public function getAphrontRefTableName()
- private function getLiskMetadata($key, $default)
- private function setLiskMetadata($key, $value)
- public function setForcedStorageNamespace($namespace)
- private function newClusterConnection($application, $database, $mode)
- private function raiseImproperWrite($database)
- private function raiseImpossibleWrite($database)
- private function raiseUnconfigured($database)
- private function raiseUnreachable($database, $proxy)
- public static function chunkSQL($fragments, $limit) — Break a list of escaped SQL statement fragments (e.g., VALUES lists for INSERT, previously built with @{function:qsprintf}) into chunks which will fit under the MySQL 'max_allowed_packet' limit.
- protected function assertAttached($property)
- protected function assertAttachedKey($value, $key)
- protected function detectEncodingForStorage($string)
- protected function getUTF8StringFromStorage($string, $encoding)
- protected function setParam($param, $value)
- protected function getParam($param, $default)
- public function setMailTags($tags) — These tags are used to allow users to opt out of receiving certain types of mail, like updates when a task's projects change.
- public function getMailTags()
- public function setParentMessageID($id) — In Gmail, conversations will be broken if you reply to a thread and the server sends back a response without referencing your Message-ID, even if it references a Message-ID earlier in the thread. To avoid this, use the parent email's message ID explicitly if it's available. This overwrites the "In-Reply-To" and "References" headers we would otherwise generate. This needs to be set whenever an action is triggered by an email message. See T251 for more details.
- public function getParentMessageID()
- public function getSubject()
- public function addTos($phids)
- public function addRawTos($raw_email)
- public function addCCs($phids)
- public function setExcludeMailRecipientPHIDs($exclude)
- private function getExcludeMailRecipientPHIDs()
- public function setMutedPHIDs($muted)
- private function getMutedPHIDs()
- public function setForceHeraldMailRecipientPHIDs($force)
- private function getForceHeraldMailRecipientPHIDs()
- public function addPHIDHeaders($name, $phids)
- public function addHeader($name, $value)
- public function getHeaders()
- public function addAttachment($attachment)
- public function getAttachments()
- public function getAttachmentFilePHIDs()
- public function loadAttachedFiles($viewer)
- public function setAttachments($attachments)
- public function setFrom($from)
- public function getFrom()
- public function setRawFrom($raw_email, $raw_name)
- public function getRawFrom()
- public function setReplyTo($reply_to)
- public function getReplyTo()
- public function setSubject($subject)
- public function setSubjectPrefix($prefix)
- public function getSubjectPrefix()
- public function setVarySubjectPrefix($prefix)
- public function getVarySubjectPrefix()
- public function setBody($body)
- public function setSensitiveContent($bool)
- public function hasSensitiveContent()
- public function setMustEncrypt($bool)
- public function getMustEncrypt()
- public function setMustEncryptURI($uri)
- public function getMustEncryptURI()
- public function setMustEncryptSubject($subject)
- public function getMustEncryptSubject()
- public function setMustEncryptReasons($reasons)
- public function getMustEncryptReasons()
- public function setMailStamps($stamps)
- public function getMailStamps()
- public function setMailStampMetadata($metadata)
- public function getMailStampMetadata()
- public function getMailerKey()
- public function setTryMailers($mailers)
- public function setHTMLBody($html)
- public function getBody()
- public function getHTMLBody()
- public function setIsErrorEmail($is_error)
- public function getIsErrorEmail()
- public function getToPHIDs()
- public function getRawToAddresses()
- public function getCcPHIDs()
- public function setMessageType($message_type)
- public function getMessageType()
- public function setForceDelivery($force) — Force delivery of a message, even if recipients have preferences which would otherwise drop the message.
- public function getForceDelivery()
- public function setIsBulk($is_bulk) — Flag that this is an auto-generated bulk message and should have bulk headers added to it if appropriate. Broadly, this means some flavor of "Precedence: bulk" or similar, but is implementation and configuration dependent.
- public function getIsBulk()
- public function setThreadID($thread_id, $is_first_message) — Use this method to set an ID used for message threading. MetaMTA will set appropriate headers (Message-ID, In-Reply-To, References and Thread-Index) based on the capabilities of the underlying mailer.
- public function getThreadID()
- public function getIsFirstMessage()
- public function saveAndSend() — Save a newly created mail to the database. The mail will eventually be delivered by the MetaMTA daemon.
- public function sendNow() — Attempt to deliver an email immediately, in this process.
- public static function newMailers($constraints)
- public function sendWithMailers($mailers)
- public static function shouldMailEachRecipient()
- public function loadAllActors()
- public function getExpandedRecipientPHIDs()
- private function getAllActorPHIDs()
- public function expandRecipients($phids) — Expand a list of recipient PHIDs (possibly including aggregate recipients like projects) into a deaggregated list of individual recipient PHIDs. For example, this will expand project PHIDs into a list of the project's members.
- private function filterDeliverableActors($actors)
- private function loadActors($actor_phids)
- public function getDeliveredHeaders()
- public function setDeliveredHeaders($headers)
- public function getUnfilteredHeaders()
- public function setUnfilteredHeaders($headers)
- private function flattenHeaders($headers)
- public function getDeliveredActors()
- public function getDeliveredRoutingRules()
- public function getDeliveredRoutingMap()
- public function getDeliveredBody()
- public function setDeliveredBody($body)
- public function getURI()
- public function addRoutingRule($routing_rule, $phids, $reason_phid)
- private function getRoutingRule($phid)
- private function getRoutingRuleMap()
- private function loadPreferences($target_phid)
- public function shouldRenderMailStampsInBody($viewer)
- public function getCapabilities()
- public function getPolicy($capability)
- public function hasAutomaticCapability($capability, $viewer)
- public function describeAutomaticCapability($capability)
- public function destroyObjectPermanently($engine)