Page 1 of 2

Date type custom field with default value

Posted: 22 Aug 2017, 11:20
by shanthini.g
Hi

We created a date type custom field in which we left the default value as empty. But while accessing report issues page we got error as ''Invalid argument supplied for foreach()' in 'C:\xampp\htdocs\Bugtracker\core\date_api.php' line 25

Our Mantis version is 2.3.1

Please refer below screen shots and suggest

Thanks

Re: Date type custom field with default value

Posted: 22 Aug 2017, 11:43
by atrol
I assume this bug causes your issue https://www.mantisbt.org/bugs/view.php?id=22663
It's fixed starting with version 2.3.2.

Adding this single line should fix it
https://github.com/mantisbt/mantisbt/co ... 26bd3799b6
but I recommend to upgrade to latest stable version (2.5.1. at the moment) as there are quite a lot of fixes (especially security related) since 2.3.1.

Re: Date type custom field with default value

Posted: 22 Aug 2017, 13:10
by shanthini.g
Yes, Fixed. Thanks

Re: Date type custom field with default value

Posted: 23 Aug 2017, 05:55
by shanthini.g
Hi atrol

When we try to save the issue below error appears. We have attached the screen shot for the same. Could you please suggest

SYSTEM WARNING

'date() expects parameter 2 to be long, string given' in 'C:\xampp\htdocs\Bugtracker\core\cfdefs\cfdef_standard.php' line 215
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

Thanks

Re: Date type custom field with default value

Posted: 23 Aug 2017, 06:19
by atrol
shanthini.g wrote:When we try to save the issue below error appears.
Is this related to "Date type custom field with default value"?

Re: Date type custom field with default value

Posted: 23 Aug 2017, 12:45
by shanthini.g
Hi,

Sorry I attached a wrong screen shot.

I have removed old one and attached the correct one. Could you please refer

Thanks

Re: Date type custom field with default value

Posted: 23 Aug 2017, 18:27
by atrol
Did you upgrade to 2.5.1?

Re: Date type custom field with default value

Posted: 24 Aug 2017, 04:52
by shanthini.g
Our Mantis version is 2.3.1. We will do the upgrade and get back if we still face the issue.

Thanks for your support

Re: Date type custom field with default value

Posted: 06 Sep 2017, 09:12
by shanthini.g
Hi

We upgraded mantis to 2.5.1

Still we are facing the issue if we submit an issue with out selecting the date field

Please refer below screen shots

Screen shot of submitting an issue - https://www.sierratec.com/demo/screensh ... issues.png
Screen shot of Mantis error that we got - https://www.sierratec.com/demo/screensh ... -error.png

Thanks

Re: Date type custom field with default value

Posted: 08 Sep 2017, 06:50
by atrol
I am note able to reproduce the issue.

- Do you get any errors or warnings when running admin/check/index.php?
- Could you provide a screen shot of the "Raised on" field definition?
- Did you change any source of Mantis?
- Did you install any 3rd party plugins?
- Which PHP version do you use?
- Which database version do you use?

Re: Date type custom field with default value

Posted: 14 Sep 2017, 12:28
by shanthini.g
Hi

Please find our reply here http://www.sierratec.com/demo/screensho ... 42017.docx

Thanks

Re: Date type custom field with default value

Posted: 14 Sep 2017, 14:28
by atrol
Please no linked attachments.

You have set default value of the date field to string NULL.
String NULL is not a valid date, so you should remove it.
Except the below suggested one we have not edited the source
https://github.com/mantisbt/mantisbt/co ... 26bd3799b6
You don't have to change the code any longer if you updated to 2.5.1.

Re: Date type custom field with default value

Posted: 15 Sep 2017, 09:24
by shanthini.g
Thanks for your support

This is working fine while posting new issues as well as editing/updating the newly posted issues after doing as you suggested

But if we edit/update the old issues (that is the issues that we created long before even before mantis upgrade) an issue occurs as 'date() expects parameter 2 to be long, string given'

We checked 'mantis_custom_field_string_table' both has the same value. Could you please refer below screen shots and suggest.

date() expects parameter 2 to be long, string given - Error screen shot - https://www.sierratec.com/demo/screensh ... 092017.png
mantis_custom_field_string_table - screen shot - https://www.sierratec.com/demo/screensh ... 092017.png

Thanks

Re: Date type custom field with default value

Posted: 15 Sep 2017, 18:30
by atrol
shanthini.g wrote:Could you please refer below screen shots and suggest.
atrol wrote:Please no linked attachments
Additional, debugging information is needed:

1. temporarily configure your system as follows:

Code: Select all

$g_display_errors = array(
    E_WARNING => 'halt',
    E_NOTICE => 'halt',
    E_USER_ERROR => 'halt',
    E_USER_WARNING => 'halt',
    E_USER_NOTICE => 'halt'
);
$g_show_detailed_errors = ON;

WARNING - SECURITY RISK: the 'show_detailed_errors' config can cause MantisBT to display sensitive information about your system. We recommend to restrict its activation to a Test environment, only for as long as necessary. If possible, do not turn it ON globally, instead limit it for specific user(s) using the Manage Configuration page.

2. Reproduce the error

If the output does not help you resolving the issue and you need further assistance,

3. save the output of the error screen, preferably as a single HTML page (not a screenshot !)
4. be careful to remove/mask any confidential information if needed
5. upload the results here

Re: Date type custom field with default value

Posted: 19 Sep 2017, 11:56
by shanthini.g
Hi

Please find below details. As my limit to upload images exceeds, I posted the screen shot as link, sorry...

SYSTEM WARNING

'date() expects parameter 2 to be long, string given' in 'C:\xampp\htdocs\Bugtracker\core\cfdefs\cfdef_standard.php' line 290
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.

Full path: C:\xampp\htdocs\Bugtracker\core\cfdefs\cfdef_standard.php
Line: 290
Variable Value Type
p_value NULL string

Filename Line Function Args
C:\xampp\htdocs\Bugtracker\core\cfdefs\cfdef_standard.php 290 - - date ( <string>'Y-m-d', <string>'NULL' )
- - - - cfdef_prepare_date_value_for_email ( <string>'NULL' )
C:\xampp\htdocs\Bugtracker\core\custom_field_api.php 1476 - - call_user_func ( <string>'cfdef_prepare_date_value_for_email', <string>'NULL' )
C:\xampp\htdocs\Bugtracker\core\history_api.php 674 - - string_custom_field_value_for_email ( <string>'NULL', <string>'8' )
C:\xampp\htdocs\Bugtracker\core\history_api.php 152 - - history_localize_item ( <string>'Raised on', <string>'0', <string>'NULL', <string>'' )
C:\xampp\htdocs\Bugtracker\history_inc.php 63 - - history_get_events_array ( <integer>49725 )
C:\xampp\htdocs\Bugtracker\bug_view_inc.php 775 - - include ( <string>'C:\\xampp\\htdocs\\Bugtracker\\history_inc.php' )
C:\xampp\htdocs\Bugtracker\view.php 37 - - include ( <string>'C:\\xampp\\htdocs\\Bugtracker\\bug_view_inc.php' )