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

Upload with charset #431

Merged
merged 6 commits into from
Jan 24, 2023
Merged

Upload with charset #431

merged 6 commits into from
Jan 24, 2023

Conversation

quazardous
Copy link
Contributor

Proposition for #336

@quazardous
Copy link
Contributor Author

depends on #348

@quazardous
Copy link
Contributor Author

@jlevers I think it's OK (got some trouble with markdown auto toc)

Copy link
Owner

@jlevers jlevers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments :) sorry it took me so long!

lib/Document.php Outdated
Comment on lines 252 to 257
public function upload($feedData, ?string $charset = null): void {
$response = $this->client->put($this->url, [
RequestOptions::HEADERS => [
"content-type" => $this->contentType,
"content-type" => self::get_content_type_with_charset($this->contentType, $charset),
"host" => parse_url($this->url, PHP_URL_HOST),
],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we just give the new parameter a default of 'utf-8', we can remove a bunch of code, because then the 'content-type' header can become "$contentType; charset=$charset", and the get_content_type_with_charset method can be removed altogether :)

README.md Outdated
...
// Create feed document
$createFeedDocSpec = new Feeds\CreateFeedDocumentSpecification([
'content_type' => SellingPartnerApi\Document::get_content_type_with_charset($feedType['contentType'], $charset)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given my below comment, i think this documentation will need to be changed.

i think that a static method for retrieving a content type with a charset should be put in ContentType.php, something like this:

public static function withCharset(string $contentType, string $charset): string
{
    return "{$contentType}; charset={$charset}";
}

@quazardous
Copy link
Contributor Author

@jlevers withCharset() became withContentType() (because content type is the main parameter)

Copy link
Owner

@jlevers jlevers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@jlevers
Copy link
Owner

jlevers commented Mar 5, 2023

I'm reverting this until the next major version. It's a breaking change because of the usage differences when creating a new feed document. This has led to a lot of people encountering issues and needing to downgrade (see #486).

@quazardous
Copy link
Contributor Author

oops

using a null / NoOp default should be BC free, or at least adding a new function uploadWithCharset()

@jlevers
Copy link
Owner

jlevers commented Mar 9, 2023

Would you mind making a new PR with a null default?

@quazardous
Copy link
Contributor Author

OC no pb

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants