Array_Shift Issue

Hi,

I've just installed the latest version (1.3.1 [5736]) on my server and I keep getting this error on my admin page and on my gallery page:

Warning: array_shift() [function.array-shift]: The argument should be an array in /nfs/c02/h08/mnt/30806/domains/photos.pedramtorbati.com/html/zp-core/functions-i18n.php on line 470

Here are 2 pics that show the error: http://www.pedramtorbati.com/errors/

I searched the forum and although this error came up in the past it doesn't resolve for me.

My server is running: PHP 5.2.6 and mySQL 4.1.25

Love the program, would be great to fix this small issue! Thanks you in advance...

Comments

  • Something is corrupt in your database for these two pictures. You should probably rename them to get the database updated.

    Basically, the database conatins something that appears to be a multilingual string but is not.
  • Hi Sbillard,

    Thank you for getting back to me about this issue. I'll be honest, i'm rather new to all this so please excuse my ignorance. Can you explain what you mean more specifically? When you say rename "them", what is "them"? Do you mean I need to change code in the admin.php file?

    FYI - I downloaded zenphoto again from your site, installed it from scratch to a new URL and created a new My SQL database and got the same issue.

    Also, I have no idea if this matter but I checked the database on myPHPadmiin and saw that the tables have a mixed collation of "utf8_unicode_ci" and "latin1_swedish_ci". Is that what you mean by "multilingual string".

    My apologies again for probably sounding uneducated. I know I'm in over my head but hoping to learn.
  • acrylian Administrator, Developer
    Something is corrupt in your database for these two pictures. You should probably rename them to get the database updated.
    Well, he obviously meant the images. more exact their file names so they get fresh database entries.

    Regarding multilingual strings: Zenphoto is capable of storing several language versions of one title or description of an images (or other items). These are stored in one databse field but as a serialized array so Zenphoto can pick the right language version. Something has been corrupted with that in your database somehow.
  • Hi Acrylian,

    Let me clarify that those two images are just screen grabs. The problem showed up on my admin page header when I first finished the install (that's the screen grab from the first pic). Afterwards, I tested uploading a picture to a gallery and found that on the user side the heading of the webpage has the same error (second pic). I uploaded a new bigger screen grab which might explain this a little better: http://www.pedramtorbati.com/errors/Picture 3.png.

    Basically from the first second i finished the install and i was directed to the admin page I saw this error at the top.

    I posted my "functions-i18n.php" file here http://www.pedramtorbati.com/errors/ if you can to take a look at what could be corrupted. In case it was corrupted after the install, I tried taking the "functions-i18n.php" from the original software download folder from your site to overwrite the one that was on the server and it didn't fix it.

    To give you more info I'm being hosted on a gridserver on mediatemple.net and from my research other users have had great success with zenphoto on media temple. That's how I was referred to your software.

    I hope this helps.

    Thanks,

    p
  • acrylian Administrator, Developer
    Sorry, what we said still seems applicable. The function seems to want to use a value it expects to be an array which it is not if the multilingual feature is not enable.

    If something is corrupted it would be an entry in your database. If the file is best is to try a reupload.

    I don't know or ever heard of mediatemple since I am from Germany but I successfully installed Zenphoto on variouse (major) hosters over here without any problems.
  • That function is doing a pattern match on the data to be processed. In your case, the pattern matched a "serialized array" so the function is treating it as a set of multiple language strings. However, apparently the string is not a proper serialilzed array, thus the error that is reported.

    This is an indication of a corrupt database entry--something that perports to be an array but is not. It is actully possible that the server/database configuration is causing this. What warning reports did Setup give you? Specifically check things like the database character set defaults.

    If the database table fields are not UTF-8 then some characters with diacritical marks may cause it to choke. The symptom of this is truncation of the string at the offending character.
  • My setup errors were about the "magic_quotes_gpc" needing to be turned off. And that the "mbstring.internal_encoding" should be set at UTF-8. In response to those, this is the code I added to my php.ini file:

    magic_quotes_gpc=Off
    mbstring.internal_encoding=UTF-8

    Once I added that code the setup let me go forward. Am I missing something here?

    Here is the phpAdmin breakdown of the database I'm using: http://www.pedramtorbati.com/errors/Picture 8.png and one for the tables that were created: http://www.pedramtorbati.com/errors/Picture 7.png It shows that the collation for the tables are not all the same. They are not all UTF-8 unicode, for some reason some are latin1_swedish. These were automatically created by the setup so not sure why there is a difference here. Could this be the problem?
  • It is possible that the latin1_swedish fields are the problem. (An unfortunate default choice of the MySQL creators who were Sweedish)

    If your native language is English, then change those to UTF-8. (If not you will have to look at each value for diacritical marks as those will have to be re-done when the character set is changed.)

    Setup does not change these fields for the above reason.

    While you are at it, look at the images to see what their fields look like. We are looking for ones that start with "a:number:{". There should be a balanced set of braces, at least.
  • So I went through the database and manually changed all the tables to UTF-8_unicode_ci. That didn't solve the problem. I then went into each table and manually changed all the relevant fields from latin1 to UTF-8 and that also didn't solve the problem.

    You will have to help me out on "balanced set of braces"...here are 3 screen grabs of the revised "images" table with all the fields:

    http://www.pedramtorbati.com/errors/Picture 9.png
    http://www.pedramtorbati.com/errors/Picture 10.png
    http://www.pedramtorbati.com/errors/Picture 11.png

    I really don't ned a multilingual site. I just need an english version to work if that makes any difference.
  • It is actually the data that will contain that, not the field descriptions.
  • Do you mean that I can get past phpMyAdmin to see the data or code for the fields? If yes, then how?
  • You need to browse the table to see the data. Click on "browse" up at the top in the tabs.
  • Thank you. So I was only able to "browse" 3 tables out of the 14 that were created: administrators, captcha, and options. I posted them here:

    http://www.pedramtorbati.com/errors/browse-administrators.png
    http://www.pedramtorbati.com/errors/browse-captcha.png
    http://www.pedramtorbati.com/errors/browse-options.png

    For all the other tables I got this error trying to browse them:

    MySQL returned an empty result set (i.e. zero rows). (Query took 0.0022 sec)

    All I can see is the "structure" of the table. Does this seem right?
  • Presumably the other tables are empty. Not sure why that would be, thought I would expect that there would be entries at least for the images and albums tables.

    The options table does have one of these serialized arrays. It is the "gallery_title" row (third row). Looking back at the images of the original error it is likely that this row it the source of the problem.

    If you edit the row (click on the pencil icon) it will show the full text for the "value" field. Please report back that text. But also, clear the field to be empty and save the changes. If this is the only instance of the serialized array being corrupted, this will fix the problem.
  • YES! Well, almost. I deleted the value field and it fixed the error on my admin page which is great. But on my main page that users see it is still there although it used to show it twice and now it only shows it once. When I click on "archive view" or if I click to go to a test album I created the error is gone:

    http://www.pedramtorbati.com/errors/homepage.png
    http://www.pedramtorbati.com/errors/album view.png

    It seems we there is another bad value field somewhere that needs attention. Here is the value on the gallery_title row that was there before I deleted it:

    a:12:{s:5:"en_US";s:7:"Gallery";s:5:"de_DE";s:7:"Galerie";s:5:"es_ES";s:8:"Galería";s:5:"fr_FR";s:7:"Galerie";s:5:"gl_ES";s:8:"Galería";s:5:"it_IT";s:8:"Galleria";s:5:"ja_JP";s:15:"?????";s:5:"nl_NL";s:7:"Galerij";s:5:"pl_PL";s:7:"Galeria";s:5:"sv_SE";s:7:"Galleri";s:5:"zh_CN";s:6:"??";s:5:"zh_TW";s:6:"??";}

    So close!
  • Wait...very interesting...I realized that I hadn't yet added a name to my "gallery title" or my "gallery description". I threw in a few words and when I saved it I saw that the error message was finally gone from all links. As a test, I went back and deleted the title and description and the error didn't come back. I'm sure there is a better way to describe it but it seems once I deleted the bad value in my database I had to change out the variables in my admin page to "clear" out the remnants of the error. I don't know if it makes sense but it definitely worked.

    For anyone else with very little coding knowledge that might come across this in the future, it seems that the best approach to solving this issue is to first make sure you have added a name to "gallery title" and "gallery description" in your admin. Then go to your database, click on the "options" table, then click "browse" and make sure the "gallery_title" value is empty. If that doesn't work then make sure that all your tables are collated utf8_unicode_ci. If that doesn't work, then manually go inside each table and change any latin1 field to utf8. Hope this helps.

    Thank you very much for all your help!! Glad to finally use this software the right way.

    p
  • I suspect that the latin1 fields were the cause of this problem. Just curious, did Setup flag any of them? MySQL will discard characters it does not think are part of a field's collating sequence.

    Saving new values for the title and descriptions eliminated the problem as those were not "multi-lingual".
  • My only set-up errors were "magic_quotes_gpc" needing to be turned off and that the "mbstring.internal_encoding" should be set at UTF-8. For those I added code to the php.ini file. Also, it said that I had PHP 4 running on my server which I then switched to PHP 5 and that cleared it. Besides that I got a warning that MYSQL is not running 5 which is not optimal but ok. I don't remember anything coming up about latin1.

    I think latin1 was the key issue but it was painstaking to manually go and change all the fields in the tables (in the image table there are a lot of fields) so I would suggest someone start with the easy stuff first just in case the bad gallery_title value fixes it.

    Let me know if you have any more insights and thanks again for all your help. I may end up having to reinstall everything from scratch to figure out why I can't use ImageMagick and if I do I will test out whether latin1 is the cause. Hopefully it won't come to that though...

    p
  • Do your recall the version of PHP4 that was running? Some of the older versions did not let Zenphoto change the collation set of database fields. So if the database was setup initially with latin1 it would then have stayed so.

    You should check to see if there are any other DB fields that are latin1 and change the to UTF8. I am sure the Imageick problem is unrelated.
Sign In or Register to comment.