ping.php performance: improve documentation and formatting
This commit is contained in:
parent
cc4363c5c6
commit
bc407080d2
3 changed files with 40 additions and 25 deletions
|
@ -2,7 +2,7 @@ Table notify
|
||||||
============
|
============
|
||||||
|
|
||||||
| Field | Description | Type | Null | Key | Default | Extra |
|
| Field | Description | Type | Null | Key | Default | Extra |
|
||||||
| ------ | --------------------------------- | ------------ | ---- | --- | ------------------- | --------------- |
|
| ---------- | --------------------------------- | ------------ | ---- | --- | ------------------- | --------------- |
|
||||||
| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment |
|
| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment |
|
||||||
| hash | | varchar(64) | NO | | | |
|
| hash | | varchar(64) | NO | | | |
|
||||||
| type | | int(11) | NO | | 0 | |
|
| type | | int(11) | NO | | 0 | |
|
||||||
|
@ -10,13 +10,15 @@ Table notify
|
||||||
| url | | varchar(255) | NO | | | |
|
| url | | varchar(255) | NO | | | |
|
||||||
| photo | | varchar(255) | NO | | | |
|
| photo | | varchar(255) | NO | | | |
|
||||||
| date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
| date | | datetime | NO | | 0000-00-00 00:00:00 | |
|
||||||
| msg | | mediumtext | NO | | NULL | |
|
| msg | | mediumtext | YES | | NULL | |
|
||||||
| uid | user.id of the owner of this data | int(11) | NO | MUL | 0 | |
|
| uid | user.id of the owner of this data | int(11) | NO | MUL | 0 | |
|
||||||
| link | | varchar(255) | NO | | | |
|
| link | | varchar(255) | NO | | | |
|
||||||
|
| iid | item.id | int(11) | NO | | 0 | |
|
||||||
| parent | | int(11) | NO | | 0 | |
|
| parent | | int(11) | NO | | 0 | |
|
||||||
| seen | | tinyint(1) | NO | | 0 | |
|
| seen | | tinyint(1) | NO | | 0 | |
|
||||||
| verb | | varchar(255) | NO | | | |
|
| verb | | varchar(255) | NO | | | |
|
||||||
| otype | | varchar(16) | NO | | | |
|
| otype | | varchar(16) | NO | | | |
|
||||||
| iid | item.id | int(11) | NO | | 0 | |
|
| name_cache | Cached bbcode parsing of name | tinytext | YES | | NULL | |
|
||||||
|
| msg_cache | Cached bbcode parsing of msg | mediumtext | YES | | NULL | |
|
||||||
|
|
||||||
Return to [database documentation](help/database)
|
Return to [database documentation](help/database)
|
||||||
|
|
|
@ -26,18 +26,30 @@ function ref_session_read ($id) {
|
||||||
return '';
|
return '';
|
||||||
}}
|
}}
|
||||||
|
|
||||||
if(! function_exists('ref_session_write')) {
|
/**
|
||||||
function ref_session_write ($id,$data) {
|
* @brief Standard PHP session write callback
|
||||||
|
*
|
||||||
|
* This callback updates the DB-stored session data and/or the expiration depending
|
||||||
|
* on the case. Uses the $session_expire global for existing session, 5 minutes
|
||||||
|
* for newly created session.
|
||||||
|
*
|
||||||
|
* @global bool $session_exists Whether a session with the given id already exists
|
||||||
|
* @global int $session_expire Session expiration delay in seconds
|
||||||
|
* @param string $id Session ID with format: [a-z0-9]{26}
|
||||||
|
* @param string $data Serialized session data
|
||||||
|
* @return boolean Returns false if parameters are missing, true otherwise
|
||||||
|
*/
|
||||||
|
function ref_session_write($id, $data) {
|
||||||
global $session_exists, $session_expire;
|
global $session_exists, $session_expire;
|
||||||
|
|
||||||
if(! $id || ! $data) {
|
if (!$id || !$data) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$expire = time() + $session_expire;
|
$expire = time() + $session_expire;
|
||||||
$default_expire = time() + 300;
|
$default_expire = time() + 300;
|
||||||
|
|
||||||
if($session_exists) {
|
if ($session_exists) {
|
||||||
$r = q("UPDATE `session`
|
$r = q("UPDATE `session`
|
||||||
SET `data` = '%s'
|
SET `data` = '%s'
|
||||||
WHERE `sid` = '%s' AND `data` != '%s'",
|
WHERE `sid` = '%s' AND `data` != '%s'",
|
||||||
|
@ -47,13 +59,14 @@ function ref_session_write ($id,$data) {
|
||||||
SET `expire` = '%s'
|
SET `expire` = '%s'
|
||||||
WHERE `sid` = '%s' AND `expire` != '%s'",
|
WHERE `sid` = '%s' AND `expire` != '%s'",
|
||||||
dbesc($expire), dbesc($expire), dbesc($id));
|
dbesc($expire), dbesc($expire), dbesc($id));
|
||||||
} else
|
} else {
|
||||||
$r = q("INSERT INTO `session`
|
$r = q("INSERT INTO `session`
|
||||||
SET `sid` = '%s', `expire` = '%s', `data` = '%s'",
|
SET `sid` = '%s', `expire` = '%s', `data` = '%s'",
|
||||||
dbesc($id), dbesc($default_expire), dbesc($data));
|
dbesc($id), dbesc($default_expire), dbesc($data));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}}
|
}
|
||||||
|
|
||||||
if(! function_exists('ref_session_close')) {
|
if(! function_exists('ref_session_close')) {
|
||||||
function ref_session_close() {
|
function ref_session_close() {
|
||||||
|
|
|
@ -347,8 +347,8 @@ function ping_init(&$a) {
|
||||||
/**
|
/**
|
||||||
* @brief Retrieves the notifications array for the given user ID
|
* @brief Retrieves the notifications array for the given user ID
|
||||||
*
|
*
|
||||||
* @param int $uid
|
* @param int $uid User id
|
||||||
* @return array
|
* @return array Associative array of notifications
|
||||||
*/
|
*/
|
||||||
function ping_get_notifications($uid) {
|
function ping_get_notifications($uid) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue