lat9 / options_stock_support

Products' Options' Stock Manager: Support Thread
0 stars 3 forks source link

change to name truncation #30

Closed torvista closed 4 years ago

torvista commented 4 years ago

Currently

if ($name_length + $message_length > $this->name_max_length) {
                    $products_name = $this->subString($products_name, 0, $name_length - 3) . '...';
                    $pid = $class->products[$i]['id'];
                    trigger_error("Product #$pid, name truncated to '$products_name', due to database size limitation.", E_USER_WARNING);
                }

The truncation does not take into account by how much the combined texts exceed the db field limit.

I've done this:

if ($name_length + $message_length > $this->name_max_length) {
                    $excess = $name_length + $message_length - $this->name_max_length + 3;
                    $products_name = $this->subString($products_name, 0, $name_length - $excess) . '...';
                    $pid = $class->products[$i]['id'];
                    trigger_error("Product #$pid, name truncated to '$products_name: as product name length ($name_length) + stock message length ($message_length) > table orders_products->products_name field length ($this->name_max_length).", E_USER_WARNING);//steve added size info
                }
lat9 commented 4 years ago

I'll address this in a forthcoming bugfix release.