WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
[resolved] Latest Update Gives Many Undefined Index Errors (5 posts)

  1. MPSwebdev
    Member
    Posted 1 year ago #

    Just updated the new version of this wonderful plugin which I use everywhere on my websites, including the public website and WP dashboard on the Options page.

    Unfortunately the new update caused many undefined index errors to pop up now. I think I know a symptom of the cause. It is because I add a group of custom field options with different features to my page template, so the code for the field is there (with an if conditional to check for values) whether there is any information in the field or not. With the new conditional logic feature (amazing new addition) I allow the user to chose whether or not they want to use that feature with a check box on the WP Edit screen. For instance I have setup a special video player and photo album code that will appear or not based on the user entering the values for those fields. I am very excited for this new way of creating theme options on pages.

    So what I have come to realize is this "undefined index error" message appears when there is no information entered in a field, while the code is still there checking if it exists. Before the update all I needed was an if conditional for field values so it would check whether to use the rest of the code. Now apparently it causes PHP to attempt to access something that is not there, therefore giving me the undefined index error. I looked into this a little bit and apparently it is something that happens in plugins when isset() is not used correctly.

    The error only appears in the latest update of this plugin. Please fix so I can update my website without worrying a bunch of these errors will now appear.

    Below is an example code that causes the error when the initial if conditional returns no value.

    <?php // TESTIMONIALS CUSTOM FIELDS
    				if(get_field('testimonials')) : ?>
    					<ul id="testimonials">
    					<?php while(the_repeater_field('testimonials')) : ?>
    					    <li>
    						<p><?php the_sub_field('feedback') ?><br />
    						<em><?php the_sub_field('customer') ?></em></p>
    					    </li>
    					<?php endwhile; ?>
    					</ul><!-- end .testimonials -->
    				<?php endif; // end testimonials fields ?>

    http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. elliotcondon
    Member
    Plugin Author

    Posted 1 year ago #

    Hi @MPSwebdev

    Can you report the actual error?
    Also, does updating to 3.5.3.1 help?

    Thanks
    Elliot

  3. MPSwebdev
    Member
    Posted 1 year ago #

    Oh thank you! 3.5.3 was giving the undefined errors but 3.5.3.1 fixed it. Great.

  4. Ov3rfly
    Member
    Posted 1 year ago #

    I saw similar PHP Notices with 3.5.3 when WP_DEBUG in wp-config.php was set to true.

    Edit: Seems to be fixed with 3.5.3.1

    Was able to reproduce the PHP Notice with 3.5.3 by using get_field( 'some-non-existing-field' ) somewhere:

    Notice: Undefined index: key in /var/.../htdocs/wp-content/plugins/advanced-custom-fields/core/fields/acf_field.php on line 236

  5. elliotcondon
    Member
    Plugin Author

    Posted 1 year ago #

    Hi @Ov3rfly

    Thanks, my WP_DEBUG is always true. I think my server was just being lenient with action/hook PHP errors...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic