Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where different cache key is generated for the same message content. #26

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion class-gwiz-gf-openai.php
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@

$cache_key = sha1( serialize( array(
'url' => $url,
'body' => $body,
'body' => map_deep( $body, 'sanitize_text_field' ), // Sanitize the `$body` variable to ensure consistent `$cache_key`
'request_params' => $this->get_request_params( $feed ),
) ) );

Expand Down Expand Up @@ -1386,7 +1386,7 @@

$body = apply_filters( 'gf_openai_request_body', $body, $endpoint, $feed );

$this->log_debug( __METHOD__ . '(): ' . sprintf( __( 'Making request to %s', 'gravityforms-openai' ), $url ) );

Check warning on line 1389 in class-gwiz-gf-openai.php

View workflow job for this annotation

GitHub Actions / PHPCS

A gettext call containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.

// Cache successful responses.
$response = wp_remote_post($url, array_merge( array(
Expand Down Expand Up @@ -1547,7 +1547,7 @@
public function should_transform_feed( $feed ) {
$endpoint = rgars( $feed, 'meta/endpoint' );

if ( in_array( $endpoint, array( 'completions', 'edits' ) ) ) {

Check warning on line 1550 in class-gwiz-gf-openai.php

View workflow job for this annotation

GitHub Actions / PHPCS

Not using strict comparison for in_array; supply true for third argument.
return true;
}

Expand Down
Loading