| Summary: | Warn that printing large barcode ranges can lead to running out of memory | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Philip Orr <philip.orr> |
| Component: | Tools | Assignee: | Bugs List <koha-bugs> |
| Status: | NEW --- | QA Contact: | Testopia <testopia> |
| Severity: | enhancement | ||
| Priority: | P5 - low | CC: | dcook |
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | --- |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: | Version(s) released in: | ||
| Circulation function: | |||
|
Description
Philip Orr
2025-10-31 16:13:28 UTC
Nice spot, Philip. This is a tricky one. I hoped that maybe checking the size of the array created by ($from .. $to) would be enough, but it turns out that ($from .. $to) is a very heavy CPU and RAM intensive operation itself when using the values 100101224 and 1000101274. On the face of it, we could minus $to from $from to get a difference to try to validate, but... I think barcodes are not necessarily positive integers. The ".." Perl range operator also has a magical auto-increment algorithm when applied to strings, so it might be difficult to take into account that magic... That being said... if you put $from = 'ax' and increment is with $from++, you'll get 'ay' same as when using the ".." range operator. So using a for loop with ++ increment operator and a max count might work. That should have a number of advantages in terms of CPU and RAM usage actually since the calculation should be quite stable. We'd also want another variable to test the last generated value, because something like: "from *x to az" will only yield *x, so you wouldn't want to increment 10000 times and get *x for each iteration. Anyway... perhaps not a perfect solution but hopefully it would be practical? I briefly wondered if Perl could automagically do a diff on BARCODE9999 minus BARCODE1000 but no... it did not like that haha. You can increment and decrement but there are no operations that can automagically determine the difference it seems. |