Ver código fonte

fix(l2): fall back to live view for stale snapshot timestamps

clm0081 2 dias atrás
pai
commit
0b9b05caf9
1 arquivos alterados com 9 adições e 0 exclusões
  1. 9 0
      web-modules/WecomCenter/actions/L2TopologyView.php

+ 9 - 0
web-modules/WecomCenter/actions/L2TopologyView.php

@@ -32,9 +32,18 @@ class L2TopologyView extends CController {
 		$ts_raw = $_REQUEST['ts'] ?? '';
 		$ts = ($ts_raw === '' || $ts_raw === null) ? null : (int) $ts_raw;
 
+		$requested_ts = $ts;
 		$snap = L2Store::snapshotAt($ts);
 		$json = $snap['json'] ?? null;
 		$used_ts = $snap['ts'];
+		// A stale bookmark / hand-edited ?ts= must not leave an empty page.
+		// If that exact snapshot is gone, fall back to the live latest view.
+		if ($ts !== null && ($json === null || $json === '')) {
+			$ts = null;
+			$snap = L2Store::snapshotAt(null);
+			$json = $snap['json'] ?? null;
+			$used_ts = $snap['ts'];
+		}
 
 		// The selector must cover the full retention window, not only the
 		// latest 500 rows.  At 5 minutes / 7 days this is ~2,016 points.