diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm
index 0c98d6f2aa..930e0f6ef4 100644
--- a/C4/Labels/Label.pm
+++ b/C4/Labels/Label.pm
@@ -100,7 +100,9 @@ sub _get_text_fields {
my $format_string = shift;
my $csv = Text::CSV_XS->new({allow_whitespace => 1});
my $status = $csv->parse($format_string);
- my @sorted_fields = map {{ 'code' => $_, desc => $_ }} $csv->fields();
+ my @sorted_fields = map {{ 'code' => $_, desc => $_ }}
+ map { $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
+ $csv->fields();
my $error = $csv->error_input();
warn sprintf('Text field sort failed with this error: %s', $error) if $error;
return \@sorted_fields;
diff --git a/installer/data/mysql/de-DE/optional/sample_creator_data.sql b/installer/data/mysql/de-DE/optional/sample_creator_data.sql
index bcd610a183..91d7d006e6 100644
--- a/installer/data/mysql/de-DE/optional/sample_creator_data.sql
+++ b/installer/data/mysql/de-DE/optional/sample_creator_data.sql
@@ -3,7 +3,7 @@
LOCK TABLES `creator_layouts` WRITE;
/*!40000 ALTER TABLE `creator_layouts` DISABLE KEYS */;
-INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','
+INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','
diff --git a/installer/data/mysql/en/optional/sample_creator_data.sql b/installer/data/mysql/en/optional/sample_creator_data.sql
index bcd610a183..91d7d006e6 100644
--- a/installer/data/mysql/en/optional/sample_creator_data.sql
+++ b/installer/data/mysql/en/optional/sample_creator_data.sql
@@ -3,7 +3,7 @@
LOCK TABLES `creator_layouts` WRITE;
/*!40000 ALTER TABLE `creator_layouts` DISABLE KEYS */;
-INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, callnumber','','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','
+INSERT INTO `creator_layouts` VALUES (17,'CODE39',1,'BIBBAR','Label Test',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','','Labels'),(18,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','','Labels'),(19,'CODE39',1,'BAR','DEFAULT',0,'TR',3,'POINT',0,'L','title, author, isbn, issn, itemtype, barcode, itemcallnumber','','Labels'),(20,'CODE39',1,'BAR','Test Layout',0,'TR',10,'POINT',0,'L','barcode','
diff --git a/labels/label-create-xml.pl b/labels/label-create-xml.pl
index a6c580846d..dd83f1d020 100755
--- a/labels/label-create-xml.pl
+++ b/labels/label-create-xml.pl
@@ -62,9 +62,10 @@ foreach my $item (@$items) {
format_string => $layout->get_attr('format_string'),
);
my $format_string = $layout->get_attr('format_string');
- my @data_fields = split(/, /, $format_string);
+ my @data_fields = map { $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
+ split(/, /, $format_string);
my $csv_data = $label->csv_data();
- for (my $i = 0; $i < (scalar(@data_fields) - 1); $i++) {
+ for (my $i = 0; $i <= (scalar(@data_fields) - 1); $i++) {
push(@{$xml_data->{'label'}[$item_count]->{$data_fields[$i]}}, $$csv_data[$i]);
}
$item_count++;
diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl
index 470092d90e..6a702122b2 100755
--- a/labels/label-edit-layout.pl
+++ b/labels/label-edit-layout.pl
@@ -130,7 +130,7 @@ elsif ($op eq 'save') {
font_size => $cgi->param('font_size') || 3,
callnum_split => ($cgi->param('callnum_split') ? 1 : 0),
text_justify => $cgi->param('text_justify') || 'L',
- format_string => $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, callnumber',
+ format_string => $cgi->param('format_string') || 'title, author, isbn, issn, itemtype, barcode, itemcallnumber',
);
if ($layout_id) { # if a label_id was passed in, this is an update to an existing layout
$layout = C4::Labels::Layout->retrieve(layout_id => $layout_id);
diff --git a/t/Labels.t b/t/Labels.t
new file mode 100644
index 0000000000..2450794cce
--- /dev/null
+++ b/t/Labels.t
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+#
+# for context, see http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=2691
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+BEGIN {
+ use_ok('C4::Labels::Label');
+}
+
+my $format_string = "title, callnumber";
+my $parsed_fields = C4::Labels::Label::_get_text_fields($format_string);
+my $expected_fields = [
+ { code => 'title', desc => 'title' },
+ { code => 'itemcallnumber', desc => 'itemcallnumber' },
+];
+is_deeply($parsed_fields, $expected_fields, '"callnumber" in label layout alias for "itemcallnumber" per bug 5653');