From 6db73c0b6d2373a555bd098ab7ed0c941d5a072b Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sun, 7 Sep 2014 17:28:38 +0200 Subject: [PATCH 1/2] fix update routine to support update from 3.2 disable PDO support --- boot.php | 105 +++++++++++++++++++++++---------------- include/dba.php | 33 +++++++------ include/dbstructure.php | 52 +++++++++++--------- include/network.php | 41 +++++++++------- update.php | 106 ++++++++++++++++++++-------------------- 5 files changed, 185 insertions(+), 152 deletions(-) diff --git a/boot.php b/boot.php index 3c3ca1264..e552ee3e0 100644 --- a/boot.php +++ b/boot.php @@ -11,6 +11,9 @@ require_once('include/cache.php'); require_once('library/Mobile_Detect/Mobile_Detect.php'); require_once('include/features.php'); +require_once('update.php'); +require_once('include/dbstructure.php'); + define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '3.2.1753' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); @@ -1003,7 +1006,6 @@ if(! function_exists('check_url')) { if(! function_exists('update_db')) { function update_db(&$a) { - $build = get_config('system','build'); if(! x($build)) $build = set_config('system','build',DB_UPDATE_VERSION); @@ -1011,21 +1013,17 @@ if(! function_exists('update_db')) { if($build != DB_UPDATE_VERSION) { $stored = intval($build); $current = intval(DB_UPDATE_VERSION); - if(($stored < $current) && file_exists('update.php')) { - + if($stored < $current) { load_config('database'); // We're reporting a different version than what is currently installed. // Run any existing update scripts to bring the database up to current. - require_once('update.php'); - // make sure that boot.php and update.php are the same release, we might be // updating right this very second and the correct version of the update.php // file may not be here yet. This can happen on a very busy site. if(DB_UPDATE_VERSION == UPDATE_VERSION) { - // Compare the current structure with the defined structure $t = get_config('database','dbupdate_'.DB_UPDATE_VERSION); @@ -1034,53 +1032,32 @@ if(! function_exists('update_db')) { set_config('database','dbupdate_'.DB_UPDATE_VERSION, time()); - require_once("include/dbstructure.php"); + // run old update routine (wich could modify the schema and + // conflits with new routine) + for ($x = $stored; $x < NEW_UPDATE_ROUTINE_VERSION; $x++) { + $r = run_update_function($x); + if (!$r) break; + } + if ($stored < NEW_UPDATE_ROUTINE_VERSION) $stored = NEW_UPDATE_ROUTINE_VERSION; + + + // run new update routine + // it update the structure in one call $retval = update_structure(false, true); if($retval) { update_fail( DB_UPDATE_VERSION, - sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION) + $retval ); - break; + return; } else { set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success'); } + // run any left update_nnnn functions in update.php for($x = $stored; $x < $current; $x ++) { - if(function_exists('update_' . $x)) { - - // There could be a lot of processes running or about to run. - // We want exactly one process to run the update command. - // So store the fact that we're taking responsibility - // after first checking to see if somebody else already has. - - // If the update fails or times-out completely you may need to - // delete the config entry to try again. - - $t = get_config('database','update_' . $x); - if($t !== false) - break; - set_config('database','update_' . $x, time()); - - // call the specific update - - $func = 'update_' . $x; - $retval = $func(); - if($retval) { - //send the administrator an e-mail - update_fail( - $x, - sprintf(t('Update %s failed. See error logs.'), $x) - ); - break; - } else { - set_config('database','update_' . $x, 'success'); - set_config('system','build', $x + 1); - } - } else { - set_config('database','update_' . $x, 'success'); - set_config('system','build', $x + 1); - } + $r = run_update_function($x); + if (!$r) break; } } } @@ -1089,6 +1066,48 @@ if(! function_exists('update_db')) { return; } } +if(!function_exists('run_update_function')){ + function run_update_function($x) { + if(function_exists('update_' . $x)) { + + // There could be a lot of processes running or about to run. + // We want exactly one process to run the update command. + // So store the fact that we're taking responsibility + // after first checking to see if somebody else already has. + + // If the update fails or times-out completely you may need to + // delete the config entry to try again. + + $t = get_config('database','update_' . $x); + if($t !== false) + return false; + set_config('database','update_' . $x, time()); + + // call the specific update + + $func = 'update_' . $x; + $retval = $func(); + + if($retval) { + //send the administrator an e-mail + update_fail( + $x, + sprintf(t('Update %s failed. See error logs.'), $x) + ); + return false; + } else { + set_config('database','update_' . $x, 'success'); + set_config('system','build', $x + 1); + return true; + } + } else { + set_config('database','update_' . $x, 'success'); + set_config('system','build', $x + 1); + return true; + } + return true; + } +} if(! function_exists('check_plugins')) { diff --git a/include/dba.php b/include/dba.php index 7409ec3a8..c66723033 100644 --- a/include/dba.php +++ b/include/dba.php @@ -1,10 +1,15 @@ db) + if ($this->db) if($this->mysqli) $this->db->close(); else @@ -245,14 +250,14 @@ function printable($s) { }} // Procedural functions -if(! function_exists('dbg')) { +if(! function_exists('dbg')) { function dbg($state) { global $db; if($db) $db->dbg($state); }} -if(! function_exists('dbesc')) { +if(! function_exists('dbesc')) { function dbesc($str) { global $db; if($db && $db->connected) @@ -268,7 +273,7 @@ function dbesc($str) { // Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d", // 'user', 1); -if(! function_exists('q')) { +if(! function_exists('q')) { function q($sql) { global $db; @@ -285,12 +290,12 @@ function q($sql) { /** * - * This will happen occasionally trying to store the - * session data after abnormal program termination + * This will happen occasionally trying to store the + * session data after abnormal program termination * */ logger('dba: no database: ' . print_r($args,true)); - return false; + return false; }} @@ -300,7 +305,7 @@ function q($sql) { * */ -if(! function_exists('dbq')) { +if(! function_exists('dbq')) { function dbq($sql) { global $db; @@ -312,10 +317,10 @@ function dbq($sql) { }} -// Caller is responsible for ensuring that any integer arguments to +// Caller is responsible for ensuring that any integer arguments to // dbesc_array are actually integers and not malformed strings containing -// SQL injection vectors. All integer array elements should be specifically -// cast to int to avoid trouble. +// SQL injection vectors. All integer array elements should be specifically +// cast to int to avoid trouble. if(! function_exists('dbesc_array_cb')) { diff --git a/include/dbstructure.php b/include/dbstructure.php index 010f86218..75623c01c 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1,6 +1,9 @@ variable -// of $st and an optional text of $message and terminates the current process. +// Outputs a basic dfrn XML status structure to STDOUT, with a variable +// of $st and an optional text of $message and terminates the current process. if(! function_exists('xml_status')) { function xml_status($st, $message = '') { @@ -246,7 +246,7 @@ function http_status_exit($val) { if($val >= 200 && $val < 300) $err = 'OK'; - logger('http_status_exit ' . $val); + logger('http_status_exit ' . $val); header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err); killme(); @@ -298,16 +298,16 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) { } }} -// Given an email style address, perform webfinger lookup and +// Given an email style address, perform webfinger lookup and // return the resulting DFRN profile URL, or if no DFRN profile URL -// is located, returns an OStatus subscription template (prefixed +// is located, returns an OStatus subscription template (prefixed // with the string 'stat:' to identify it as on OStatus template). // If this isn't an email style address just return $s. // Return an empty string if email-style addresses but webfinger fails, -// or if the resultant personal XRD doesn't contain a supported +// or if the resultant personal XRD doesn't contain a supported // subscription/friend-request attribute. -// amended 7/9/2011 to return an hcard which could save potentially loading +// amended 7/9/2011 to return an hcard which could save potentially loading // a lengthy content page to scrape dfrn attributes if(! function_exists('webfinger_dfrn')) { @@ -332,7 +332,7 @@ function webfinger_dfrn($s,&$hcard) { return $profile_link; }} -// Given an email style address, perform webfinger lookup and +// Given an email style address, perform webfinger lookup and // return the array of link attributes from the personal XRD file. // On error/failure return an empty array. @@ -374,7 +374,7 @@ function lrdd($uri, $debug = false) { // All we have is an email address. Resource-priority is irrelevant // because our URI isn't directly resolvable. - if(strstr($uri,'@')) { + if(strstr($uri,'@')) { return(webfinger($uri)); } @@ -418,7 +418,7 @@ function lrdd($uri, $debug = false) { foreach($properties as $prop) if((string) $prop['@attributes'] === 'http://lrdd.net/priority/resource') $priority = 'resource'; - } + } // save the links in case we need them @@ -449,7 +449,7 @@ function lrdd($uri, $debug = false) { $tpl = ''; if($priority === 'host') { - if(strlen($tpl)) + if(strlen($tpl)) $pxrd = str_replace('{uri}', urlencode($uri), $tpl); elseif(isset($href)) $pxrd = $href; @@ -623,6 +623,9 @@ function fetch_xrd_links($url) { if(! function_exists('validate_url')) { function validate_url(&$url) { + + if(get_config('system','disable_url_validation')) + return true; // no naked subdomains (allow localhost for tests) if(strpos($url,'.') === false && strpos($url,'/localhost/') === false) return false; @@ -688,7 +691,7 @@ function allowed_url($url) { foreach($allowed as $a) { $pat = strtolower(trim($a)); if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) { - $found = true; + $found = true; break; } } @@ -722,7 +725,7 @@ function allowed_email($email) { foreach($allowed as $a) { $pat = strtolower(trim($a)); if(($fnmatch && fnmatch($pat,$domain)) || ($pat == $domain)) { - $found = true; + $found = true; break; } } @@ -888,7 +891,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace = $new_height = $ph->getHeight(); logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG); $s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]' - . "\n" . (($include_link) + . "\n" . (($include_link) ? '[url=' . $mtch[1] . ']' . t('view full size') . '[/url]' . "\n" : ''),$s); logger('scale_external_images: new string: ' . $s, LOGGER_DEBUG); @@ -928,8 +931,8 @@ function fix_contact_ssl_policy(&$contact,$new_policy) { } if($ssl_changed) { - q("update contact set - url = '%s', + q("update contact set + url = '%s', request = '%s', notify = '%s', poll = '%s', @@ -984,7 +987,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority = return array(); } - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); // http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); diff --git a/update.php b/update.php index 0ac59db95..0d4863a3f 100644 --- a/update.php +++ b/update.php @@ -48,13 +48,13 @@ function update_1000() { q("ALTER TABLE `intro` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `knowyou` "); q("ALTER TABLE `contact` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rel` "); - q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); + q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `avatar-date`"); } function update_1001() { q("ALTER TABLE `item` ADD `wall` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `type` "); - q("ALTER TABLE `item` ADD INDEX ( `wall` )"); + q("ALTER TABLE `item` ADD INDEX ( `wall` )"); } function update_1002() { @@ -65,7 +65,7 @@ function update_1003() { q("ALTER TABLE `contact` DROP `issued-pubkey` , DROP `ret-id` , DROP `ret-pubkey` "); q("ALTER TABLE `contact` ADD `usehub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `ret-aes`"); q("ALTER TABLE `contact` ADD `hub-verify` CHAR( 255 ) NOT NULL AFTER `usehub`"); - q("ALTER TABLE `contact` ADD INDEX ( `uid` ) , ADD INDEX ( `self` ), ADD INDEX ( `issued-id` ), ADD INDEX ( `dfrn-id` )"); + q("ALTER TABLE `contact` ADD INDEX ( `uid` ) , ADD INDEX ( `self` ), ADD INDEX ( `issued-id` ), ADD INDEX ( `dfrn-id` )"); q("ALTER TABLE `contact` ADD INDEX ( `blocked` ), ADD INDEX ( `readonly` )"); } @@ -104,7 +104,7 @@ function update_1006() { function update_1007() { q("ALTER TABLE `user` ADD `page-flags` INT NOT NULL DEFAULT '0' AFTER `notify-flags`"); - q("ALTER TABLE `user` ADD INDEX ( `nickname` )"); + q("ALTER TABLE `user` ADD INDEX ( `nickname` )"); } function update_1008() { @@ -137,9 +137,9 @@ function update_1012() { } function update_1013() { - q("ALTER TABLE `item` ADD `target-type` CHAR( 255 ) NOT NULL + q("ALTER TABLE `item` ADD `target-type` CHAR( 255 ) NOT NULL AFTER `object` , ADD `target` TEXT NOT NULL AFTER `target-type`"); -} +} function update_1014() { require_once('include/Photo.php'); @@ -156,7 +156,7 @@ function update_1014() { } $r = q("SELECT * FROM `contact` WHERE 1"); if(count($r)) { - foreach($r as $rr) { + foreach($r as $rr) { if(stristr($rr['thumb'],'avatar')) q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d", dbesc(str_replace('avatar','micro',$rr['thumb'])), @@ -269,7 +269,7 @@ function update_1027() { `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` CHAR( 255 ) NOT NULL , `version` CHAR( 255 ) NOT NULL , - `installed` TINYINT( 1 ) NOT NULL DEFAULT '0' + `installed` TINYINT( 1 ) NOT NULL DEFAULT '0' ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "); } @@ -319,7 +319,7 @@ function update_1031() { } } } - + function update_1032() { q("ALTER TABLE `profile` ADD `pdesc` CHAR( 255 ) NOT NULL AFTER `name` "); } @@ -335,11 +335,11 @@ function update_1033() { function update_1034() { - // If you have any of these parent-less posts they can cause problems, and + // If you have any of these parent-less posts they can cause problems, and // we need to delete them. You can't see them anyway. - // Legitimate items will usually get re-created on the next + // Legitimate items will usually get re-created on the next // pull from the hub. - // But don't get rid of a post that may have just come in + // But don't get rid of a post that may have just come in // and may not yet have the parent id set. q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE"); @@ -557,7 +557,7 @@ function update_1068() { `url` CHAR( 255 ) NOT NULL , `photo` CHAR( 255 ) NOT NULL , `note` TEXT NOT NULL , - `created` DATETIME NOT NULL + `created` DATETIME NOT NULL ) ENGINE = MYISAM DEFAULT CHARSET=utf8"); } @@ -633,7 +633,7 @@ function update_1076() { } // There was a typo in 1076 so we'll try again in 1077 to make sure -// We'll also make it big enough to allow for future growth, I seriously +// We'll also make it big enough to allow for future growth, I seriously // doubt Diaspora will be able to leave guids at 16 bytes, // and we can also use the same structure for our own larger guids @@ -641,7 +641,7 @@ function update_1077() { q("CREATE TABLE IF NOT EXISTS `guid` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `guid` CHAR( 16 ) NOT NULL , INDEX ( `guid` ) ) ENGINE = MYISAM "); - q("ALTER TABLE `guid` CHANGE `guid` `guid` CHAR( 64 ) NOT NULL"); + q("ALTER TABLE `guid` CHANGE `guid` `guid` CHAR( 64 ) NOT NULL"); } function update_1078() { @@ -667,7 +667,7 @@ function update_1079() { ADD `network` CHAR( 32 ) NOT NULL , ADD `alias` CHAR( 255 ) NOT NULL , ADD `pubkey` TEXT NOT NULL , - ADD INDEX ( `addr` ) , + ADD INDEX ( `addr` ) , ADD INDEX ( `network` ) "); } @@ -802,24 +802,24 @@ function update_1096() { } function update_1097() { - q("ALTER TABLE `queue` - ADD INDEX (`cid`), - ADD INDEX (`created`), - ADD INDEX (`last`), - ADD INDEX (`network`), - ADD INDEX (`batch`) + q("ALTER TABLE `queue` + ADD INDEX (`cid`), + ADD INDEX (`created`), + ADD INDEX (`last`), + ADD INDEX (`network`), + ADD INDEX (`batch`) "); } function update_1098() { - q("ALTER TABLE `contact` - ADD INDEX (`network`), - ADD INDEX (`name`), - ADD INDEX (`nick`), - ADD INDEX (`attag`), + q("ALTER TABLE `contact` + ADD INDEX (`network`), + ADD INDEX (`name`), + ADD INDEX (`nick`), + ADD INDEX (`attag`), ADD INDEX (`url`), - ADD INDEX (`addr`), - ADD INDEX (`batch`) + ADD INDEX (`addr`), + ADD INDEX (`batch`) "); } @@ -843,7 +843,7 @@ function update_1099() { q("ALTER TABLE `gcontact` ADD INDEX (`nurl`) "); q("ALTER TABLE `glink` ADD INDEX (`cid`), ADD INDEX (`uid`), ADD INDEX (`gcid`), ADD INDEX (`updated`) "); - q("ALTER TABLE `contact` ADD `poco` TEXT NOT NULL AFTER `confirm` "); + q("ALTER TABLE `contact` ADD `poco` TEXT NOT NULL AFTER `confirm` "); } @@ -859,7 +859,7 @@ function update_1100() { q("update contact set nurl = '%s' where id = %d", dbesc(normalise_link($rr['url'])), intval($rr['id']) - ); + ); } } } @@ -876,18 +876,18 @@ function update_1101() { } function update_1102() { - q("ALTER TABLE `clients` ADD `name` TEXT NULL DEFAULT NULL AFTER `redirect_uri` "); - q("ALTER TABLE `clients` ADD `icon` TEXT NULL DEFAULT NULL AFTER `name` "); - q("ALTER TABLE `clients` ADD `uid` INT NOT NULL DEFAULT 0 AFTER `icon` "); + q("ALTER TABLE `clients` ADD `name` TEXT NULL DEFAULT NULL AFTER `redirect_uri` "); + q("ALTER TABLE `clients` ADD `icon` TEXT NULL DEFAULT NULL AFTER `name` "); + q("ALTER TABLE `clients` ADD `uid` INT NOT NULL DEFAULT 0 AFTER `icon` "); - q("ALTER TABLE `tokens` ADD `secret` TEXT NOT NULL AFTER `id` "); - q("ALTER TABLE `tokens` ADD `uid` INT NOT NULL AFTER `scope` "); + q("ALTER TABLE `tokens` ADD `secret` TEXT NOT NULL AFTER `id` "); + q("ALTER TABLE `tokens` ADD `uid` INT NOT NULL AFTER `scope` "); } function update_1103() { // q("ALTER TABLE `item` ADD INDEX ( `wall` ) "); - q("ALTER TABLE `item` ADD FULLTEXT ( `tag` ) "); + q("ALTER TABLE `item` ADD FULLTEXT ( `tag` ) "); q("ALTER TABLE `contact` ADD INDEX ( `pending` ) "); q("ALTER TABLE `user` ADD INDEX ( `hidewall` ) "); q("ALTER TABLE `user` ADD INDEX ( `blockwall` ) "); @@ -924,7 +924,7 @@ function update_1107() { } -function update_1108() { +function update_1108() { q("ALTER TABLE `contact` ADD `hidden` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `writable` , ADD INDEX ( `hidden` ) "); @@ -993,8 +993,8 @@ INDEX ( `stat` ) } function update_1115() { - q("ALTER TABLE `item` ADD `moderated` - TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `pubmail`, + q("ALTER TABLE `item` ADD `moderated` + TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `pubmail`, ADD INDEX (`moderated`) "); } @@ -1149,16 +1149,16 @@ function update_1134() { } function update_1135() { - //there can't be indexes with more than 1000 bytes in mysql, + //there can't be indexes with more than 1000 bytes in mysql, //so change charset to be smaller q("ALTER TABLE `config` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL , -CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL"); - +CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL"); + //same thing for pconfig q("ALTER TABLE `pconfig` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL , - CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL"); + CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL"); // faulty update merged forward. Bad update in 1134 caused duplicate k,cat pairs - // these have to be cleared before the unique keys can be added. + // these have to be cleared before the unique keys can be added. } function update_1136() { @@ -1184,7 +1184,7 @@ function update_1136() { } } } - + $arr = array(); $r = q("select * from pconfig where 1 order by id desc"); if(count($r)) { @@ -1203,8 +1203,8 @@ function update_1136() { } } } - q("ALTER TABLE `config` ADD UNIQUE `access` ( `cat` , `k` ) "); - q("ALTER TABLE `pconfig` ADD UNIQUE `access` ( `uid` , `cat` , `k` )"); + q("ALTER TABLE `config` ADD UNIQUE `access` ( `cat` , `k` ) "); + q("ALTER TABLE `pconfig` ADD UNIQUE `access` ( `uid` , `cat` , `k` )"); } @@ -1278,7 +1278,7 @@ function update_1146() { function update_1147() { $r1 = q("ALTER TABLE `sign` ALTER `iid` SET DEFAULT '0'"); $r2 = q("ALTER TABLE `sign` ADD `retract_iid` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `iid`"); - $r3 = q("ALTER TABLE `sign` ADD INDEX ( `retract_iid` )"); + $r3 = q("ALTER TABLE `sign` ADD INDEX ( `retract_iid` )"); if((! $r1) || (! $r2) || (! $r3)) return UPDATE_FAILED ; return UPDATE_SUCCESS ; @@ -1327,7 +1327,7 @@ function update_1152() { `otype` TINYINT( 3 ) UNSIGNED NOT NULL , `type` TINYINT( 3 ) UNSIGNED NOT NULL , `term` CHAR( 255 ) NOT NULL , - `url` CHAR( 255 ) NOT NULL, + `url` CHAR( 255 ) NOT NULL, KEY `oid` ( `oid` ), KEY `otype` ( `otype` ), KEY `type` ( `type` ), @@ -1340,7 +1340,7 @@ function update_1152() { function update_1153() { $r = q("ALTER TABLE `hook` ADD `priority` INT(11) UNSIGNED NOT NULL DEFAULT '0'"); - + if(!$r) return UPDATE_FAILED; return UPDATE_SUCCESS; } @@ -1448,11 +1448,9 @@ function update_1162() { function update_1163() { set_config('system', 'maintenance', 1); - $r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL, - ADD INDEX (`network`)"); + $r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL"); set_config('system', 'maintenance', 0); - if(!$r) return UPDATE_FAILED; From 3ac5e4508b2c11f04acabbeb50bdbabcc904ec5e Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sun, 7 Sep 2014 17:46:31 +0200 Subject: [PATCH 2/2] fix email to new registerd users. fix notification in case of error sending email. --- include/Emailer.php | 1 + include/enotify.php | 3 +-- include/user.php | 4 ++-- mod/register.php | 11 ++++++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/Emailer.php b/include/Emailer.php index 2baa27980..535a05428 100644 --- a/include/Emailer.php +++ b/include/Emailer.php @@ -57,6 +57,7 @@ class Emailer { ); logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG); + return $res; } } ?> diff --git a/include/enotify.php b/include/enotify.php index 9ca9d7970..bad94597a 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -595,7 +595,7 @@ function notification($params) { // use the Emailer class to send the message - Emailer::send(array( + return Emailer::send(array( 'fromName' => $sender_name, 'fromEmail' => $sender_email, 'replyTo' => $sender_email, @@ -605,7 +605,6 @@ function notification($params) { 'textVersion' => $email_text_body, 'additionalMailHeader' => $datarray['headers'], )); - return True; } return False; diff --git a/include/user.php b/include/user.php index bf29daf1a..eccfa7a08 100644 --- a/include/user.php +++ b/include/user.php @@ -382,7 +382,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor The login details are as follows: Site Location: %3$s Login Name: %1$s - Password: %5$ + Password: %5$s You may change your password from your account "Settings" page after logging in. @@ -407,7 +407,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor $preamble = sprintf($preamble, $username, $sitename); $body = sprintf($body, $email, $sitename, $siteurl, $username, $password); - notification(array( + return notification(array( 'type' => "SYSTEM_EMAIL", 'to_email' => $email, 'subject'=> sprintf( t('Registration details for %s'), $sitename), diff --git a/mod/register.php b/mod/register.php index eb6fda737..4ad84ecd6 100644 --- a/mod/register.php +++ b/mod/register.php @@ -81,20 +81,25 @@ function register_post(&$a) { set_pconfig($user['uid'],'system','invites_remaining',$num_invites); } - send_register_open_eml( + $res = send_register_open_eml( $user['email'], $a->config['sitename'], $a->get_baseurl(), $user['username'], $result['password']); - if($res) { info( t('Registration successful. Please check your email for further instructions.') . EOL ) ; goaway(z_root()); } else { - notice( t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL ); + notice( + sprintf( + t('Failed to send email message. Here your accout details:
login: %s
password: %s

You can change your password after login.'), + $user['email'], + $result['password'] + ). EOL + ); } } elseif($a->config['register_policy'] == REGISTER_APPROVE) {