Browse files

Fix invalid-string-format date passing to MySQL.

This fixes a lot of instances where we were passing
incorrectly-formatted string representations of date/time values in
prepared queries.  This is an issue now that MySQL 5.5 is picky about
receiving properly-formatted strings.

Thanks to Daniel K for finding another pattern to search for direct
binding of string-formatted dates.

Refs #8585.
(backports 3d42de5 from master)
  • Loading branch information...
1 parent 4bba807 commit 8b9e5ce0d92721396144fe0014ab4b90cde5152b @sphery sphery committed Aug 26, 2011
View
4 mythtv/libs/libmythtv/recordinginfo.cpp
@@ -236,7 +236,7 @@ RecordingInfo::RecordingInfo(
" program.starttime < :STARTTS1 AND "
" program.endtime > :STARTTS2 ";
bindings[":CHANID"] = QString::number(_chanid);
- QString str_startts = desiredts.toString("yyyy-MM-ddThh:mm:50");
+ QString str_startts = desiredts.toString("yyyy-MM-dd hh:mm:50");
bindings[":STARTTS1"] = str_startts;
bindings[":STARTTS2"] = str_startts;
@@ -332,7 +332,7 @@ RecordingInfo::RecordingInfo(
" program.starttime > :STARTTS "
"GROUP BY program.starttime ORDER BY program.starttime LIMIT 1 ";
bindings[":CHANID"] = QString::number(_chanid);
- bindings[":STARTTS"] = desiredts.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":STARTTS"] = desiredts.toString("yyyy-MM-dd hh:mm:50");
LoadFromProgram(progList, querystr, bindings, schedList, false);
View
8 mythtv/libs/libmythtv/tvbrowsehelper.cpp
@@ -315,10 +315,10 @@ void TVBrowseHelper::GetNextProgramDB(
MSqlBindings bindings;
bindings[":CHANID"] = chanid;
- bindings[":NOWTS"] = nowtime.toString("yyyy-MM-ddThh:mm:ss");
- bindings[":LATESTTS"] = latesttime.toString("yyyy-MM-ddThh:mm:ss");
- bindings[":BROWSETS"] = browsetime.toString("yyyy-MM-ddThh:mm:ss");
- bindings[":BROWSETS2"] = browsetime.toString("yyyy-MM-ddThh:mm:ss");
+ bindings[":NOWTS"] = nowtime;
+ bindings[":LATESTTS"] = latesttime;
+ bindings[":BROWSETS"] = browsetime;
+ bindings[":BROWSETS2"] = browsetime;
QString querystr = " WHERE program.chanid = :CHANID ";
switch (direction)
View
8 mythtv/programs/mythfrontend/guidegrid.cpp
@@ -673,8 +673,8 @@ ProgramList GuideGrid::GetProgramList(uint chanid) const
" program.endtime >= :STARTTS AND "
" program.starttime <= :ENDTS AND "
" program.manualid = 0 ";
- bindings[":STARTTS"] = m_currentStartTime.toString("yyyy-MM-ddThh:mm:00");
- bindings[":ENDTS"] = m_currentEndTime.toString("yyyy-MM-ddThh:mm:00");
+ bindings[":STARTTS"] = m_currentStartTime.toString("yyyy-MM-dd hh:mm:00");
+ bindings[":ENDTS"] = m_currentEndTime.toString("yyyy-MM-dd hh:mm:00");
bindings[":CHANID"] = chanid;
ProgramList dummy;
@@ -1039,8 +1039,8 @@ ProgramList *GuideGrid::getProgramListFromProgram(int chanNum)
" AND program.starttime <= :ENDTS "
" AND program.manualid = 0 ";
bindings[":CHANID"] = GetChannelInfo(chanNum)->chanid;
- bindings[":STARTTS"] = m_currentStartTime.toString("yyyy-MM-ddThh:mm:00");
- bindings[":ENDTS"] = m_currentEndTime.toString("yyyy-MM-ddThh:mm:00");
+ bindings[":STARTTS"] = m_currentStartTime.toString("yyyy-MM-dd hh:mm:00");
+ bindings[":ENDTS"] = m_currentEndTime.toString("yyyy-MM-dd hh:mm:00");
LoadFromProgram(*proglist, querystr, bindings, m_recList, false);
}
View
14 mythtv/programs/mythfrontend/progfind.cpp
@@ -570,7 +570,7 @@ void ProgFinder::selectShowData(QString progTitle, int newCurShow)
" AND program.endtime > :ENDTIME "
" AND channel.visible = 1 ";
bindings[":TITLE"] = progTitle;
- bindings[":ENDTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":ENDTIME"] = progStart.toString("yyyy-MM-dd hh:mm:50");
LoadFromScheduler(m_schedList);
LoadFromProgram(m_showData, querystr, bindings, m_schedList, false);
@@ -619,7 +619,7 @@ void ProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindings
where += "ORDER BY title;";
- bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":STARTTIME"] = progStart.toString("yyyy-MM-dd hh:mm:50");
}
else
{
@@ -644,7 +644,7 @@ void ProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindings
bindings[":TWO"] = two;
bindings[":THREE"] = three;
bindings[":FOUR"] = four;
- bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":STARTTIME"] = progStart.toString("yyyy-MM-dd hh:mm:50");
if (!m_searchStr.isEmpty())
bindings[":SEARCH"] = '%' + m_searchStr + '%';
@@ -839,7 +839,7 @@ void JaProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindin
where += "ORDER BY title_pronounce;";
- bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":STARTTIME"] = progStart.toString("yyyy-MM-dd hh:mm:50");
}
@@ -925,7 +925,7 @@ void HeProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings &bindin
where += "ORDER BY title;";
- bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":STARTTIME"] = progStart.toString("yyyy-MM-dd hh:mm:50");
}
bool HeProgFinder::formatSelectedData(QString& data)
@@ -1007,7 +1007,7 @@ void RuProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings
where += "ORDER BY title;";
- bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":STARTTIME"] = progStart.toString("yyyy-MM-dd hh:mm:50");
}
else
{
@@ -1035,7 +1035,7 @@ void RuProgFinder::whereClauseGetSearchData(QString &where, MSqlBindings
bindings[":THREE"] = three;
bindings[":FOUR"] = four;
bindings[":FIVE"] = five;
- bindings[":STARTTIME"] = progStart.toString("yyyy-MM-ddThh:mm:50");
+ bindings[":STARTTIME"] = progStart.toString("yyyy-MM-dd hh:mm:50");
if (!m_searchStr.isEmpty())
bindings[":SEARCH"] = '%' + m_searchStr + '%';
View
4 mythtv/programs/mythfrontend/proglist.cpp
@@ -811,7 +811,7 @@ void ProgLister::FillViewList(const QString &view)
}
else if (m_type == plCategory) // list by category
{
- QString startstr = m_startTime.toString("yyyy-MM-ddThh:mm:50");
+ QString startstr = m_startTime.toString("yyyy-MM-dd hh:mm:50");
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("SELECT g1.genre, g2.genre "
"FROM program "
@@ -1144,7 +1144,7 @@ void ProgLister::FillItemList(bool restorePosition, bool updateDisp)
bool oneChanid = false;
QString where;
- QString startstr = m_startTime.toString("yyyy-MM-ddThh:mm:50");
+ QString startstr = m_startTime.toString("yyyy-MM-dd hh:mm:50");
QString qphrase = m_viewList[m_curView];
MSqlBindings bindings;

0 comments on commit 8b9e5ce

Please sign in to comment.