• I noticed a conflict where uploading new images via NG Gallery was triggering an error message. I’m on NG Galleries v2.3.

    My Apache error log was showing this error:
    PHP Fatal error: Call to undefined method stdClass::id() in /httpdocs/wp-content/plugins/nextgen-gallery-voting/ngg-voting.php on line 1584, referer: /wp-admin/admin.php?page=ngg_addgallery

    The solution was to patch ngg-voting.php like this:

    
    Index: wp-content/plugins/nextgen-gallery-voting/ngg-voting.php
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    --- wp-content/plugins/nextgen-gallery-voting/ngg-voting.php	(revision 31b8a5811e09b558932b2a0def0480453a8a92b4)
    +++ wp-content/plugins/nextgen-gallery-voting/ngg-voting.php	(revision 6a35ca82d9c1389c29a04bb39128c31704130338)
    @@ -1581,23 +1581,29 @@
     		 */
     		function addNewImage($image) {
     			if(defined('NEXTGEN_GALLERY_PLUGIN_VERSION') && NEXTGEN_GALLERY_PLUGIN_VERSION >= 2 && is_object($image)) {
    -				if($image->id() && $image->__get('galleryid')) {
    +			  if('stdClass' === get_class($image)) {
    +          $pid = $image->pid;
    +          $gallery_id = $image->galleryid;
    +        } elseif($image->id() && $image->__get('galleryid')) {
     					$pid = $image->id();
    -					$post = array();
    -					$post['nggv_image'] = array();
    -					$post['nggv_image'][$pid] = array();
    -					
    -					$criteria = $this->getImageCriteria();
    -					foreach ((array)$criteria as $key=>$val) {
    -						$post['nggv_image'][$pid][$val->id] = array();
    -						$post['nggv_image'][$pid][$val->id]['enable'] = get_option('nggv_image_enable');
    -						$post['nggv_image'][$pid][$val->id]['force_login'] = get_option('nggv_image_force_login');
    -						$post['nggv_image'][$pid][$val->id]['force_once'] = get_option('nggv_image_force_once');
    -						$post['nggv_image'][$pid][$val->id]['user_results'] = get_option('nggv_image_user_results');
    -						$post['nggv_image'][$pid][$val->id]['voting_type'] = get_option('nggv_image_voting_type');
    -					}
    -					$this->onGalleryUpdate($image->__get('galleryid'), $post);
    -				}
    +					$gallery_id = $image->__get('galleryid');
    +				}
    +				if(isset($pid) && isset($gallery_id)) {
    +          $post = array();
    +          $post['nggv_image'] = array();
    +          $post['nggv_image'][$pid] = array();
    +
    +          $criteria = $this->getImageCriteria();
    +          foreach ((array)$criteria as $key=>$val) {
    +            $post['nggv_image'][$pid][$val->id] = array();
    +            $post['nggv_image'][$pid][$val->id]['enable'] = get_option('nggv_image_enable');
    +            $post['nggv_image'][$pid][$val->id]['force_login'] = get_option('nggv_image_force_login');
    +            $post['nggv_image'][$pid][$val->id]['force_once'] = get_option('nggv_image_force_once');
    +            $post['nggv_image'][$pid][$val->id]['user_results'] = get_option('nggv_image_user_results');
    +            $post['nggv_image'][$pid][$val->id]['voting_type'] = get_option('nggv_image_voting_type');
    +          }
    +          $this->onGalleryUpdate($gallery_id, $post);
    +        }
     			}else{
     				if($image['id']) {
     					$post = array();
    
  • The topic ‘Error while uploading new images’ is closed to new replies.