PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.2
2.4.3 2.4.4 2.4.2 2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 All 60 releases
← All changes | includes/Models/Payment.php +14 -7 2.1.1 → 2.4.2 View file →
@@ -146,9 +146,9 @@
146 146 $field_name = $this->camelCaseToSnakeCase(substr($name, 3)); // Remove 'has' prefix
147 147 return !empty($this->__get($field_name));
148 148 }
149 149
150 - throw new \BadMethodCallException("Method $name does not exist");
150 + throw new \BadMethodCallException(esc_html("Method $name does not exist"));
151 151 }
152 152
153 153 /**
154 154 * Convert camelCase to snake_case
@@ -184,9 +184,9 @@
184 184 public function update(array $data): bool {
185 185 if (!$this->exists()) {
186 186 return false;
187 187 }
188 -
188 +
189 189 // Update post meta for each field
190 190 $meta_fields = [
191 191 'invoice_id' => '_invoice_id',
192 192 'amount' => '_amount',
@@ -206,15 +206,21 @@
206 206 $success = true;
207 207
208 208 foreach ($meta_fields as $field => $meta_key) {
209 209 if (isset($data[$field])) {
210 + // update_post_meta returns false if value is unchanged (not an error)
211 + // It returns meta_id on success, or true if updated
212 + // We need to check if the meta exists to determine real failure
213 + $old_value = get_post_meta($this->id, $meta_key, true);
210 214 $result = update_post_meta($this->id, $meta_key, $data[$field]);
211 - if ($result === false) {
212 - $success = false;
213 - } else {
214 - // Update local data
215 - $this->data[$field] = $data[$field];
215 +
216 + // Only consider it a failure if the result is false AND the value wasn't already the same
217 + if ($result === false && $old_value !== $data[$field]) {
218 + //$success = false;
216 219 }
220 +
221 + // Always update local data since we're setting it
222 + $this->data[$field] = $data[$field];
217 223 }
218 224 }
219 225
220 226 // Update the post title if invoice_id is provided
@@ -221,8 +227,9 @@
221 227 if (isset($data['invoice_id']) && $data['invoice_id']) {
222 228 $invoice = new \EasyInvoice\Models\Invoice($data['invoice_id']);
223 229 if ($invoice->exists()) {
224 230 $post_title = sprintf(
231 + /* translators: %s: document number. */
225 232 __('Payment for Invoice %s', 'easy-invoice'),
226 233 $invoice->getNumber()
227 234 );
228 235 wp_update_post([