alleyinteractive / ad-layers

Ad Layers WordPress Plugin
Other
26 stars 12 forks source link

Duplicate entries in `ad_layers` option #96

Closed mogmarsh closed 2 years ago

mogmarsh commented 2 years ago

The ad_layers option can somehow get duplicate entries of the Ad Layer posts. When determining the priority, only the first entry matters, but the second entry can be confusing for users. There is no way to delete the second entry through the GUI, unless you mess with the CSS or DOM in your browser.

Example (note duplicate entries for 1000488, 1000491, 1000608 and others):


array (
  0 => 
  array (
    'post_id' => '1000472',
    'title' => 'Homepage',
  ),
  1 => 
  array (
    'post_id' => '1000488',
    'title' => 'Channel Mains',
  ),
  2 => 
  array (
    'post_id' => '1000491',
    'title' => 'Channel Mains - Article/Video',
  ),
  3 => 
  array (
    'post_id' => '1000493',
    'title' => 'Channel Mains - Photogallery',
  ),
  4 => 
  array (
    'post_id' => '1000608',
    'title' => 'Anglers',
  ),
  5 => 
  array (
    'post_id' => '1000610',
    'title' => 'Anglers - Person Pages',
  ),
  6 => 
  array (
    'post_id' => '1000581',
    'title' => 'Tournaments',
  ),
  7 => 
  array (
    'post_id' => '1000605',
    'title' => 'Other',
  ),
  8 => 
  array (
    'post_id' => '1000603',
    'title' => 'Search Page',
  ),
  9 => 
  array (
    'post_id' => '1000600',
    'title' => 'Video',
  ),
  10 => 
  array (
    'post_id' => '1000593',
    'title' => 'Tournaments - Blog',
  ),
  11 => 
  array (
    'post_id' => '1000595',
    'title' => 'Tournaments - Kayak',
  ),
  12 => 
  array (
    'post_id' => '1000589',
    'title' => 'Tournaments - Basstrakk',
  ),
  13 => 
  array (
    'post_id' => '1000587',
    'title' => 'Tournaments - Leaderboard',
  ),
  14 => 
  array (
    'post_id' => '1000585',
    'title' => 'Tournaments - Individual',
  ),
  15 => 
  array (
    'post_id' => '1000583',
    'title' => 'Tournaments - Schedule',
  ),
  16 => 
  array (
    'post_id' => '1000591',
    'title' => 'Tournaments - Info',
  ),
  17 => 
  array (
    'post_id' => '1000495',
    'title' => 'Channel Mains - Archive',
  ),
  18 => 
  array (
    'post_id' => '117675',
    'title' => 'catch all',
  ),
  19 => 
  array (
    'post_id' => '117673',
    'title' => 'Homepage',
  ),
  20 => 
  array (
    'post_id' => '1000089',
    'title' => 'Catch All',
  ),
  21 => 
  array (
    'post_id' => '1000641',
    'title' => 'Anglers - Standings',
  ),
  22 => 
  array (
    'post_id' => '1000640',
    'title' => 'Anglers - Elites',
  ),
  23 => 
  array (
    'post_id' => '1000488',
    'title' => 'Channel Mains',
  ),
  24 => 
  array (
    'post_id' => '1000631',
    'title' => 'Tournaments - Schedule',
  ),
  25 => 
  array (
    'post_id' => '1000632',
    'title' => 'Tournaments - Individual',
  ),
  26 => 
  array (
    'post_id' => '1000633',
    'title' => 'Tournaments - Leaderboard',
  ),
  27 => 
  array (
    'post_id' => '1000634',
    'title' => 'Tournaments - Basstrakk',
  ),
  28 => 
  array (
    'post_id' => '1000635',
    'title' => 'Tournaments - Kayak',
  ),
  29 => 
  array (
    'post_id' => '1000636',
    'title' => 'Search Page',
  ),
  30 => 
  array (
    'post_id' => '1000637',
    'title' => 'Other',
  ),
  31 => 
  array (
    'post_id' => '1000638',
    'title' => 'Anglers - Person Pages',
  ),
  32 => 
  array (
    'post_id' => '1000639',
    'title' => 'Anglers - Person Pages - Stats',
  ),
  33 => 
  array (
    'post_id' => '1000491',
    'title' => 'Channel Mains - Article/Video',
  ),
  34 => 
  array (
    'post_id' => '1000641',
    'title' => 'Anglers - Standings',
  ),
  35 => 
  array (
    'post_id' => '1000610',
    'title' => 'Anglers - Person Pages',
  ),
  36 => 
  array (
    'post_id' => 1000581,
    'title' => 'Tournaments',
  ),
  37 => 
  array (
    'post_id' => 1000603,
    'title' => 'Search Page',
  ),
  38 => 
  array (
    'post_id' => 1000608,
    'title' => 'Anglers',
  ),
)```
mogmarsh commented 2 years ago

It seems that https://github.com/alleyinteractive/ad-layers/blob/feature/version-2/inc/class-ad-layers-post-type.php#L266-L306 is not working, and my guess is that it is trying to compare a string and an int on line 292.

mogmarsh commented 2 years ago

We're going to have the same issue here in the delete function: https://github.com/alleyinteractive/ad-layers/blob/feature/version-2/inc/class-ad-layers-post-type.php#L324

kevinfodness commented 2 years ago

Fixed in #97