Possible bug with custom fields

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Possible bug with custom fields
« on February 1st, 2019, 12:54 AM »
  • Create a custom field in the gallery
  • Make it a checklist
  • Make it required
  • Make it searchable
  • Edit an item, don't fill that field
  • Observe errors when saving
Code: [Select]
// Add them to the form
  foreach ($fields as $field)
  {
- if ($field['type'] == 'checkbox')
+ if ($field['type'] == 'checkbox' && empty($field['searchable']))
  $field['value'] = explode(', ', $field['value']);
 
  // Options...
  $value = isset($_POST['custom_field'][$field['id']]) && (is_array($_POST['custom_field'][$field['id']]) || trim($_POST['custom_field'][$field['id']]) != '') ? $_POST['custom_field'][$field['id']] : '';
 
+ // JTR: preparsecode() corrupts the array by converting it to a string.
+ if (isset($_POST['custom_field'][$field['id']]) && !is_array($_POST['custom_field'][$field['id']]))
- preparsecode($value);
+ preparsecode($value);
 
  // Do the value checks
  if ($field['type'] == 'checkbox')
  {
- foreach ($value as $val)
- if (!in_array($val, $field['options']))
- fatal_error(sprintf($txt['aeva_cf_invalid'], $field['name']));
-
  // Nothing set?
  if (empty($value) && $field['required'])
  fatal_error(sprintf($txt['aeva_cf_empty'], $field['name']));
  elseif (empty($value))
  continue;
 
+ foreach ($value as $val)
+ if (!in_array($val, $field['options']))
+ fatal_error(sprintf($txt['aeva_cf_invalid'], $field['name']));
+
  // Set the proper value
  $value = implode(', ', $value);
  }
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Possible bug with custom fields
« Reply #1, on May 11th, 2019, 01:36 PM »
Is... that a fix, you posted below? Because your topic says 'possible bug', not 'bug with possible fix'... ;)
You could just as well post a PR..? Or maybe there's one... I must admit, I don't check the git page often.

(As a quick note: I believe the custom field feature for AeMe was written by Dragooon originally, so I'm probably not well versed in it.)

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Re: Possible bug with custom fields
« Reply #2, on January 10th, 2020, 11:58 PM »
Eh, the code is what I did to keep the logs quiet.

And I did not send anything to the repo. This was on AeMe on SMF, so I have no idea if the code is even valid for Wedge.

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Possible bug with custom fields
« Reply #3, on April 6th, 2020, 04:54 PM »
Oh, I see...
I'm so out of the loop anyway.
Yesterday I spent a few hours rewriting the audio player for my very old prog-rock website (fox.noisen.com), which isn't running on Wedge but is running an old version of Aeva Media (it's the website I actually wrote the 'Foxy' module for, hence the name), and ended up getting it to work on modern browsers. Then I wondered to myself, is it worth porting over to Aeva and/or Wedge..?
I don't know.
I have this weird feeling that Foxprog is the only website to use the playlist features of Aeva Media, anyway.