php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66070 UTF8 Keys Truncated at 15 When mbstring Installed
Submitted: 2013-11-09 03:45 UTC Modified: 2015-04-11 17:15 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ewilde at bsmdevelopment dot com Assigned: cmb (profile)
Status: Closed Package: ODBC related
PHP Version: 5.5.5 OS: CentOS 6.4
Private report: No CVE-ID: None
 [2013-11-09 03:45 UTC] ewilde at bsmdevelopment dot com
Description:
------------
It is a well-known fact that ODBC support truncates returned database keys to 31 characters. No surprise there, since the key name length is hard coded at 32 bytes in php_odbc_includes.h. And, no complaints either, since we've all learned how to live with it.

However, when "mbstring" support is compiled into PHP using "--enable-mbstring" at build time, the keys are now truncated at 15. This happens even when the server and database are set to a single-byte character set such as UTF8.

In my case, I am using mysql-5.6.14, unixODBC-2.3.2 and mysql-connector-odbc-5.2.6-src. I have set "character-set-server = utf8" in my.cnf and have set the default database character set with "alter database character set = 'utf8';" but still no joy.

The obvious fix is to recompile PHP with "char name[64];" in the odbc_result_value structure in php_odbc_includes.h. However, if it is possible, ODBC support should query the database and determine which character set is in use (e.g. the query in question under MySQL is "show variables like 'character_set_database';"). If it is an 8-byte character set, the mbstring support should be turned off and the full 31-byte keys returned. If it is not possible, I throw my vote behind changing the key length to 64 by default (regardless of the reluctance to do so as expressed in Bug #30043).


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-11 17:15 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-04-11 17:15 UTC] cmb@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

The 32 byte limit has already been mitigated; the field name can
have up to 256 bytes as of PHP 5.4.0. Unfortunately, there has been
a temporary regression (at least PHP 5.5.3 and 5.5.4 have been
affected), but since PHP 5.5.7 the limit is 256 bytes again.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC