Cannot install at all, "Fatal error: Call to undefined function" :-(

Hello,

I've bumped into something I can't fix and understand myself...

I am trying to install Zen Photo Gallery on a server (Apache/php/mysql, standard stuff).

I downloaded and unpacked all files. I filled the data in the zp-config.php (database data). I then tried to load the install. Nope! Got the following error:

(First I tried to install Zen in a subdomain):

`Fatal error: Call to undefined function: mb_detect_encoding() in /home/XXXXXX/public_html/gallery/zp-core/lib-gettext/gettext.inc on line 101`

I tried to un-comment the lines:
`// define('WEBPATH', '/zenphoto');

// define('SERVERPATH', '/full/server/path/to/zenphoto');`

and specify the paths, but same error popped up.

I then thought, maybe problem is I try to install in a subdomain.

Tried a directory on a server (for example, I've created /photos), and got error:

`Fatal error: Call to undefined function: mb_detect_encoding() in /home/XXXXXX/public_html/photos/zp-core/lib-gettext/gettext.inc on line 101`

I can't do anything, I'm simply stuck...

What's this error, what does it mean and can I install Zen and how? :-)

Thanks for any help!! :-) It's very urgent, but I hope I can live till Monday:)

Cheers, Michel

Comments

  • acrylian Administrator, Developer
    Which version do you have? This is most likely related to the localization feature, the error means the function `mb_detect_encoding()` is not available. This happens if the multibyte support for php is not installed / activated. Could you please check your phpinfo if you have the mbstring package?
  • Sure, here it is: http://www.bluelink.net/info.php

    I think I didn't find any mentioning of mbstring ...

    What can I do, now?

    // PS I tried to install latest stable release, 1.1.6
  • acrylian Administrator, Developer
    Sadly you can't remove the gettext folder since it actually should take care that the gettext() calls we have for translation does not cause similar error since that would require a gettext package on your server, too.

    A possiblity would be to either define that function (just an empty one maybe) or comment out the part where it is required. I haven't tested that though.
  • Hmmm, strange...

    As I have quite good experience in WordPress, and I did install WordPress blog on the same server several times, without problems, does this mean that either: 1) WP doesn't require mb_detect_encoding(), or 2) can be installed even if it's not there?

    (To me ZP is a bit similat to WP, that's why I'm comparing them...)

    Can't something be changed in the core of ZP so it can work without this, too? :-)

    If not... What's the best way for me to proceed to install Zen Photo there?

    1) I do not think I can change the php package/modules on the server...
    2) So, if I must try to comment some lines in the gettext.inc file, then which ones exactly? (I am no php coder...) And what'll happen when a new version of Zen is released? I'll have to manually change them again and again, in that inc file, right? :(

    Thanks for all the help! :)

    Cheers, M.
  • acrylian Administrator, Developer
    Well, we have that feature in there secretly and more unfinished a while now, you are the first to report that problem as far as I know.

    1) Well, Zenphoto is not Wordpress but a certain similarity is indeed intended...:-) Wordpress has it's own modification of the gettext replacement libary (what you see in the zp-core/lib-gettext folder) so that most likely has a workaround for that. We plan to add a replacement like that later because this libary does not work at all as it is supposed to anyway, but we didn't manage that yet.

    2) I did a quick search on the file, I have found two function calls that might cause trouble:
    They are in gettext.inc line 101 and 104 in the function `_encode()`. Just comment out the whole function like this:
    `/* function _encode($text) {

    $source_encoding = mb_detect_encoding($text);

    $target_encoding = _get_codeset();

    if ($source_encoding != $target_encoding) {

    return mb_convert_encoding($text, $target_encoding, $source_encoding);

    }

    else {

    return $text;

    }

    } */`

    At least on my installation that causes no error. Since these gettext lib is not really used, it should do no harm.
  • Thanks a bunch!!

    I'll try this workaround and will report back later if it fixed things for me :)

    And, (on the sideline)... you know, I feel Zen Photo is very friendly little web app, with even friendlier developers & users around it! You should definitely become the new 'WP in organizing photos & albums' area of the web! I mean it! :)))

    Cheers, Michel
  • acrylian Administrator, Developer
    Thanks!
  • Hi, when I commented the lines you have recommended,

    I got a new error:

    `Fatal error: Call to undefined function: _encode() in /home/XXXXXX/public_html/gallery/zp-core/lib-gettext/gettext.inc on line 190`

    Here's the part in the code:

    `/**

    * Lookup a message in the current domain.

    */

    function _gettext($msgid) {

    $l10n = _get_reader();

    //return $l10n->translate($msgid);

    return _encode($l10n->translate($msgid));

    }`

    so line 190 is: `return _encode($l10n->translate($msgid));`

    Hm. Any ideas, how to continue...?...

    OK, idea (for future versions):

    If on the server the mbstring package is not activated or installed, can Zen detect this, and make parts of the code (via some 'if -- else' in PHP) related to it, not used?...

    I am no PHP coder, but I guess that if php_info() can show if the package IS or is NOT there, if-else can be created and this part of the code made not used...

    Hmmm?...

    For now, I'd like just to see, if I can somehow (using /**/ comments) make so the Zen Photo to be installed on this server...

    Thanks again!

    --M.
  • acrylian Administrator, Developer
    The lib-gettext is only a temporay solution to prevent errors on servers without the native gettext suppor. This libary is third-party and does not work as expected anyway, btu at least should prevent errors when native gettext is missing. Well, it seems we forgot about the mbyte but we can't think of all possible configuration variants.

    I have tested it on my test environment with and without native gettext enabled, and my fellow devs did with native gettext, too, but we didn't get those errors.

    You should be able to just comment out the function or just all the stuff within it. We currently experiment with that, too.

    Thanks for the report.
  • OK, what I tried: I commented some other lines in the gettext.inc file, where errors were showing. Finally, I think I commented everything which gave an error connected to `_gettext`.

    Then, what I saw:

    `Fatal error: Call to undefined function: gettext() in /home/bluelink/public_html/gallery/zp-core/functions.php on line 233`

    So, another file which again references to that...

    Hm. I can't comment code everywhere in all kinds of files, Zen'll then become too complicated and unstable for me, at the end... :-(

    I think, currently, if mbstring package ain't there, I can't use Zen Photo... if this is the core culprit for my issues:-(

    I'm happy I can contribute with a report of this bug:)

    But I am not so happy I can't use Zen (at least, on this server). Any other ideas?... Or should I wait for a nightly build which might address that?... :-) How can I help more?

    --M.
  • acrylian Administrator, Developer
    Well, `_gettext()` is one of the replacement functions this lib provides, the function we use is `gettext()`. If you look at the bottom of `zp-core/lib-gettext/gettext.inc` you will find a list of functions surounded by a `if(!function_exists("gettext") { }`. Pleas locate the line
    `function gettext($msgid) {

    return _gettext($msgid);

    }`

    and change it to
    `function gettext($msgid) {

    return $msgid;

    }`

    This should provide the gettext function if not existing without having any effect. We tried that at least yesterday and are working on a workaround. But since we don't get those errors, it's hard to solve.
  • OK! So, what I did:

    I deleted the modified by me gettext.inc file (as I have added too much comments into it;-), and replaced it with a new one (un-touched).

    Then, the *only* change I made in it, is the once you recommended to me:

    find:
    `function gettext($msgid) {

    return _gettext($msgid);

    }`

    and change it to:
    `function gettext($msgid) {

    return $msgid;

    }`

    After that, I tried to run setup again and here what I got:

    `[Zen Photo Setup] Setup

    Welcome to Zenphoto! This page will set up Zenphoto on your web server.

    Systems Check:

    pass: PHP version 4.4.6

    pass: PHP Safe Mode

    pass: PHP GD support

    warn: PHP gettext() support [is not present]

    Localization of Zenphoto currently requires native PHP gettext() support

    [[ all other things: OK (pass) too, skipping some text here ]]

    Go!

    zenphoto version 1.1.6 [1550]`

    So, I guess, if I click now the 'GO' button, Zen will be installed! :-)

    Thanks a lot for the help!!

    Suggestion: add some check; if `PHP gettext()` is not present, use if-else in the code (in gettext.inc?), to activate some sort of workaround (I changed part of the code, as you have advised me -- maybe this could be done automatically?) and so setup will be able to continue after producing this warning...

    Hope that my feedback will be able to let you squash one more bug in ZP :)))

    Cheers, Michel

    PS If anything else pops up, on this server, I'll notify you! :)
    PPS For now, even this thread might help other people fix things for them, in case they have trouble with gettext(), too:)
  • acrylian Administrator, Developer
    Actually we were already testing sort of what I suggested you to do. Gladly this seemed to work out for you!
    A workaround will surely be in one of the next nightly builds.

    Thanks again for reporting and testing. We are really dependend on that since we can't foresee all possible server configurations.
  • Sure, you're welcome! :-)

    Glad I helped! :-)

    Now going to set up tis new gallery :-)

    --M.
  • gunta Member
    I`ve got the same problem and can`t open the gettext.inc file for modification.
    With zenphoto 1.5 I didn`t have this problem.

    Fatal error: Call to undefined function mb_detect_encoding() in /xxx/htdocs/zenphoto/zp-core/lib-gettext/gettext.inc on line 101
  • acrylian Administrator, Developer
    Well, you got Zenphoto 1.5..:-)) Greetings to the future (sorry couldn't resist).

    Now seriously, please try the nightly build.
  • gunta Member
    Thanks I tried the latest nightly built, but:

    Fatal error: Call to undefined function gettext() in /xxx/zenphoto/zp-core/functions-i18n.php on line 6

    Fatal error: Call to undefined function gettext() in /xxx/htdocs/zenphoto/zp-core/setup.php on line 5
  • We have found this problem. It will be corrected in tonight's nightly build.
Sign In or Register to comment.