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

Itunes categories with same main category are overwritten #41

Open
podcasthosting opened this issue Aug 23, 2021 · 9 comments
Open

Itunes categories with same main category are overwritten #41

podcasthosting opened this issue Aug 23, 2021 · 9 comments
Labels
Awaiting Author Updates Bug Something isn't working
Milestone

Comments

@podcasthosting
Copy link

Bug Report

Q A
Version(s) 2.14.1

Summary

When setting multiple iTunes categories and two or more having the same "main" category the latter are overwritten.

Current behavior

$feed->setItunesCategories(['Arts' => 'Food]);
$feed->setItunesCategories(['Arts' => 'Visual Arts]);

only

    <itunes:category text="Arts">
      <itunes:category text="Visual Arts"/>
    </itunes:category>

ends up being in the rendered output

How to reproduce

Add two categories with the same main category.

Expected behavior

I´d expect both entries being shown in the feed.

    <itunes:category text="Arts">
      <itunes:category text="Food"/>
    </itunes:category>
    <itunes:category text="Arts">
      <itunes:category text="Visual Arts"/>
    </itunes:category>

The culprit seems to be

vendor/laminas/laminas-feed/src/Writer/Extension/ITunes/Feed.php

somewhere within method setItunesCategories()

@podcasthosting podcasthosting added the Bug Something isn't working label Aug 23, 2021
@froschdesign
Copy link
Member

froschdesign commented Aug 24, 2021

@podcasthosting

$feed->setItunesCategories(['Arts' => 'Food']);
$feed->setItunesCategories(['Arts' => 'Visual Arts']);

The usage is wrong because the method sets all categories for the feed and a second call overwrites all previous categories. You expect the functionality of a method like addItunesCategory but it does not exist.

Use the following:

$feed->setItunesCategories(['Arts' => ['Food', 'Visual Arts']]);

@podcasthosting
Copy link
Author

But why does it work with categories with a different main category?

$feed->setItunesCategories(['Arts' => 'Food]);
$feed->setItunesCategories(['Business']);
$feed->setItunesCategories(['Comedy' => 'Comedy Interviews']);

Adds all 3 categories to the feed (as expected). Right now it partly works like an addItunesCategory method.

@froschdesign
Copy link
Member

@podcasthosting
The method is far from perfect and leads to unexpected behaviour at the moment. A clean and well-defined API is needed to avoid problems like the current one.

Adds all 3 categories to the feed (as expected). Right now it partly works like an addItunesCategory method.

And this behaviour is wrong. setItunesCategories should set the categories in whole and should overwrite all previous categories.

But at this point, we cannot change the current behaviour because this could break the current running applications.

@froschdesign froschdesign added this to the 3.0.0 milestone Aug 24, 2021
@podcasthosting
Copy link
Author

Thank you for clarification!

@froschdesign
Copy link
Member

@podcasthosting
I would leave the issue report open because the API can be improved with the next major version. That's why I had added the milestone.

@froschdesign froschdesign reopened this Aug 24, 2021
@podcasthosting
Copy link
Author

This actually also does not work:

$feed->setItunesCategories(['Comedy' => ['Improv', 'Comedy Interviews']]);

The result is:

    <itunes:category text="Comedy">
      <itunes:category text="Improv"/>
      <itunes:category text="Comedy Interviews"/>
    </itunes:category>

but should be:

    <itunes:category text="Comedy">
      <itunes:category text="Improv"/>
    </itunes:category>

    <itunes:category text="Comedy">
      <itunes:category text="Comedy Interviews"/>
    </itunes:category>

So this is completely broken and a pretty severe bug (from our customers` point of view).

@froschdesign
Copy link
Member

@podcasthosting

but should be:

    <itunes:category text="Comedy">
      <itunes:category text="Improv"/>
    </itunes:category>

    <itunes:category text="Comedy">
      <itunes:category text="Comedy Interviews"/>
    </itunes:category>

Can you provide a reference / documentation for this? Thanks in advance! 👍

@froschdesign
Copy link
Member

@podcasthosting
Another idea is to use the corresponding XML schemas in the unit tests, so the schemas will also help here.

@froschdesign
Copy link
Member

froschdesign commented Oct 25, 2021

@podcasthosting
Did you find some reference or documentation for this topic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Author Updates Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants