فهرست منبع

Fix missing description field in sync query and buffer corruption

getSyncEnabledProducts() selected pd.name but not pd.description, causing
an 'Undefined array key description' PHP warning in ProductMapper::toReverb()
which was buffered by OC3 and prepended to the JSON response, making it
unparseable by jQuery.

Also clean the OB buffer at the top of sync() so any future PHP notices
cannot corrupt AJAX JSON responses. Revert diagnostic error callback now
that the root cause is identified and fixed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Benjamin Harris 2 هفته پیش
والد
کامیت
112d0030d2

+ 6 - 0
upload/admin/controller/extension/module/reverb.php

@@ -173,6 +173,12 @@ class ControllerExtensionModuleReverb extends Controller {
         // Set JSON header first so any uncaught error still returns parseable JSON.
         $this->response->addHeader('Content-Type: application/json');
 
+        // Discard any PHP notices/warnings buffered before this point so they
+        // cannot corrupt the JSON response body.
+        if (ob_get_level()) {
+            ob_clean();
+        }
+
         try {
             if (!$this->user->hasPermission('modify', 'extension/module/reverb')) {
                 $this->response->setOutput(json_encode(['success' => false, 'error' => $this->language->get('error_permission')]));

+ 1 - 1
upload/admin/model/extension/module/reverb.php

@@ -108,7 +108,7 @@ class ModelExtensionModuleReverb extends Model {
         $ids = implode(',', array_map('intval', $allowed_category_ids));
 
         $query = $this->db->query("
-            SELECT p.product_id, pd.name, p.model, p.price, p.quantity, p.image,
+            SELECT p.product_id, pd.name, pd.description, p.model, p.price, p.quantity, p.image,
                    r.reverb_listing_id, r.condition_uuid, r.reverb_category_uuid
             FROM `" . DB_PREFIX . "product` p
             INNER JOIN `" . DB_PREFIX . "product_description` pd

+ 2 - 7
upload/admin/view/template/extension/module/reverb.twig

@@ -254,13 +254,8 @@ $(function() {
                     $result.removeClass('text-success').addClass('text-danger').text(data.error).show();
                 }
             },
-            error: function(xhr) {
-                var info = 'HTTP ' + xhr.status;
-                if (xhr.responseText) {
-                    var preview = xhr.responseText.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim().substring(0, 300);
-                    if (preview) info += ': ' + preview;
-                }
-                $result.removeClass('text-success').addClass('text-danger').text(info).show();
+            error: function() {
+                $result.removeClass('text-success').addClass('text-danger').text('Sync request failed.').show();
             },
             complete: function() {
                 $btn.prop('disabled', false).html('<i class="fa fa-refresh"></i> {{ button_sync_now }}');