ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Channel Form and undefined constant MB_ENABLED

October 09, 2013 1:21pm

Subscribe [3]
  • #1 / Oct 09, 2013 1:21pm

    taxi.developers

    4 posts

    I recently upgraded to 2.7.1 from 2.5.x, and now the Channel Form tag is triggering an “undefined constant MB_ENABLED” PHP error notice.

    The following code is enough to reproduce this:

    {exp:channel:form channel="my_channel_name"}
    Hi!
    {/exp:channel:form}

    And the error message is as follows:

    A PHP Error was encountered
    Severity: Notice
    Message: Use of undefined constant MB_ENABLED - assumed 'MB_ENABLED'
    Filename: libraries/Encrypt.php
    Line Number: 367

    I’ve traced this back to the CI_Utf8 constructor (in /system/codeigniter/system/core/Utf8.php:47), where if the UTF-8 support test fails, the MB_ENABLED constant is never defined. This seems to be a bug.

    In my case, this particular test fails:

    $CFG->item('charset') == 'UTF-8'

    The value of $CFG->item(‘charset’) is ‘utf-8’, not ‘UTF-8’. How do I change this?

     

  • #2 / Oct 10, 2013 2:41pm

    webslinger

    14 posts

    I had the same problem.  Seeing your post, I changed line 47 in Utf8.php to:

    AND $CFG->item('charset') == 'UTF-8' OR 'utf-8'

    I’m not sure this is the ideal solution, but it seems to stop the errors

  • #3 / Oct 10, 2013 4:56pm

    taxi.developers

    4 posts

    Thanks for replying. Editing core files is never ideal, of course.

    I changed that part of the conditional to

    AND preg_match('/^utf\-?8$/i', $CFG->item('charset'))
    // accepts UTF-8, utf-8, utf8, etc..

    Seeing as your errors went away this may not be an issue, but your conditional is incorrect. You are not comparing ‘utf-8’ to the config item, just treating it as a Boolean on it’s own; it it will always resolve as TRUE because ‘utf-8’ is a non-empty string, even if the other tests fail:

    if (FALSE AND FALSE AND FALSE OR 'utf-8') {
    // the above is truthy, this block will always execute
    }

    Write it like this:

    AND ($CFG->item('charset') == 'UTF-8' OR $CFG->item('charset') == 'utf-8')
  • #4 / May 18, 2014 3:33pm

    Andrea DeMers

    18 posts

    I just upgraded from 2.5.x to 2.8.1, and am getting the same errors. I changed line 47 of /system/codeigniter/system/core/Utf8.php to “AND $CFG->item(‘charset’) == ‘UTF-8’ OR ‘utf-8’” and that got rid of the errors.

    This StackExchange thread (http://expressionengine.stackexchange.com/questions/15537/ee-upgrade-issue-mb-enabled) mentions the “iconv extension”. The client’s server doesn’t have iconv enabled and I don’t see this in the EECMS system reqs. Also, the server passed the ee wizard tests.

    Is this an issue with EE or my server?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases