mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-11 01:24:27 +02:00
Fix for MySQL 5.7+
https://github.com/friendica/friendica/issues/2786 Only tested on Ubuntu 16.10 with MySQL 5.7.17. https://dev.mysql.com/doc/refman/8.0/en/timestamp-initialization.html https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_no_zero_date As of MySQL 5.7.4, NO_ZERO_DATE is deprecated. Patch based on the following search & replace (and then reverting some changes in libraries): ```sh grep -l '= "0000-00-00"' -r . | xargs sed -i -e "s/= \"0000-00-00\"/= '0000-00-00'/g" grep -l "0000-00-00" -r . | xargs sed -i -e "s/0000-00-00/0001-01-01/g" grep -l "!= '0001-01-01'" -r . | xargs sed -i -e "s/!= '0001-01-01'/> '0001-01-01'/g" grep -l " === '0001-01-01'" -r . | xargs sed -i -e "s/ === '0001-01-01'/ <= '0001-01-01'/g" grep -l " == '0001-01-01'" -r . | xargs sed -i -e "s/ == '0001-01-01'/ <= '0001-01-01'/g" grep -l "strpos(\$dob, '0000-') === 0" -r . | xargs sed -i -e "s/strpos(\$dob, '0000-') === 0/strpos(\$dob, '0000-') === 0 || strpos(\$dob, '0001-') === 0/g" grep -l 'array("", "0001-01-01")' -r . | xargs sed -i -e 's/array("", "0001-01-01")/array("", "0000-00-00", "0001-01-01")/g' grep -l "\$dob = '0000-'" -r . | xargs sed -i -e "s/\$dob = '0000-'/\$dob = '0001-'/g" ```
This commit is contained in:
parent
0d2bf557de
commit
d2901dcb00
37 changed files with 139 additions and 139 deletions
|
@ -126,7 +126,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
|
|||
// add 32 days so that we at least get year 00, and then hack around the fact that
|
||||
// months and days always start with 1.
|
||||
|
||||
if(substr($s,0,10) == '0000-00-00') {
|
||||
if(substr($s,0,10) <= '0001-01-01') {
|
||||
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
|
||||
return str_replace('1','0',$d->format($fmt));
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ function dob($dob) {
|
|||
$f = get_config('system','birthday_input_format');
|
||||
if(! $f)
|
||||
$f = 'ymd';
|
||||
if($dob === '0000-00-00')
|
||||
if($dob <= '0001-01-01')
|
||||
$value = '';
|
||||
else
|
||||
$value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d'));
|
||||
|
@ -189,7 +189,7 @@ function dob($dob) {
|
|||
)
|
||||
));
|
||||
|
||||
// if ($dob && $dob != '0000-00-00')
|
||||
// if ($dob && $dob > '0001-01-01')
|
||||
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob');
|
||||
// else
|
||||
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),false,'dob');
|
||||
|
@ -553,7 +553,7 @@ function update_contact_birthdays() {
|
|||
// This only handles foreign or alien networks where a birthday has been provided.
|
||||
// In-network birthdays are handled within local_delivery
|
||||
|
||||
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
|
||||
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` > '0001-01-01' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue