Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.6.2
-
Component/s: Resource
-
Labels:None
-
Environment:Windows 2003 Server CHT version, php 5.X, MySQL 5.X
-
Database:MySQL
-
Affected Branches:MOODLE_16_STABLE
-
Fixed Branches:MOODLE_16_STABLE, MOODLE_17_STABLE
Description
Insert a Chinese charachter string to label resource result error.
For example. Insert a label, Content as [????]: ?????! ??????, ?????????????.
Error report as follow:
---------------------------------------------------------------
Data too long for column 'name' at row 1
INSERT INTO mdl_label ( COURSE, NAME, CONTENT, TIMEMODIFIED ) VALUES ( 1, '[????]: ?????! ??????..', '[????]: ?????! ??????, ?????????????. ', 1159673300 )
Could not add a new instance of label
----------------------------------------------------------------------------------------------------------------
This bug is in /moodle/mod/label/lib.php line 16:
$label->name = substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";
Suggest correct source as follow:
mb_internal_encoding("UTF-8");
$label->name = mb_substr($label->name, 0, LABEL_MAX_NAME_LENGTH)."...";