PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 3.1.7
MxChat – AI Chatbot & Content Generation for WordPress v3.1.7
3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
← All changes | includes/class-mxchat-utils.php +18 -29 3.2.23.1.7 View file →
@@ -804,34 +804,31 @@
804 804
805 805 // Add the original single-vector ID (for non-chunked content)
806 806 $vectors_to_delete[] = $base_vector_id;
807 807
808 - // Pinecone /vectors/list is a GET endpoint with query-string parameters; a POST here returns a
809 - // non-200 silently and we end up only deleting the base vector, leaving chunks orphaned.
810 - $query_params = array(
808 + // Use Pinecone list API to find all chunk vectors with this prefix
809 + $list_url = "https://{$host}/vectors/list";
810 +
811 + $list_body = array(
811 812 'prefix' => $base_vector_id . '_chunk_',
812 - 'limit' => 100,
813 + 'limit' => 100
813 814 );
815 +
814 816 if (!empty($namespace)) {
815 - $query_params['namespace'] = $namespace;
817 + $list_body['namespace'] = $namespace;
816 818 }
817 819
818 - $list_url = "https://{$host}/vectors/list?" . http_build_query($query_params);
820 + $list_response = wp_remote_post($list_url, array(
821 + 'headers' => array(
822 + 'Api-Key' => $api_key,
823 + 'accept' => 'application/json',
824 + 'content-type' => 'application/json'
825 + ),
826 + 'body' => wp_json_encode($list_body),
827 + 'timeout' => 30
828 + ));
819 829
820 - // Paginate in case a URL has more than 100 chunks.
821 - do {
822 - $list_response = wp_remote_get($list_url, array(
823 - 'headers' => array(
824 - 'Api-Key' => $api_key,
825 - 'accept' => 'application/json',
826 - ),
827 - 'timeout' => 30,
828 - ));
829 -
830 - if (is_wp_error($list_response) || wp_remote_retrieve_response_code($list_response) !== 200) {
831 - break;
832 - }
833 -
830 + if (!is_wp_error($list_response)) {
834 831 $list_data = json_decode(wp_remote_retrieve_body($list_response), true);
835 832 if (!empty($list_data['vectors'])) {
836 833 foreach ($list_data['vectors'] as $vector) {
837 834 if (isset($vector['id'])) {
@@ -838,17 +835,9 @@
838 835 $vectors_to_delete[] = $vector['id'];
839 836 }
840 837 }
841 838 }
842 -
843 - $next_token = $list_data['pagination']['next'] ?? '';
844 - if (empty($next_token)) {
845 - break;
846 - }
847 -
848 - $query_params['paginationToken'] = $next_token;
849 - $list_url = "https://{$host}/vectors/list?" . http_build_query($query_params);
850 - } while (true);
839 + }
851 840
852 841 if (empty($vectors_to_delete)) {
853 842 //error_log('[MXCHAT-CHUNK-DELETE] No vectors found to delete');
854 843 return true;