Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

XML import/export plugin fixes

This resolves a number of warnings and notices with the plugin when
strict error reporting.

As far as I can tell, the fixes mentioned in issue #12013 after dhx
committed the changes (8401753), i.e.
bugnotes are not needed:
- ~28391 by schoppi71: don't think this is a bug
- ~28855 by ninguno: already included in dhx's commit
commit de607de3542df356704c62c3ad512371a80c6ecb 2 parents bdb6e9a + aca7cdf
@dregad dregad authored
View
2  core/file_api.php
@@ -1021,7 +1021,7 @@ function file_get_content( $p_file_id, $p_type = 'bug' ) {
$result = db_query_bound( $query, array( $p_file_id ) );
$row = db_fetch_array( $result );
- if ( $f_type == 'bug' ) {
+ if( $p_type == 'bug' ) {
$t_project_id = bug_get_field( $row['bug_id'], 'project_id' );
} else {
$t_project_id = $row['bug_id'];
View
1  plugins/XmlImportExport/ImportXml.php
@@ -171,6 +171,7 @@ public function import( ) {
printf( "Processing cross-references for %s issues...", count( $importedIssues ) );
foreach( $importedIssues as $oldId => $newId ) {
$bugData = bug_get( $newId, true );
+ $content_replaced = false;
$bugLinkRegexp = '/(^|[^\w])(' . preg_quote( $this->source_->issuelink, '/' ) . ')(\d+)\b/e';
// replace links in description
View
39 plugins/XmlImportExport/ImportXml/Issue.php
@@ -23,8 +23,8 @@
*/
-require_once( 'bug_api.php' );
-require_once( 'user_api.php' );
+require_api( 'bug_api.php' );
+require_api( 'user_api.php' );
require_once( 'Interface.php' );
/**
@@ -71,6 +71,10 @@ public function process( XMLreader $reader ) {
$t_project_id = helper_get_current_project(); // TODO: category_get_id_by_name could work by default on current project
$userId = auth_get_current_user_id( );
+ $t_custom_fields = array();
+ $t_bugnotes = array();
+ $t_attachments = array();
+
$depth = $reader->depth;
while( $reader->read() &&
($reader->depth > $depth ||
@@ -153,7 +157,7 @@ public function process( XMLreader $reader ) {
$reader->nodeType != XMLReader::END_ELEMENT ) ) {
if ( $reader->nodeType == XMLReader::ELEMENT ) {
if ($reader->localName == 'custom_field') {
- $i++;
+ $t_custom_fields[++$i] = new stdClass();
}
switch ( $reader->localName ) {
default:
@@ -174,7 +178,7 @@ public function process( XMLreader $reader ) {
$reader->nodeType != XMLReader::END_ELEMENT ) ) {
if ( $reader->nodeType == XMLReader::ELEMENT ) {
if ($reader->localName == 'bugnote') {
- $i++;
+ $t_bugnotes[++$i] = new stdClass();
}
switch ( $reader->localName ) {
case 'reporter':
@@ -207,7 +211,7 @@ public function process( XMLreader $reader ) {
$reader->nodeType != XMLReader::END_ELEMENT ) ) {
if ( $reader->nodeType == XMLReader::ELEMENT ) {
if ($reader->localName == 'attachment') {
- $i++;
+ $t_attachments[++$i] = new stdClass();
}
switch ( $reader->localName ) {
default:
@@ -249,7 +253,19 @@ public function process( XMLreader $reader ) {
// add bugnotes
if ( $this->new_id_ > 0 && is_array( $t_bugnotes ) && count( $t_bugnotes ) > 0 ) {
foreach ( $t_bugnotes as $t_bugnote) {
- bugnote_add( $this->new_id_, $t_bugnote->note, $t_bugnote->time_tracking, $t_bugnote->private, $t_bugnote->note_type, $t_bugnote_>note_attr, $t_bugnote->reporter_id, false, $t_bugnote->date_submitted, $t_bugnote->last_modified, true );
+ bugnote_add(
+ $this->new_id_,
+ $t_bugnote->note,
+ $t_bugnote->time_tracking,
+ $t_bugnote->private,
+ $t_bugnote->note_type,
+ $t_bugnote->note_attr,
+ $t_bugnote->reporter_id,
+ false,
+ $t_bugnote->date_submitted,
+ $t_bugnote->last_modified,
+ true
+ );
}
}
@@ -259,10 +275,13 @@ public function process( XMLreader $reader ) {
// Create a temporary file in the temporary files directory using sys_get_temp_dir()
$temp_file_name = tempnam( sys_get_temp_dir(), 'MantisImport' );
file_put_contents( $temp_file_name, base64_decode( $t_attachment->content ) );
- $file_data = array( 'name' => $t_attachment->filename,
- 'type' => $t_attachment->file_type,
- 'tmp_name' => $temp_file_name,
- 'size' => filesize( $temp_file_name ) );
+ $file_data = array(
+ 'name' => $t_attachment->filename,
+ 'type' => $t_attachment->file_type,
+ 'tmp_name' => $temp_file_name,
+ 'size' => filesize( $temp_file_name ),
+ 'error' => UPLOAD_ERR_OK,
+ );
// unfortunately we have no clue who has added the attachment (this could only be fetched from history -> feel free to implement this)
// also I have no clue where description should come from...
file_add( $this->new_id_, $file_data, 'bug', $t_attachment->title, $p_desc = '', $p_user_id = null, $t_attachment->date_added, true );
View
2  plugins/XmlImportExport/lang/strings_english.txt
@@ -50,7 +50,7 @@ $s_plugin_XmlImportExport_description = 'Adds XML based import and export capabi
$s_plugin_XmlImportExport_import = 'Import issues';
$s_plugin_XmlImportExport_export = 'XML Export';
-$s_plugin_XmlImportExport_importing_in_project = 'Importing issues in project:';
+$s_plugin_XmlImportExport_importing_in_project = 'Importing issues into project: \'%s\'';
$s_plugin_XmlImportExport_import_options = 'Import options';
$s_plugin_XmlImportExport_cross_references = 'Cross references';
View
9 plugins/XmlImportExport/pages/import.php
@@ -43,17 +43,20 @@
?>
-<div class="center">
+<div class="table-container">
<form name="file_upload" method="post" enctype="multipart/form-data" action="<?php echo plugin_page( 'import_action' )?>">
<?php echo form_security_field( 'plugin_xml_import_action' ) ?>
<input type="hidden" name="project_id" value="<?php echo $t_project_id;?>" />
-<table class="width100">
+<table>
<tr>
<td class="form-title" colspan="2">
<?php
- echo plugin_lang_get( 'importing_in_project' ) . ' ' . string_display( project_get_field( $t_project_id, 'name' ) );
+ printf(
+ plugin_lang_get( 'importing_in_project' ),
+ string_display( project_get_field( $t_project_id, 'name' ) )
+ );
?>
</td>
</tr>
View
13 plugins/XmlImportExport/pages/import_action.php
@@ -46,8 +46,17 @@
print_manage_menu( 'manage_import_issues_page.php' );
-echo "<pre>\n";
+?>
+
+<br />
+
+<pre>
+
+<?php
$importer->import( );
-echo "</pre>\n";
+?>
+
+</pre>
+<?php
html_page_bottom();
Please sign in to comment.
Something went wrong with that request. Please try again.