Forums

[Plugin: NextGEN Custom Fields] PHP Error Warning (9 posts)

  1. brtepley
    Member
    Posted 2 years ago #

    Is there a quick fix for this error: Warning: Attempt to assign property of non-object in .../wp-content/plugins/nextgen-gallery-custom-fields/ngg-custom-fields.php on line 555.

    I can't find any info on this error warning.

  2. shauno
    Member
    Posted 2 years ago #

    Hi brtepley

    What version of NextGEN Gallery, and NextGEN Custom Fields are you using?

    Also, when do you get the error?

  3. greligioso
    Member
    Posted 2 years ago #

    I am getting the same error. I get it on the post.

    NextGEN Gallery Version 1.3.5
    NextGEN Custom Fields Version 0.5

  4. brtepley
    Member
    Posted 2 years ago #

    I am using 1.3.5, as well... Custom Fields 0.5.

    I can get the field to show up in my template, everything seems to work perfectly, but the error message at the top of the screen.

    I created a template based on the 'gallery-caption' template. I added the gallery to a page and when I view the page the error shows at the top, but doesn't seem to effect the output. The field shows up, my layout shows up.

    I am excited to use this plugin! I hope I can get it to work.

    Here is line 550 - 555 -571:

    function nggcf_image_obj($pictureObj, $pid) {
    		global $nggcf_values;
    
    		nggcf_hold_field_values($pid);
    
    		$pictureObj->ngg_custom_fields = array();
    		foreach ($nggcf_values[$pid] as $key=>$val) {
    			$pictureObj->ngg_custom_fields[$key] = stripslashes($val->field_value);
    		}
    
    		return $pictureObj;
    	}
    
    	function nggcf_get_gallery_field($gid, $fname) {
    		global $nggcf_field_values;
    
    		nggcf_hold_gallery_field_values($gid);
    
    		return $nggcf_field_values[$gid][$fname];
    	}
    //}
    ?>
  5. shauno
    Member
    Posted 2 years ago #

    What version of PHP are you running?
    I'm stumped. I know what the error means, but I can't reproduce it. I can't see anyway that the $pictureObj variable wouldn't be an object.

    But if you say it still works, then just try replacing line 555, currently this:
    $pictureObj->ngg_custom_fields = array();
    with this
    @$pictureObj->ngg_custom_fields = array();

    Notice the @ symbol in front of it now. This is just a way to suppress the error.

    I am still trying to debug this, but it's tough without being able to get the error myself.

    Let me know if that quick fix works for you! :)

  6. brtepley
    Member
    Posted 2 years ago #

    Thanks shauno! Your fix worked.

    I am running PHP version 5.2.9.

    Is is there anything else I can let you know that will help?

    The plugin is exactly what I was looking for and it works perfectly!

  7. shauno
    Member
    Posted 2 years ago #

    Glad the fix worked for you. I have updated the plugin to include it for future downloads.

    Thanks for pointing out the bug, it's always good to get feedback!

  8. rdimou
    Member
    Posted 2 years ago #

    Ok thanks this with the @ symbol helped to supress the warnings. but how we solve this problem? what is it?

  9. shauno
    Member
    Posted 2 years ago #

    Hey rdimou
    Basically it appears as though the $pictureObj variable was not coming through as an object as expected. Because PHP is loosely typed, and doesn't require me to declare my variable as an array before using it as one, it won't break the code to just suppress the error.
    Not ideal, but that's the cost of free :)

    I am working on a new release, but I have to wait for the new release of NextGEN before I can complete it.

Topic Closed

This topic has been closed to new replies.

About this Topic