تصحيح مفتاح Redis لموقع السائق: driver:location ← driver:public

الموضعان كانا يقرآن مفتاحاً لا يُكتب في أي مكان في المشروع:
  $redisLocation->hGetAll("driver:location:$driverId")

الكاتب الفعلي هو معالج الدفعات في loction_server/driver_socket.php، وهو
يكتب hmset على driver:profile:{id} و driver:public:{id} معاً بنفس الحقول
(lat/lng/heading/speed/status/updated_at). و driver:public له TTL 86400
بينما driver:profile له 900 فقط، فالعام هو الأنسب للقراءة.

الأثر: كانت حمولة القبول تصل الراكب بلا إحداثيات أولية للسائق، فلا يظهر
الماركر إلا بعد أول تحديث موقع من السوكيت أو الـ polling.

أحد الموضعين ملف getRideOrderID.php الذي أضفته في f66db7db — نسخت النمط
من acceptRide.php فنقلت الخطأ معه.

مثبَّت على الإنتاج: redis-cli --scan --pattern 'driver:*' أرجع
driver:public:<id> فقط، ولا شيء باسم driver:location.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hamza-Ayed
2026-07-27 01:14:26 +03:00
co-authored by Claude Opus 5
parent 0e6dd68385
commit ef1240b130
2 changed files with 9 additions and 2 deletions
+6 -1
View File
@@ -177,7 +177,12 @@ try {
if (isset($redisLocation) && $redisLocation) {
try {
$driverLoc = $redisLocation->hGetAll("driver:location:$driverId");
// ‏المفتاح الصحيح driver:public — و driver:location لا يُكتب في أي
// ‏مكان إطلاقاً فكانت القراءة ترجع فارغة دائماً، فيصل الراكب بلا
// ‏إحداثيات أولية للسائق. الكاتب driver_socket.php في معالج
// ‏الدفعات (hmset على driver:profile و driver:public معاً، بحقول
// ‏lat/lng/heading نفسها، وTTL أربعٍ وعشرين ساعة للعام).
$driverLoc = $redisLocation->hGetAll("driver:public:$driverId");
if (!empty($driverLoc)) {
$driverInfo['lat'] = (float)($driverLoc['lat'] ?? 0);
$driverInfo['lng'] = (float)($driverLoc['lng'] ?? 0);
+3 -1
View File
@@ -148,7 +148,9 @@ try {
// ── 3. آخر موقع للسائق من Redis (اختياري) ──────────────────────
if (isset($redisLocation) && $redisLocation) {
try {
$driverLoc = $redisLocation->hGetAll("driver:location:$driverId");
// ‏المفتاح driver:public هو ما يكتبه driver_socket.php فعلاً
// ‏(driver:location لا وجود له — كان خطأً منسوخاً من acceptRide.php).
$driverLoc = $redisLocation->hGetAll("driver:public:$driverId");
if (!empty($driverLoc)) {
$driverInfo['lat'] = (float)($driverLoc['lat'] ?? 0);
$driverInfo['lng'] = (float)($driverLoc['lng'] ?? 0);