Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
7a44511d
Unverified
Commit
7a44511d
authored
Jan 08, 2018
by
Armando Lüscher
Committed by
GitHub
Jan 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #738 from noplanman/737-fix_date_updates
Fix empty date for User and Chat entities
parents
6357e95a
0ab9095c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
CHANGELOG.md
CHANGELOG.md
+1
-0
DB.php
src/DB.php
+6
-8
No files found.
CHANGELOG.md
View file @
7a44511d
...
@@ -11,6 +11,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
...
@@ -11,6 +11,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Fixed
### Fixed
-
Entity relations and wrong types for payments.
-
Entity relations and wrong types for payments.
-
Allow empty string for
`switch_inline_query`
and
`switch_inline_query_current_chat`
(InlineKeyboardButton).
-
Allow empty string for
`switch_inline_query`
and
`switch_inline_query_current_chat`
(InlineKeyboardButton).
-
Fix empty date entry for User and Chat entities, using the current timestamp instead.
### Security
### Security
## [0.51.0] - 2017-12-05
## [0.51.0] - 2017-12-05
...
...
src/DB.php
View file @
7a44511d
...
@@ -260,17 +260,13 @@ class DB
...
@@ -260,17 +260,13 @@ class DB
/**
/**
* Convert from unix timestamp to timestamp
* Convert from unix timestamp to timestamp
*
*
* @param int $time Unix timestamp (if
null
, current timestamp is used)
* @param int $time Unix timestamp (if
empty
, current timestamp is used)
*
*
* @return string
* @return string
*/
*/
protected
static
function
getTimestamp
(
$time
=
null
)
protected
static
function
getTimestamp
(
$time
=
null
)
{
{
if
(
$time
===
null
)
{
return
date
(
'Y-m-d H:i:s'
,
$time
?:
time
());
$time
=
time
();
}
return
date
(
'Y-m-d H:i:s'
,
$time
);
}
}
/**
/**
...
@@ -362,7 +358,7 @@ class DB
...
@@ -362,7 +358,7 @@ class DB
* @return bool If the insert was successful
* @return bool If the insert was successful
* @throws TelegramException
* @throws TelegramException
*/
*/
public
static
function
insertUser
(
User
$user
,
$date
,
Chat
$chat
=
null
)
public
static
function
insertUser
(
User
$user
,
$date
=
null
,
Chat
$chat
=
null
)
{
{
if
(
!
self
::
isDbConnected
())
{
if
(
!
self
::
isDbConnected
())
{
return
false
;
return
false
;
...
@@ -389,6 +385,7 @@ class DB
...
@@ -389,6 +385,7 @@ class DB
$sth
->
bindValue
(
':first_name'
,
$user
->
getFirstName
());
$sth
->
bindValue
(
':first_name'
,
$user
->
getFirstName
());
$sth
->
bindValue
(
':last_name'
,
$user
->
getLastName
());
$sth
->
bindValue
(
':last_name'
,
$user
->
getLastName
());
$sth
->
bindValue
(
':language_code'
,
$user
->
getLanguageCode
());
$sth
->
bindValue
(
':language_code'
,
$user
->
getLanguageCode
());
$date
=
$date
?:
self
::
getTimestamp
();
$sth
->
bindValue
(
':created_at'
,
$date
);
$sth
->
bindValue
(
':created_at'
,
$date
);
$sth
->
bindValue
(
':updated_at'
,
$date
);
$sth
->
bindValue
(
':updated_at'
,
$date
);
...
@@ -429,7 +426,7 @@ class DB
...
@@ -429,7 +426,7 @@ class DB
* @return bool If the insert was successful
* @return bool If the insert was successful
* @throws TelegramException
* @throws TelegramException
*/
*/
public
static
function
insertChat
(
Chat
$chat
,
$date
,
$migrate_to_chat_id
=
null
)
public
static
function
insertChat
(
Chat
$chat
,
$date
=
null
,
$migrate_to_chat_id
=
null
)
{
{
if
(
!
self
::
isDbConnected
())
{
if
(
!
self
::
isDbConnected
())
{
return
false
;
return
false
;
...
@@ -466,6 +463,7 @@ class DB
...
@@ -466,6 +463,7 @@ class DB
$sth
->
bindValue
(
':title'
,
$chat
->
getTitle
());
$sth
->
bindValue
(
':title'
,
$chat
->
getTitle
());
$sth
->
bindValue
(
':username'
,
$chat
->
getUsername
());
$sth
->
bindValue
(
':username'
,
$chat
->
getUsername
());
$sth
->
bindValue
(
':all_members_are_administrators'
,
$chat
->
getAllMembersAreAdministrators
(),
PDO
::
PARAM_INT
);
$sth
->
bindValue
(
':all_members_are_administrators'
,
$chat
->
getAllMembersAreAdministrators
(),
PDO
::
PARAM_INT
);
$date
=
$date
?:
self
::
getTimestamp
();
$sth
->
bindValue
(
':created_at'
,
$date
);
$sth
->
bindValue
(
':created_at'
,
$date
);
$sth
->
bindValue
(
':updated_at'
,
$date
);
$sth
->
bindValue
(
':updated_at'
,
$date
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment