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.

Cannot Redeclare lang() Problem

April 01, 2010 7:19pm

Subscribe [5]
  • #1 / Apr 01, 2010 7:19pm

    Stephen Lewis

    466 posts

    Hello,

    I keep running into a problem with the Language class, and it’s driving me spare.

    There are times when the Language class needs to be loaded and instantiated manually, typically when running some code from the ‘sessions_start’ hook.

    In the past, it was possible to do something like this:

    if ( ! class_exists('Language'))
    {
       require_once PATH_CORE .'core.language' .EXT;
       $LANG = new Language();
       $LANG->fetch_language_file(strtolower(get_class($this));
    }
    
    echo $LANG->line('something');

    In 1.6.8, a global ‘lang’ function was added, for use in View files. This would be all fine and dandy, but for the fact that core.system.php uses ‘require’, instead of ‘require_once’ to load the core.language.php file.

    This results in a “cannot redeclare lang()” error, and as far as I can tell, there’s no way around it.

    Am I missing something obvious here, or doing something horribly ill-advised? Or should this be filed as a bug?

    Any pointers would be much appreciated.

    Cheers,
    Stephen

  • #2 / Apr 01, 2010 9:00pm

    Brandon Jones

    5500 posts

    Hi Stephen,

    I’ll ping the developers on this and let you know the response.  Thanks for your patience.

  • #3 / Apr 01, 2010 9:37pm

    Stephen Lewis

    466 posts

    Thanks Brandon.

  • #4 / Apr 05, 2010 2:23am

    John Henry Donovan

    12339 posts

    Stephen,

    Just to let you know the devs have been pinged about this and we will let you know as soon as we hear anything back.

  • #5 / Apr 05, 2010 6:22am

    Stephen Lewis

    466 posts

    Cheers John.

    O

  • #6 / Apr 06, 2010 3:03pm

    Robin Sowell

    13255 posts

    😉  Obscure, but yes, annoying.  I ran it by Pascal and then switched it to require_once in core.system.php around line 582.  Should be fixed in the next release.

    Thanks for the ‘heads up’!

  • #7 / Apr 06, 2010 3:36pm

    Stephen Lewis

    466 posts

    Should be fixed in the next release.

    Thanks Robin.

    Cheers,
    Stephen

  • #8 / Apr 06, 2010 3:39pm

    Ingmar

    29245 posts

    Glad to see we were able to get to the bottom of this 😊 Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases