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
0ab9095c
Unverified
Commit
0ab9095c
authored
Jan 07, 2018
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When trying to insert an empty date for users or chats, use the current timestamp.
parent
6357e95a
Changes
2
Hide 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 @
0ab9095c
...
...
@@ -11,6 +11,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Fixed
-
Entity relations and wrong types for payments.
-
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
## [0.51.0] - 2017-12-05
...
...
src/DB.php
View file @
0ab9095c
...
...
@@ -260,17 +260,13 @@ class DB
/**
* 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
*/
protected
static
function
getTimestamp
(
$time
=
null
)
{
if
(
$time
===
null
)
{
$time
=
time
();
}
return
date
(
'Y-m-d H:i:s'
,
$time
);
return
date
(
'Y-m-d H:i:s'
,
$time
?:
time
());
}
/**
...
...
@@ -362,7 +358,7 @@ class DB
* @return bool If the insert was successful
* @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
())
{
return
false
;
...
...
@@ -389,6 +385,7 @@ class DB
$sth
->
bindValue
(
':first_name'
,
$user
->
getFirstName
());
$sth
->
bindValue
(
':last_name'
,
$user
->
getLastName
());
$sth
->
bindValue
(
':language_code'
,
$user
->
getLanguageCode
());
$date
=
$date
?:
self
::
getTimestamp
();
$sth
->
bindValue
(
':created_at'
,
$date
);
$sth
->
bindValue
(
':updated_at'
,
$date
);
...
...
@@ -429,7 +426,7 @@ class DB
* @return bool If the insert was successful
* @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
())
{
return
false
;
...
...
@@ -466,6 +463,7 @@ class DB
$sth
->
bindValue
(
':title'
,
$chat
->
getTitle
());
$sth
->
bindValue
(
':username'
,
$chat
->
getUsername
());
$sth
->
bindValue
(
':all_members_are_administrators'
,
$chat
->
getAllMembersAreAdministrators
(),
PDO
::
PARAM_INT
);
$date
=
$date
?:
self
::
getTimestamp
();
$sth
->
bindValue
(
':created_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