1
1
Fork 0

Merge pull request #1131 from fabrixxm/master

Bug fixes!
This commit is contained in:
Tobias Diekershoff 2014-09-07 17:52:52 +02:00
commit e767e2d750
9 changed files with 196 additions and 158 deletions

View file

@ -11,6 +11,9 @@ require_once('include/cache.php');
require_once('library/Mobile_Detect/Mobile_Detect.php'); require_once('library/Mobile_Detect/Mobile_Detect.php');
require_once('include/features.php'); require_once('include/features.php');
require_once('update.php');
require_once('include/dbstructure.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.2.1754' ); define ( 'FRIENDICA_VERSION', '3.2.1754' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
@ -1003,7 +1006,6 @@ if(! function_exists('check_url')) {
if(! function_exists('update_db')) { if(! function_exists('update_db')) {
function update_db(&$a) { function update_db(&$a) {
$build = get_config('system','build'); $build = get_config('system','build');
if(! x($build)) if(! x($build))
$build = set_config('system','build',DB_UPDATE_VERSION); $build = set_config('system','build',DB_UPDATE_VERSION);
@ -1011,21 +1013,17 @@ if(! function_exists('update_db')) {
if($build != DB_UPDATE_VERSION) { if($build != DB_UPDATE_VERSION) {
$stored = intval($build); $stored = intval($build);
$current = intval(DB_UPDATE_VERSION); $current = intval(DB_UPDATE_VERSION);
if(($stored < $current) && file_exists('update.php')) { if($stored < $current) {
load_config('database'); load_config('database');
// We're reporting a different version than what is currently installed. // We're reporting a different version than what is currently installed.
// Run any existing update scripts to bring the database up to current. // 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 // 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 // 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. // file may not be here yet. This can happen on a very busy site.
if(DB_UPDATE_VERSION == UPDATE_VERSION) { if(DB_UPDATE_VERSION == UPDATE_VERSION) {
// Compare the current structure with the defined structure // Compare the current structure with the defined structure
$t = get_config('database','dbupdate_'.DB_UPDATE_VERSION); $t = get_config('database','dbupdate_'.DB_UPDATE_VERSION);
@ -1034,19 +1032,42 @@ if(! function_exists('update_db')) {
set_config('database','dbupdate_'.DB_UPDATE_VERSION, time()); 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); $retval = update_structure(false, true);
if($retval) { if($retval) {
update_fail( update_fail(
DB_UPDATE_VERSION, DB_UPDATE_VERSION,
sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION) $retval
); );
break; return;
} else { } else {
set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success'); set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success');
} }
// run any left update_nnnn functions in update.php
for($x = $stored; $x < $current; $x ++) { for($x = $stored; $x < $current; $x ++) {
$r = run_update_function($x);
if (!$r) break;
}
}
}
}
return;
}
}
if(!function_exists('run_update_function')){
function run_update_function($x) {
if(function_exists('update_' . $x)) { if(function_exists('update_' . $x)) {
// There could be a lot of processes running or about to run. // There could be a lot of processes running or about to run.
@ -1059,34 +1080,32 @@ if(! function_exists('update_db')) {
$t = get_config('database','update_' . $x); $t = get_config('database','update_' . $x);
if($t !== false) if($t !== false)
break; return false;
set_config('database','update_' . $x, time()); set_config('database','update_' . $x, time());
// call the specific update // call the specific update
$func = 'update_' . $x; $func = 'update_' . $x;
$retval = $func(); $retval = $func();
if($retval) { if($retval) {
//send the administrator an e-mail //send the administrator an e-mail
update_fail( update_fail(
$x, $x,
sprintf(t('Update %s failed. See error logs.'), $x) sprintf(t('Update %s failed. See error logs.'), $x)
); );
break; return false;
} else { } else {
set_config('database','update_' . $x, 'success'); set_config('database','update_' . $x, 'success');
set_config('system','build', $x + 1); set_config('system','build', $x + 1);
return true;
} }
} else { } else {
set_config('database','update_' . $x, 'success'); set_config('database','update_' . $x, 'success');
set_config('system','build', $x + 1); set_config('system','build', $x + 1);
return true;
} }
} return true;
}
}
}
return;
} }
} }

View file

@ -57,6 +57,7 @@ class Emailer {
); );
logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG); logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG);
return $res;
} }
} }
?> ?>

View file

@ -1,10 +1,15 @@
<?php <?php
# if PDO is avaible for mysql, use the new database abstraction # if PDO is avaible for mysql, use the new database abstraction
# TODO: PDO is disabled for release 3.3. We need to investigate why
# the update from 3.2 fails with pdo
/*
if(class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) { if(class_exists('\PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
require_once("library/dddbl2/dddbl.php"); require_once("library/dddbl2/dddbl.php");
require_once("include/dba_pdo.php"); require_once("include/dba_pdo.php");
} }
*/
require_once('include/datetime.php'); require_once('include/datetime.php');

View file

@ -1,6 +1,9 @@
<?php <?php
require_once("boot.php"); require_once("boot.php");
require_once("include/text.php"); require_once("include/text.php");
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/* /*
* send the email and do what is needed to do on update fails * send the email and do what is needed to do on update fails
* *
@ -62,27 +65,6 @@ function update_fail($update_id, $error_message){
break; break;
} }
function dbstructure_run(&$argv, &$argc) {
global $a, $db;
if(is_null($a)){
$a = new App;
}
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
update_structure(true, true);
}
if (array_search(__file__,get_included_files())===0){
dbstructure_run($argv,$argc);
killme();
}
function table_structure($table) { function table_structure($table) {
$structures = q("DESCRIBE `%s`", $table); $structures = q("DESCRIBE `%s`", $table);
@ -1334,3 +1316,29 @@ function db_definition() {
return($database); return($database);
} }
/*
* run from command line
*/
function dbstructure_run(&$argv, &$argc) {
global $a, $db;
if(is_null($a)){
$a = new App;
}
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
update_structure(true, true);
}
if (array_search(__file__,get_included_files())===0){
dbstructure_run($argv,$argc);
killme();
}

View file

@ -595,7 +595,7 @@ function notification($params) {
// use the Emailer class to send the message // use the Emailer class to send the message
Emailer::send(array( return Emailer::send(array(
'fromName' => $sender_name, 'fromName' => $sender_name,
'fromEmail' => $sender_email, 'fromEmail' => $sender_email,
'replyTo' => $sender_email, 'replyTo' => $sender_email,
@ -605,7 +605,6 @@ function notification($params) {
'textVersion' => $email_text_body, 'textVersion' => $email_text_body,
'additionalMailHeader' => $datarray['headers'], 'additionalMailHeader' => $datarray['headers'],
)); ));
return True;
} }
return False; return False;

View file

@ -623,6 +623,9 @@ function fetch_xrd_links($url) {
if(! function_exists('validate_url')) { if(! function_exists('validate_url')) {
function validate_url(&$url) { function validate_url(&$url) {
if(get_config('system','disable_url_validation'))
return true;
// no naked subdomains (allow localhost for tests) // no naked subdomains (allow localhost for tests)
if(strpos($url,'.') === false && strpos($url,'/localhost/') === false) if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
return false; return false;

View file

@ -382,7 +382,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor
The login details are as follows: The login details are as follows:
Site Location: %3$s Site Location: %3$s
Login Name: %1$s Login Name: %1$s
Password: %5$ Password: %5$s
You may change your password from your account "Settings" page after logging You may change your password from your account "Settings" page after logging
in. in.
@ -407,7 +407,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor
$preamble = sprintf($preamble, $username, $sitename); $preamble = sprintf($preamble, $username, $sitename);
$body = sprintf($body, $email, $sitename, $siteurl, $username, $password); $body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
notification(array( return notification(array(
'type' => "SYSTEM_EMAIL", 'type' => "SYSTEM_EMAIL",
'to_email' => $email, 'to_email' => $email,
'subject'=> sprintf( t('Registration details for %s'), $sitename), 'subject'=> sprintf( t('Registration details for %s'), $sitename),

View file

@ -81,20 +81,25 @@ function register_post(&$a) {
set_pconfig($user['uid'],'system','invites_remaining',$num_invites); set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
} }
send_register_open_eml( $res = send_register_open_eml(
$user['email'], $user['email'],
$a->config['sitename'], $a->config['sitename'],
$a->get_baseurl(), $a->get_baseurl(),
$user['username'], $user['username'],
$result['password']); $result['password']);
if($res) { if($res) {
info( t('Registration successful. Please check your email for further instructions.') . EOL ) ; info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
goaway(z_root()); goaway(z_root());
} }
else { 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:<br> login: %s<br> password: %s<br><br>You can change your password after login.'),
$user['email'],
$result['password']
). EOL
);
} }
} }
elseif($a->config['register_policy'] == REGISTER_APPROVE) { elseif($a->config['register_policy'] == REGISTER_APPROVE) {

View file

@ -1448,11 +1448,9 @@ function update_1162() {
function update_1163() { function update_1163() {
set_config('system', 'maintenance', 1); set_config('system', 'maintenance', 1);
$r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL, $r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL");
ADD INDEX (`network`)");
set_config('system', 'maintenance', 0); set_config('system', 'maintenance', 0);
if(!$r) if(!$r)
return UPDATE_FAILED; return UPDATE_FAILED;