I was doing maintenance on my website, and I found this error on the page; I couldn't find a place to submit this, so I posted here:

jrCharts 1.2.1 can return HTTP 500 when a chart counter is nonnumeric
Environment
- Site:
- Jamroom Core: 7.0.3
- jrCharts: 1.2.1
- Production PHP and Apache: versions unverified
- Local reproduction: PHP 8.5.12 CLI on Windows
The domain homepage returned HTTP 500 while rendering its chart. The active skin was xxxxxxx. The same code path can affect jrAudioPro2 when it requests a chart.
The PHP log reported this error in modules/jrCharts/include.php at line 271, inside jrCharts_db_search_params_listener().
TypeError: Unsupported operand types: string - intCause and reproduction
The listener calculates the chart delta with (int) ($count - $_ce[$iid]). PHP evaluates the subtraction before casting the result. The original isset() check verifies that a historical value exists, so a nonnumeric counter can still reach the subtraction.
The reproduction fixture triggers the error with a nonnumeric current counter and a numeric historical counter. The exact stored value that triggered the production error is unknown.
Code comparison
The patch validates both counters before subtraction and skips invalid rows. Numeric strings and tracks with no historical entry retain their existing behavior.
foreach ($_cb as $iid => $count) {
- if (isset($_ce[$iid])) {
+ $has_history = array_key_exists($iid, $_ce);
+ if (!is_numeric($count) || ($has_history && !is_numeric($_ce[$iid]))) {
+ // An invalid counter cannot produce a meaningful chart position.
+ unset($_ce[$iid]);
+ continue;
+ }
+ if ($has_history) {
// We have a history entry - get diff
$GLOBALS["{$_args['module']}_jrcharts_cnt"][$iid] = (int) ($count - $_ce[$iid]);
$GLOBALS["{$_args['module']}_jrcharts_old"][$iid] = $num++;Historical JSON that decodes to a value other than an array is treated as missing history.
$_ce = json_decode($_ce['chart_counts'], true);
+if (!is_array($_ce)) {
+ $_ce = array();
+}When no valid counters remain, the patch preserves the existing search filters and adds a condition that returns an empty chart.
arsort($GLOBALS["{$_args['module']}_jrcharts_cnt"], SORT_NUMERIC);
+// An empty ID list must not turn a chart into an unfiltered item list.
+if (!$GLOBALS["{$_args['module']}_jrcharts_cnt"]) {
+ $_data['search'][] = '_item_id < 0';
+ return $_data;
+}Verification
The original file reproduced the TypeError. The patched file passed PHP lint and the regression fixture. The fixture covers invalid current and historical counters, numeric strings, missing history, result limits, preserved filters, and an empty result when every counter is invalid.
After deployment, the homepage, audio listing, chart page, and chart refresh returned HTTP 200.
updated by @serveion: 11/17/26 09:00:31AM