*

cartagena68

  • ***
  • 71 posts
Bug with custom field date interval
« on: November 09, 2021, 11:16:08 PM »
If you create a custom field date interval and check the option to allow searches, it will throw a fatal error in the search page.

*

MB Themes

Re: Bug with custom field date interval
« Reply #1 on: November 10, 2021, 09:05:34 AM »
Can you put there that error?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #2 on: November 10, 2021, 01:55:47 PM »
This is the error i get

PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /var/www/vhosts/example.com/testiamo/oc-includes/osclass/frm/Field.form.class.php:196
Stack trace:
#0 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/frm/Field.form.class.php(347): FieldForm::meta()
#1 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/functions.php(619): FieldForm::meta_fields_search()
#2 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/classes/Plugins.php(43): osc_meta_search()
#3 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/helpers/hPlugins.php(34): Plugins::runHook()
#4 /var/www/vhosts/example.com/testiamo/oc-content/themes/ctg_light/search-sidebar.php(95): osc_run_hook()
#5 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/helpers/hDefines.php(363): require('...')
#6 /var/www/vhosts/example.com/testiamo/oc-content/themes/ctg_light/search.php(63): osc_current_web_theme_path()
#7 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/helpers/hDefines.php(363): require('...')
#8 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/controller/search.php(702): osc_current_web_theme_path()
#9 /var/www/vhosts/example.com/testiamo/oc-includes/osclass/controller/search.php(634): CWebSearch->doView()
#10 /var/www/vhosts/example.com/testiamo/index.php(108): CWebSearch->doModel()
#11 {main}
  thrown in /var/www/vhosts/example.com/testiamo/oc-includes/osclass/frm/Field.form.class.php on line 196

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #3 on: November 10, 2021, 03:05:48 PM »
I find a fix for the problem in oc-includes/osclass/frm/Field.form.class.php:196
change
Code: [Select]
$_meta = Params::getParam('meta');to
Code: [Select]
$_meta = array(Params::getParam('meta'));
I don't know if is the correct solution, but the error is gone

*

MB Themes

Re: Bug with custom field date interval
« Reply #4 on: November 10, 2021, 03:40:32 PM »
To me, correct solution looks like to replace this:
Code: [Select]
          $temp['from'] = @(int)$_meta[$field['pk_i_id']]['from'];
          $temp['to'] = @(int)$_meta[$field['pk_i_id']]['to'];

With following:
Code: [Select]
          if(is_array($_meta) && isset($_meta[$field['pk_i_id']]) && isset($_meta[$field['pk_i_id']]['from'])) {
            $temp['from'] = (int)$_meta[$field['pk_i_id']]['from'];
            $temp['to'] = (int)$_meta[$field['pk_i_id']]['to'];
          } else {
            $temp['from'] = '';
            $temp['to'] = '';
          }
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #5 on: November 10, 2021, 03:49:22 PM »
To me, correct solution looks like to replace this:
Code: [Select]
          $temp['from'] = @(int)$_meta[$field['pk_i_id']]['from'];
          $temp['to'] = @(int)$_meta[$field['pk_i_id']]['to'];

With following:
Code: [Select]
          if(is_array($_meta) && isset($_meta[$field['pk_i_id']]) && isset($_meta[$field['pk_i_id']]['from'])) {
            $temp['from'] = (int)$_meta[$field['pk_i_id']]['from'];
            $temp['to'] = (int)$_meta[$field['pk_i_id']]['to'];
          } else {
            $temp['from'] = '';
            $temp['to'] = '';
          }

with this solution, i get a php worning
Undefined variable $_meta in /var/www/vhosts/example.com/ctg-light/oc-includes/osclass/frm/Field.form.class.php on line 195

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #6 on: November 10, 2021, 03:56:01 PM »
should add $_meta = '';

Code: [Select]
          $_meta = '';
          if(is_array($_meta) && isset($_meta[$field['pk_i_id']]) && isset($_meta[$field['pk_i_id']]['from'])) {
            $temp['from'] = (int)$_meta[$field['pk_i_id']]['from'];
            $temp['to'] = (int)$_meta[$field['pk_i_id']]['to'];
          } else {
            $temp['from'] = '';
            $temp['to'] = '';
          }


Will be fixed in next update?
« Last Edit: November 10, 2021, 03:58:45 PM by cartagena68 »

*

MB Themes

Re: Bug with custom field date interval
« Reply #7 on: November 10, 2021, 04:06:43 PM »
No, why $_meta would be changed?

It is like this:
Code: [Select]
          $_meta = Params::getParam('meta');
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #8 on: November 10, 2021, 04:17:18 PM »
ok, so we add $_meta = Params::getParam('meta'); before if(is_array($_meta) && isset($_meta[$field['pk_i_id']]) && isset($_meta[$field['pk_i_id']]['from'])) {

*

MB Themes

Re: Bug with custom field date interval
« Reply #9 on: November 10, 2021, 04:18:04 PM »
No it is already there - will add complete code tomorrow
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #10 on: November 10, 2021, 04:21:10 PM »
i don't find it anywhere in Field.form.class.php and if i don't add it i get a warning
Undefined variable $_meta in /var/www/vhosts/example.com/ctg-light/oc-includes/osclass/frm/Field.form.class.php on line 195

*

MB Themes

Re: Bug with custom field date interval
« Reply #11 on: November 11, 2021, 03:04:28 PM »
This is full block.
Code: [Select]
        } else {
          $_meta = Params::getParam('meta');
         
          if(is_array($_meta) && isset($_meta[$field['pk_i_id']]) && isset($_meta[$field['pk_i_id']]['from'])) {
            $temp['from'] = (int)$_meta[$field['pk_i_id']]['from'];
            $temp['to'] = (int)$_meta[$field['pk_i_id']]['to'];
          } else {
            $temp['from'] = '';
            $temp['to'] = '';
          }
         
          $field['s_value'] = $temp;
        }

original was:
Code: [Select]
        } else {
          $_meta = Params::getParam('meta');
          $temp['from'] = @(int)$_meta[$field['pk_i_id']]['from'];
          $temp['to'] = @(int)$_meta[$field['pk_i_id']]['to'];
          $field['s_value'] = $temp;
        }
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #12 on: November 11, 2021, 03:27:56 PM »
Correct, thank you, so will be fixed in next update?

*

MB Themes

Re: Bug with custom field date interval
« Reply #13 on: November 11, 2021, 03:42:56 PM »
@cartagena68
Yes is ready in 8.0.1
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Bug with custom field date interval
« Reply #14 on: November 11, 2021, 03:44:25 PM »
Thank you very much