[2.0.x][2.1]Minor bug - Undefined POST in Stats.php causes undefined errors.

Started by nend, January 28, 2016, 10:46:52 PM

Previous topic - Next topic

nend

index.php?action=stats;xml

SMF 2.1 beta 2
Themes/default/Xml.template.php (stats sub template - eval?)
Line: 229


SMF 2.0.11
The database value you're trying to insert does not exist: year
Function: getDailyStatsApply Filter: Only show the errors from this file File: Sources/Stats.php
Line: 652


function DisplayStats()
{
global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc;

isAllowedTo('view_stats');

if (!empty($_REQUEST['expand']))
{
$context['robot_no_index'] = true;

$month = (int) substr($_REQUEST['expand'], 4);
$year = (int) substr($_REQUEST['expand'], 0, 4);
if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12)
$_SESSION['expanded_stats'][$year][] = $month;
}
elseif (!empty($_REQUEST['collapse']))
{
$context['robot_no_index'] = true;

$month = (int) substr($_REQUEST['collapse'], 4);
$year = (int) substr($_REQUEST['collapse'], 0, 4);
if (!empty($_SESSION['expanded_stats'][$year]))
$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
}

// Handle the XMLHttpRequest.
if (isset($_REQUEST['xml']))
{
// Collapsing stats only needs adjustments of the session variables.
if (!empty($_REQUEST['collapse']))
obExit(false);

$context['sub_template'] = 'stats';
getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month));
$context['yearly'][$year]['months'][$month]['date'] = array(
'month' => sprintf('%02d', $month),
'year' => $year,
);
return;
}

This portion of code is almost the same in each version, the function that is called getDailyStats starts varying from there, but both throw errors.

As you can see I am not supplying it with the stuff it wants, xml request is set but it isn't sending any data for $year or $month. So when the sub-template loads you get a invalid argument foreach and a undefined error for year.  ;)

Kindred

Hmmmm... As far as I can tell, this has never happened to me with a default installation
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


Kindred

well, would you look at that......


wow...   either than was introduced or I have never actually hit that page, because I have honestly never seen it do that before.
(I was posting from my phone before, so I didn't get to test it specifically then....)

was sure I had used that link before, but, seeing as I never saw that error, I guess not.

seems like a valid bug.  :-\
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Suki

Thank you for your report, it appears it has been already reported: https://github.com/SimpleMachines/SMF2.1/issues/3066 but the fix provided was incomplete. will check on it further.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: