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/AttributeService.php +77 -20 3.0.2.6 → 3.0.16 View file →
@@ -398,18 +398,10 @@
398 398
399 399 // Process icon field
400 400 if (isset($data['icon'])) {
401 401 if (is_array($data['icon'])) {
402 - // Sanitize icon array
403 - $icon = [
404 - 'type' => isset($data['icon']['type']) && in_array($data['icon']['type'], ['icon', 'image'], true)
405 - ? $data['icon']['type']
406 - : 'icon',
407 - 'value' => isset($data['icon']['value'])
408 - ? sanitize_text_field($data['icon']['value'])
409 - : '',
410 - ];
411 - $data['icon'] = maybe_serialize($icon);
402 + $data['icon'] = yatra_normalize_icon_picker_for_storage($data['icon']);
403 + $data['icon'] = maybe_serialize($data['icon']);
412 404 } elseif (is_string($data['icon'])) {
413 405 // If it's already a string, sanitize it
414 406 $data['icon'] = sanitize_text_field($data['icon']);
415 407 }
@@ -484,18 +476,10 @@
484 476
485 477 // Process icon field
486 478 if (isset($data['icon'])) {
487 479 if (is_array($data['icon'])) {
488 - // Sanitize icon array
489 - $icon = [
490 - 'type' => isset($data['icon']['type']) && in_array($data['icon']['type'], ['icon', 'image'], true)
491 - ? $data['icon']['type']
492 - : 'icon',
493 - 'value' => isset($data['icon']['value'])
494 - ? sanitize_text_field($data['icon']['value'])
495 - : '',
496 - ];
497 - $data['icon'] = maybe_serialize($icon);
480 + $data['icon'] = yatra_normalize_icon_picker_for_storage($data['icon']);
481 + $data['icon'] = maybe_serialize($data['icon']);
498 482 } elseif (is_string($data['icon'])) {
499 483 // If it's already a string, sanitize it
500 484 $data['icon'] = sanitize_text_field($data['icon']);
501 485 }
@@ -582,8 +566,81 @@
582 566 } catch (\Exception $e) {
583 567 Logger::error("Failed to force delete attribute {$id}: " . $e->getMessage());
584 568 throw $e;
585 569 }
570 + }
571 +
572 + /**
573 + * Bulk update status for multiple attributes
574 + *
575 + * @param array $ids Attribute IDs
576 + * @param string $status Target status (publish|draft|trash)
577 + * @return array{updated: int, failed: int}
578 + */
579 + public function bulkUpdateStatus(array $ids, string $status): array
580 + {
581 + $updated = 0;
582 + $failed = 0;
583 +
584 + foreach ($ids as $id) {
585 + $id = (int) $id;
586 + if ($id <= 0) {
587 + $failed++;
588 + continue;
589 + }
590 + try {
591 + if ($this->attributeRepository->update($id, ['status' => $status])) {
592 + $updated++;
593 + } else {
594 + $failed++;
595 + }
596 + } catch (\Exception $e) {
597 + Logger::error("bulkUpdateStatus failed for attribute {$id}: " . $e->getMessage());
598 + $failed++;
599 + }
600 + }
601 +
602 + if ($updated > 0) {
603 + $this->clearAttributeCache();
604 + }
605 +
606 + return ['updated' => $updated, 'failed' => $failed];
607 + }
608 +
609 + /**
610 + * Permanently delete multiple attributes
611 + *
612 + * @param array $ids Attribute IDs
613 + * @return array{deleted: int, failed: int}
614 + */
615 + public function bulkDelete(array $ids): array
616 + {
617 + $deleted = 0;
618 + $failed = 0;
619 +
620 + foreach ($ids as $id) {
621 + $id = (int) $id;
622 + if ($id <= 0) {
623 + $failed++;
624 + continue;
625 + }
626 + try {
627 + if ($this->attributeRepository->forceDelete($id)) {
628 + $deleted++;
629 + } else {
630 + $failed++;
631 + }
632 + } catch (\Exception $e) {
633 + Logger::error("bulkDelete failed for attribute {$id}: " . $e->getMessage());
634 + $failed++;
635 + }
636 + }
637 +
638 + if ($deleted > 0) {
639 + $this->clearAttributeCache();
640 + }
641 +
642 + return ['deleted' => $deleted, 'failed' => $failed];
586 643 }
587 644
588 645 /**
589 646 * Update attribute display orders