PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | app/Services/ExportImportService.php +34 -65 3.0.2.7 → 3.0.16 View file →
@@ -4,10 +4,15 @@
4 4
5 5 namespace Yatra\Services;
6 6
7 7 use Yatra\Constants\ClassificationTypes;
8 +use Yatra\Database\Tables\BookingsTable;
9 +use Yatra\Database\Tables\ClassificationsTable;
10 +use Yatra\Database\Tables\DiscountsTable;
11 +use Yatra\Database\Tables\TripItineraryDayEntryTable;
12 +use Yatra\Database\Tables\TripItineraryDaysTable;
13 +use Yatra\Repositories\ExportImportRepository;
8 14 use Yatra\Utils\Logger;
9 -use Yatra\Repositories\ExportImportRepository;
10 15
11 16 /**
12 17 * Export/Import Service
13 18 *
@@ -23,31 +28,29 @@
23 28 private const JOB_OPTION_PREFIX = 'yatra_job_';
24 29 private const BATCH_SIZE = 500;
25 30
26 31 /**
27 - * Unprefixed physical table names (Yatra 3.x uses yatra_new_* — not legacy yatra_trips, etc.).
32 + * Unprefixed physical table names (Yatra 3.x uses yatra_* — not legacy yatra_trips, etc.).
28 33 *
29 34 * @var array<string, string>
30 35 */
31 36 private const TABLE_SUFFIX_MAP = [
32 - 'trips' => 'yatra_new_trips',
33 - 'bookings' => 'yatra_new_bookings',
34 - 'customers' => 'yatra_new_customers',
35 - 'reviews' => 'yatra_new_reviews',
36 - 'payments' => 'yatra_new_booking_payments',
37 - 'enquiries' => 'yatra_new_enquiries',
38 - 'discounts' => 'yatra_new_discounts',
39 - 'travelers' => 'yatra_new_booking_travellers',
40 - 'traveler_meta' => 'yatra_new_booking_traveller_meta',
41 - 'availability' => 'yatra_new_trip_availability_dates',
42 - 'availability_rules' => 'yatra_new_trip_availability_rules',
43 - 'departures' => 'yatra_new_trip_departures',
44 - 'booking_departures' => 'yatra_new_booking_departures',
45 - 'trip_classifications' => 'yatra_new_trip_classifications',
46 - 'trip_content' => 'yatra_new_trip_content',
47 - 'trip_revisions' => 'yatra_new_trip_revisions',
48 - 'scheduled_payments' => 'yatra_new_scheduled_payments',
49 - 'payment_tokens' => 'yatra_new_payment_tokens',
37 + 'trips' => 'yatra_trips',
38 + 'bookings' => 'yatra_bookings',
39 + 'customers' => 'yatra_customers',
40 + 'reviews' => 'yatra_reviews',
41 + 'payments' => 'yatra_booking_payments',
42 + 'enquiries' => 'yatra_enquiries',
43 + 'discounts' => 'yatra_discounts',
44 + 'travelers' => 'yatra_booking_travellers',
45 + 'traveler_meta' => 'yatra_booking_traveller_meta',
46 + 'availability' => 'yatra_trip_availability_dates',
47 + 'availability_rules' => 'yatra_trip_availability_rules',
48 + 'departures' => 'yatra_trip_departures',
49 + 'booking_departures' => 'yatra_booking_departures',
50 + 'trip_classifications' => 'yatra_trip_classifications',
51 + 'trip_content' => 'yatra_trip_content',
52 + 'trip_revisions' => 'yatra_trip_revisions',
50 53 ];
51 54
52 55 /**
53 56 * Free core map + optional suffixes from Yatra Pro (or other add-ons) via
@@ -316,10 +319,10 @@
316 319 continue;
317 320 }
318 321
319 322 if ($dataType === 'itinerary') {
320 - $daysTable = $wpdb->prefix . 'yatra_new_trip_itinerary_days';
321 - $entriesTable = $wpdb->prefix . 'yatra_new_trip_itinerary_day_entry';
323 + $daysTable = TripItineraryDaysTable::getTableName();
324 + $entriesTable = TripItineraryDayEntryTable::getTableName();
322 325 $allDays = [];
323 326 $allEntries = [];
324 327
325 328 if ($repository->tableExists($daysTable)) {
@@ -358,9 +361,9 @@
358 361 }
359 362
360 363 $classType = self::classificationTypeForDataType($dataType);
361 364 if ($classType !== null) {
362 - $tableName = $wpdb->prefix . 'yatra_new_classifications';
365 + $tableName = ClassificationsTable::getTableName();
363 366 if (!$repository->tableExists($tableName)) {
364 367 $exportData['data'][$dataType] = [];
365 368 continue;
366 369 }
@@ -604,10 +607,10 @@
604 607 if (!isset($payload['days'], $payload['entries']) || !is_array($payload['days']) || !is_array($payload['entries'])) {
605 608 Logger::warning('Skipping itinerary: expected { days, entries } from Yatra 3 export; legacy flat arrays are not supported');
606 609 continue;
607 610 }
608 - $daysTable = $wpdb->prefix . 'yatra_new_trip_itinerary_days';
609 - $entriesTable = $wpdb->prefix . 'yatra_new_trip_itinerary_day_entry';
611 + $daysTable = TripItineraryDaysTable::getTableName();
612 + $entriesTable = TripItineraryDayEntryTable::getTableName();
610 613 $dayTotal = count($payload['days']);
611 614 $entryTotal = count($payload['entries']);
612 615 $importStats['itinerary'] = [
613 616 'total' => $dayTotal + $entryTotal,
@@ -726,9 +729,9 @@
726 729
727 730 $mergedMap = self::getMergedTableMap();
728 731 $classType = self::classificationTypeForDataType($dataType);
729 732 if ($classType !== null) {
730 - $tableName = $wpdb->prefix . 'yatra_new_classifications';
733 + $tableName = ClassificationsTable::getTableName();
731 734 } elseif (isset($mergedMap[$dataType])) {
732 735 $tableName = $wpdb->prefix . $mergedMap[$dataType];
733 736 } else {
734 737 Logger::warning("Skipping unknown import data type: {$dataType}");
@@ -942,12 +945,8 @@
942 945 case 'bookings':
943 946 return 'bookings';
944 947 case 'payments':
945 948 return 'payments';
946 - case 'payment_tokens':
947 - return 'payment_tokens';
948 - case 'scheduled_payments':
949 - return 'scheduled_payments';
950 949 case 'availability':
951 950 return 'availability';
952 951 case 'departures':
953 952 return 'departures';
@@ -1012,14 +1011,10 @@
1012 1011 case 'traveler_meta':
1013 1012 return empty($row['traveller_id'] ?? null);
1014 1013 case 'booking_additional_services':
1015 1014 return empty($row['booking_id'] ?? null) || empty($row['service_id'] ?? null);
1016 - case 'payment_tokens':
1017 - return empty($row['customer_id'] ?? null);
1018 1015 case 'bookings':
1019 1016 return empty($row['trip_id'] ?? null);
1020 - case 'scheduled_payments':
1021 - return empty($row['booking_id'] ?? null);
1022 1017 case 'reviews':
1023 1018 return empty($row['trip_id'] ?? null);
1024 1019 default:
1025 1020 return false;
@@ -1066,13 +1061,8 @@
1066 1061 if (isset($row['service_id'])) {
1067 1062 $row['service_id'] = $m->map('services', $row['service_id']);
1068 1063 }
1069 1064 break;
1070 - case 'payment_tokens':
1071 - if (isset($row['customer_id'])) {
1072 - $row['customer_id'] = $m->map('customers', $row['customer_id']);
1073 - }
1074 - break;
1075 1065 case 'bookings':
1076 1066 if (isset($row['trip_id'])) {
1077 1067 $row['trip_id'] = $m->map('trips', $row['trip_id']);
1078 1068 }
@@ -1116,19 +1106,8 @@
1116 1106 if (array_key_exists('customer_id', $row)) {
1117 1107 $row['customer_id'] = $m->mapFkNullable('customers', $row['customer_id']);
1118 1108 }
1119 1109 break;
1120 - case 'scheduled_payments':
1121 - if (isset($row['booking_id'])) {
1122 - $row['booking_id'] = $m->map('bookings', $row['booking_id']);
1123 - }
1124 - if (array_key_exists('customer_id', $row)) {
1125 - $row['customer_id'] = $m->mapFkNullable('customers', $row['customer_id']);
1126 - }
1127 - if (array_key_exists('payment_token_id', $row)) {
1128 - $row['payment_token_id'] = $m->mapFkNullable('payment_tokens', $row['payment_token_id']);
1129 - }
1130 - break;
1131 1110 case 'google_calendar_events':
1132 1111 if (isset($row['booking_id']) && (int) $row['booking_id'] !== 0) {
1133 1112 $mapped = $m->map('bookings', $row['booking_id']);
1134 1113 $row['booking_id'] = $mapped ?? 0;
@@ -1323,9 +1302,9 @@
1323 1302
1324 1303 private static function ensureUniqueDiscountCode(string $code): string
1325 1304 {
1326 1305 global $wpdb;
1327 - $table = $wpdb->prefix . 'yatra_new_discounts';
1306 + $table = DiscountsTable::getTableName();
1328 1307 $base = $code;
1329 1308 $candidate = $base;
1330 1309 for ($n = 0; $n < 5000; $n++) {
1331 1310 $exists = (int) $wpdb->get_var(
@@ -1345,9 +1324,9 @@
1345 1324
1346 1325 private static function ensureUniqueBookingReference(string $reference): string
1347 1326 {
1348 1327 global $wpdb;
1349 - $table = $wpdb->prefix . 'yatra_new_bookings';
1328 + $table = BookingsTable::getTableName();
1350 1329 $base = $reference;
1351 1330 $candidate = $base;
1352 1331 for ($n = 0; $n < 5000; $n++) {
1353 1332 $exists = (int) $wpdb->get_var(
@@ -1417,16 +1396,8 @@
1417 1396 }
1418 1397 if (in_array('availability', $out, true) && !in_array('availability_rules', $out, true)) {
1419 1398 $out[] = 'availability_rules';
1420 1399 }
1421 - if (in_array('payments', $out, true)) {
1422 - foreach (['scheduled_payments', 'payment_tokens'] as $extra) {
1423 - if (!in_array($extra, $out, true)) {
1424 - $out[] = $extra;
1425 - }
1426 - }
1427 - }
1428 -
1429 1400 return apply_filters('yatra_export_import_expand_types', $out, $dataTypes);
1430 1401 }
1431 1402
1432 1403 /**
@@ -1461,9 +1432,8 @@
1461 1432 'trip_demand_scores',
1462 1433 'pricing_history',
1463 1434 'departures',
1464 1435 'customers',
1465 - 'payment_tokens',
1466 1436 'bookings',
1467 1437 'booking_departures',
1468 1438 'booking_additional_services',
1469 1439 'signed_consents',
@@ -1475,9 +1445,8 @@
1475 1445 'email_logs',
1476 1446 'travelers',
1477 1447 'traveler_meta',
1478 1448 'payments',
1479 - 'scheduled_payments',
1480 1449 'google_calendar_events',
1481 1450 'reviews',
1482 1451 'enquiries',
1483 1452 'discounts',
@@ -1508,10 +1477,10 @@
1508 1477 if ($dataType === 'settings') {
1509 1478 continue;
1510 1479 }
1511 1480 if ($dataType === 'itinerary') {
1512 - $daysTable = $wpdb->prefix . 'yatra_new_trip_itinerary_days';
1513 - $entriesTable = $wpdb->prefix . 'yatra_new_trip_itinerary_day_entry';
1481 + $daysTable = TripItineraryDaysTable::getTableName();
1482 + $entriesTable = TripItineraryDayEntryTable::getTableName();
1514 1483 if ($repository->tableExists($daysTable)) {
1515 1484 $total += $repository->getRecordCount($daysTable);
1516 1485 }
1517 1486 if ($repository->tableExists($entriesTable)) {
@@ -1520,9 +1489,9 @@
1520 1489 continue;
1521 1490 }
1522 1491 $classType = self::classificationTypeForDataType($dataType);
1523 1492 if ($classType !== null) {
1524 - $tableName = $wpdb->prefix . 'yatra_new_classifications';
1493 + $tableName = ClassificationsTable::getTableName();
1525 1494 if ($repository->tableExists($tableName)) {
1526 1495 $total += $repository->getClassificationCount($tableName, $classType);
1527 1496 }
1528 1497 continue;