ZF-11964: Some Zend_Barcode Object adapters denies correct length barcodes

Issue Type: Bug Created: 2012-01-03T10:35:11.000+0000 Last Updated: 2012-02-26T06:56:20.000+0000 Status: Open Fix version(s): Reporter: Damien Nicolas (gordontesos) Assignee: Mickael Perraud (mikaelkael) Tags: - Zend_Barcode

Related issues: Attachments:


Generating a barcode with a correct length length (for example, a 13-chars ean13 code) returns exception, saying ""1234567890123" should have a length of 13 characters". Even with a "'withChecksum' => false" in the Object options, the checksum is always appended, because of the "_mandatoryChecksum" default option in most of the adapters. I don't understand why this option is set, and I think I should be able to pass a complete ean13 with my own checksum. So, I just commented out the "$this->_mandatoryChecksum = true;" line in Zend_Barcode_Object_Ean13.php.


Posted by Mickael Perraud (mikaelkael) on 2012-01-03T10:43:20.000+0000

Even if I can understand your question, why can't you simply give it: substr($code, 0, 12) and it will append the checksum without problem?

Posted by Damien Nicolas (gordontesos) on 2012-01-03T10:52:33.000+0000

Just because I spend much time understanding why I couldn’t pass a simple and complete ean13, and because this class should have an out-of-the-box functionning.

Posted by Mickael Perraud (mikaelkael) on 2012-01-03T11:59:02.000+0000

The out-of-the-box is to provide the text to encode (and only the text to encode) and Zend_Barcode will append (if nececessary but in case of EAN13 it's mandatory) the checksum for you.

Posted by Damien Nicolas (gordontesos) on 2012-01-03T12:16:35.000+0000

Well, but can you tell me why is this param mandatory ? It seems that removing it does not break anything. Or is there a way to deactivate it without altering the class ?

Posted by Mickael Perraud (mikaelkael) on 2012-01-03T12:25:00.000+0000

Because it's in the standard (…). You must have a checksum for an EAN13. It isn't the case for all barcodes. That's why we have 'withChecksum' option. But in case of EAN13, you have '_mandatoryChecksum' that overrides the value of the 'withChecksum' option. Because of the interaction with Zend_Validate_Barcode, we can't provide (today) a complete text with an incorporated checksum to the EAN13 object.

Posted by Mickael Perraud (mikaelkael) on 2012-01-03T12:27:16.000+0000

My question is: do you want a documentation with a more complete explanation on this point or the ability to provide the 13 characters?

Posted by Damien Nicolas (gordontesos) on 2012-01-03T12:43:50.000+0000

In fact, any of the solutions would save time :) but maybe, the class could check if the checksum is provided by the barcode string, and remove it itself if necessary.

I understand the blocking with Zend_Validate_Barcode, but if I just remove the _mandatoryChecksum param, the barcode validates successfully. What’s wrong with this?

Posted by Mickael Perraud (mikaelkael) on 2012-01-03T13:04:51.000+0000

I can add a check to verify that the provided length is exactly the '_barcodeLength' and in this case not appending the checksum. But this won't be possible to provide a barcode of 5 characters + 1 checksum. Because I have also a '_addLeadingZeros' to complete a partial barcode. And I don't know how to determine if a text to encode is an error, a partial or a complete barcode.

You can of course remove '_mandatoryChecksum' in your copy of the library but I can't do this in ZF library. The problem will be for you for upgrading. The other solution is to extend Zend_Barcode_Object_Ean13 in your own library and to use the 'barcodeNamespace' option. In this case, the upgrade to ZF 1.12 won't be a problem :)

Posted by Adam Lundrigan (adamlundrigan) on 2012-02-26T06:56:20.000+0000

bq. but I can't do this in ZF library

Does this mean the issue can be closed as "Wont' Fix"?

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.