View Issue Details

IDProjectCategoryView StatusLast Update
0012112mantisbtplug-inspublic2014-09-23 18:05
Reporterdocteur.cox Assigned Todregad  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.1 
Target Version1.2.12Fixed in Version1.2.12 
Summary0012112: XML Import fails: Column 'profile_id' cannot be null
Description

XML import fails with the following error message :
APPLICATION ERROR 0000401

Échec de la requête de base de données. L'erreur renvoyée par la base de données était #1048 : Column 'profile_id' cannot be null pour la requête : INSERT INTO mantis_bug_table
( project_id,reporter_id, handler_id,duplicate_id,
priority,severity, reproducibility,status,
resolution,projection, category_id,date_submitted,
last_updated,eta, bug_text_id,
os, os_build,platform, version,build,
profile_id, summary, view_state, sponsorship_total, sticky, fixed_in_version,
target_version, due_date
)
VALUES
( ?,?,?,?,
?,?,?,?,
?,?,?,?,
?,?,?,?,
?,?,?,?,
?,?,?,?,
?,?,?,?).

Tagscustom fields, summary

Relationships

related to 0015721 closedgrangeway Functionality to consider porting to master-2.0.x 
has duplicate 0012123 closeddhx Import/Export 1.0 error 401 
has duplicate 0012842 closedatrol XmlExportImport - Import XML failed 

Activities

docteur.cox

docteur.cox

2010-06-24 12:03

reporter   ~0025975

Export function does not include any profile information in the exported data.
As a consequence, the "profile_id" field of the BugData created during import is never initialized, while the database table constraints state that it must be not null.

KarlReichert

KarlReichert

2010-08-12 08:07

reporter   ~0026294

Last edited: 2010-08-12 08:07

I can confirm that. This bug is a duplicate of bug 0012123, by the way.

dhx

dhx

2010-08-14 01:23

reporter   ~0026312

Can someone check if the latest nightly snapshot of MantisBT 1.3.x resolves this issue? Issue 0012013 improved the XML import/export functionality a great deal.

Thanks

KarlReichert

KarlReichert

2010-08-16 05:44

reporter   ~0026330

I installed the current nightly build to test that, but I can't login into this build:

APPLICATION ERROR #2900
For security reasons MantisBT will not operate when $g_crypto_master_salt is not specified correctly in config_inc.php.
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.

I cannot find a solution for that. Can someone help me? Than I can test the new Im-/Export.

dhx

dhx

2010-09-14 09:38

reporter   ~0026712

The latest version of the manual contains information on how to set $g_crypto_master_salt.

Basically just set it to a completely random string (20+ characters) inside config_defaults_inc.pgp

wkarl

wkarl

2010-09-16 02:35

reporter   ~0026730

This only occurs to issues that contain the value 0 (zero) in the "profile_id" field. If the field has a different value, it is exported.

The problem is the following code in plugins/XMLImportExport/export.php :
[code]
foreach( $t_columns as $t_element ) {
$t_value = $t_row->$t_element;
if( empty( $t_value ) ) {
continue;
}
[/code]

The empty() function returns FALSE, if the field's value is 0 (zero).

This is an excerpt of the PHP manual, empty() function:
[excerpt]
Returns FALSE if var has a non-empty and non-zero value.

The following things are considered to be empty:

* "" (an empty string)
* 0 (0 as an integer)
* "0" (0 as a string)
* NULL
* FALSE
* array() (an empty array)
* var $var; (a variable declared, but without a value in a class)

[/excerpt]

Thus, variables containing 0 (zero) are considered empty.

This might also be a problem for other fields containing 0 (zero) values.

I modified the code above to:

[code]
foreach( $t_columns as $t_element ) {
$t_value = $t_row->$t_element;
if( strval( $t_value ) == "" ) {
continue;
}
[/code]

and it seems to work, I can not say if there are other problems with this code, though.

dhx

dhx

2010-09-17 21:59

reporter   ~0026753

It seems that the exporter is currently designed not to export properties that have empty/null values. Thus the importer should be detecting missing fields in the XML file and filling them with default values (taking into account the defaults set in config_defaults_inc.php).

Thus I think the fixes need to be made to the import side of the plugin to resolve this issue?

michield

michield

2012-02-02 08:57

reporter   ~0031105

I stumbled upon this problem, and looked into the DB

I found all my issues have "profile_id" 0, so I just did

"alter table mantis_bug_table change column profile_id profile_id int(7) unsigned default 0;"

and the import worked fine.

dregad

dregad

2012-09-18 09:39

developer   ~0032864

This was already fixed in master as part of 0012013

grangeway

grangeway

2013-04-05 17:56

reporter   ~0036207

Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch

Related Changesets

MantisBT: master-1.2.x cb825352

2012-09-18 01:51

dregad


Details Diff
XmlImportExport: Fix import error "Column 'profile_id' cannot be null"

In bug_api.php BugData class, the profile_id member variable defaults to
null but the DB bug table does not allow null values, causing the error.

Defaulting the variable to 0 resolves the problem.

Fixes 0012112
Affected Issues
0012112
mod - core/bug_api.php Diff File