Support

Account

Home Forums Bug Reports Undefined Variable 'value' in api.php

Solved

Undefined Variable 'value' in api.php

    • Phillip

    • November 6, 2013 at 5:48 pm

    Hey Elliot, small bug thats causing Notices when you have PHP error reporting turned on.

    File: advanced-custom-fields/core/api.php
    Line 636 (inside get_sub_field)

    // return false
    return $value[ $i ][ $field_name ];

    Neither $i or $value appear above in the function, so not sure if you’ve pasted this from another function by accident.

    Cheers!
    Phill

    • Elliot

    • November 7, 2013 at 2:23 pm

    Hi @phillip

    Thanks for the bug report.

    That line should be return false, I’ve fixed this and re-pushed the plugin to wordpress.org

    Hopefully not too many people experience this PHP notice and I can get away without a new version release for now.

    Thanks
    E

    • jamblo

    • November 9, 2013 at 2:58 am

    Hi Elliot

    Major problems here.

    I was seeing the error too in debug mode, so downloaded the new version you pushed to WP.org.

    I then go to my site and 50% of the fields on a massive flexible content field have disappeared from the page editor and ACF editor – they’re all fields that have image fields.

    HELP!

    • jamblo

    • November 9, 2013 at 3:07 am

    In case it helps: [www.]ellaberthoud.com/2013/

    That grid of boxes is controlled by a flexible content field.

    All the blank ones were images! Every single image related field has disappeared in the backend and there is no sign of them in the front.

    Cheers

    • Elliot

    • November 9, 2013 at 10:55 am

    Hi @jamblo

    Can you confirm 100% that it was updating to 4.3.0 for the second time that has caused this issue? Did your image field display before?

    How did you re-update to v4.3.0?

    If you edit your field group, is the image sub field available?
    If you edit your post, does the image sub field appear? What does it look like?

    Can you check your DB for the values in the wp_postmeta table? Are the values for the flexible content field visible?

    Thanks
    E

    • jamblo

    • November 9, 2013 at 11:55 am

    Hi Elliot

    Here’s the process I went through:

    1. Added a new field with a select drop down (with 1,2,3 as the options). Stuck “1” in the default field, saved and then added a field of this type to the homepage. At this point I saw the error (debug mode true) for the first time. Images were still there. I commented out my code pulling in the new field and the error (as outlined by the original poster) disappeared. Figured there was an issue with using “1” as the default number. Deleted the select drop down sub field and created a radio one instead, with no default declared. Refreshed the post editor, chose the radio button options that were needed and saved. Error was there again on front end.

    2. Googled the error, found this thread. Downloaded the latest version of ACF and uploaded through the plugins uploader in WP admin. Error on upload as plugin already exists. Go to FTP, rename old ACF folder and upload unzipped new files. Go to homepage, errors gone, all images gone. Rename new ACF folder, go to plugins, Add new, find ACF, install… No change.

    3. Go to page editor, half the fields are missing from the list, no fields with image field available from flexible field add panel. Go to ACF editor and my flexible field, all fields with image includes gone. Do not, at any point press save/submit, so am sure the data is still there – especially as the homepage is still showing the empty space where the fields were before this happened. Go back to this thread, find original code (that the update fixed) edit api.php file to display old code, refresh homepage, errors back, images still broken. Undo api.php change.

    To answer your questions:

    If I go to create a new flexible field it will not let me create ANY sub fields. If I go to edit my existing flexible content field I cannot add any new fields. The duplicate, etc. links on the left are gone too. In the post editor, all flexible content fields that have an image field are gone.

    I can’t check the db right now as need to get access, but the fact the boxes still appear in the page (and the text data shows for those entries, just not the images) would suggest to me that the data is still in the db.

    I hope that helps. It’s 1am so I’m. Going to sleep, back online in 7/8 hours. You’re welcome to login to my site if you want. Just send me an email.

    James

    • jamblo

    • November 9, 2013 at 10:46 pm

    @elliot

    wp_postmeta for post id 4 (my homepage):

    a:26:{i:0;s:11:"large_image";i:1;s:11:"small_quote";i:2;s:11:"small_image";i:3;s:11:"large_quote";i:4;s:14:"portrait_image";i:5;s:14:"portrait_image";i:6;s:11:"small_image";i:7;s:14:"portrait_image";i:8;s:14:"portrait_image";i:9;s:11:"large_image";i:10;s:7:"twitter";i:11;s:9:"listening";i:12;s:7:"reading";i:13;s:9:"news_feed";i:14;s:11:"large_quote";i:15;s:16:"recommended_read";i:16;s:8:"big_link";i:17;s:11:"small_image";i:18;s:16:"little_link_wide";i:19;s:11:"little_link";i:20;s:11:"little_link";i:21;s:11:"little_link";i:22;s:8:"big_link";i:23;s:11:"little_link";i:24;s:8:"big_link";i:25;s:11:"little_link";}

    That is the correct order they are supposed to display – note large_image, followed by small_quote – so I guess all is well in terms of the database.

    Looking forward to your thoughts!

    Thanks
    James

    • Elliot

    • November 10, 2013 at 3:15 pm

    Hi @phillip

    Your value above shows all the values as a serialized array. Is this correct?
    Was this from a var_dump or is this the only value in the DB?

    Can you please provide some login details here? You can use the ‘private reply’ options to hide the details

    Thanks
    E

    • jamblo

    • November 10, 2013 at 5:03 pm
    This reply has been marked as private.
    • Elliot

    • November 11, 2013 at 3:50 pm

    Hi @jamblo

    I logged in and had a look at the home page. All the data is there exept the images, so I don’t understand how your data could be saved as a serialized array as previously posted.

    Have you tried re-selecting the images for each image field?
    Have you re-saved the home page yet?
    Do you have any code which could be hooking into any ACF filter / action?

    Thanks
    E

    • jamblo

    • November 11, 2013 at 6:58 pm
    This reply has been marked as private.
    • Phillip

    • November 12, 2013 at 9:11 am
    This reply has been marked as private.
    • Elliot

    • November 12, 2013 at 4:53 pm

    Hi @phillip

    Most likely because this is your thread…

    Thanks for the warning
    E

    • Elliot

    • November 12, 2013 at 4:55 pm

    Hi @jamblo

    I can see the image fields just fine as shown in this attachment

    • jamblo

    • November 12, 2013 at 7:06 pm

    Yeah, it looks like some are still hanging about there, but several have disappeared entirely from the ACF editor and are not in the “add repeater” section:

    ACF Flexible Content - options missing

    Yet, those broken fields still appear in the front end, as blank boxes:
    [http://www.]ellaberthoud.com/2013/ – and in the postmeta in the database, as outlined above.

    Is there any way of retrieving this field data? Can you see it in the mysql database? Should I just give up and start again?

    Thanks
    James

    • Elliot

    • November 13, 2013 at 1:34 pm

    Hi @phillip

    It is hard for me to guess which is missing and which isn’t
    Can you please provide very clear instructions as to what exactly has changed?

    What do you mean by:
    “but several have disappeared entirely from the ACF editor”

    Also, what do you mean by:
    “and are not in the “add repeater” section:”

    I removed your mysql data from this post for security reasons, so I can’t access your DB data. Perhaps you could look at the postmeta table and take a screenshot of all the postmeta data for the home page ID?

    Thanks
    E

    • jamblo

    • November 13, 2013 at 9:43 pm

    The image-related sub-fields had disappeared from where you create them… eg.

    WP Admin > Custom Fields > “Front Page Boxes” > Flexible Content Field.

    They had also disappeared from Pages > Edit > Front Page > “Front Page Boxes” FCF.

    Yet, they still appeared on the front-end and the database (as above), until I pressed update.

    Anyway, I gave up trying to explain what was wrong and have just spent two hours creating it all again.

    Thanks for trying to help. There was obviously an error that corrupted it all, but not knowledgeable enough on the mechanics to put my finger on it.

    James

    • Elliot

    • November 14, 2013 at 3:54 pm

    Hi @jamblo

    Thanks for the follow up. Glad you got it working again.
    Yes, this must have unfortunately been some sort of corruption.

    Although I can’t provide any help just yet, I can assure you that this kind of issue won’t be a problem in ACF v5!

    v5 introduces a new data structure for sub fields which will make for a much more reliable plugin!

    Should be released in a few months.

    Thanks
    E

    • jamblo

    • November 14, 2013 at 8:12 pm

    Looking forward to it! Cheers.

Viewing 19 posts - 1 through 19 (of 19 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.