← All changes
|
includes/Admin/Product/Data/Services/PhotoService.php
+5
-1
1.9.0
→
1.10.20
View file →
| @@ -65,9 +65,10 @@ | ||
| 65 | 65 | |
| 66 | 66 | try { |
| 67 | 67 | return $this->fileUploader->upload($imagePathOrUrl); |
| 68 | 68 | } catch (\Throwable $e) { |
| 69 | - throw new \RuntimeException('آپلود تصویر محصول به باسلام ناموفق بود: ' . $e->getMessage(), 0, $e); | |
| 69 | + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Message is escaped; $e is the previous Throwable passed for exception chaining, not output. | |
| 70 | + throw new \RuntimeException(esc_html('آپلود تصویر محصول به باسلام ناموفق بود: ' . $e->getMessage()), 0, $e); | |
| 70 | 71 | } |
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | private function getImagePathOrUrl(int $imageId): ?string |
| @@ -85,8 +86,9 @@ | ||
| 85 | 86 | global $wpdb; |
| 86 | 87 | $tableName = $wpdb->prefix . 'sync_basalam_uploaded_media'; |
| 87 | 88 | $sourceIdentity = 'attachment:' . $wooPhotoId; |
| 88 | 89 | |
| 90 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Custom plugin table; identifier from $wpdb->prefix, not user input. | |
| 89 | 91 | $result = $wpdb->get_row($wpdb->prepare( |
| 90 | 92 | "SELECT media_id AS file_id, media_url AS url, created_at |
| 91 | 93 | FROM $tableName |
| 92 | 94 | WHERE type = %s AND source_identity = %s", |
| @@ -102,8 +104,9 @@ | ||
| 102 | 104 | |
| 103 | 105 | $age = $now - $createdAt; |
| 104 | 106 | |
| 105 | 107 | if ($age >= $fourteenDays) { |
| 108 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom plugin table; no object cache for these operational queries. | |
| 106 | 109 | $wpdb->delete( |
| 107 | 110 | $tableName, |
| 108 | 111 | ['type' => 'photo', 'source_identity' => $sourceIdentity], |
| 109 | 112 | ['%s', '%s'] |
| @@ -118,8 +121,9 @@ | ||
| 118 | 121 | { |
| 119 | 122 | global $wpdb; |
| 120 | 123 | $tableName = $wpdb->prefix . 'sync_basalam_uploaded_media'; |
| 121 | 124 | |
| 125 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom plugin table; no object cache for these operational queries. | |
| 122 | 126 | $wpdb->replace( |
| 123 | 127 | $tableName, |
| 124 | 128 | [ |
| 125 | 129 | 'type' => 'photo', |