Advertisement:

Author Topic: Image Sitemap notice-Undefined index: fk_i_item_id in /home/ [SOLVED]  (Read 3020 times)

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Hi,

I am getting PHP Notice:Undefined index: fk_i_item_id in /home/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29

My error log is full of this Notice....Please help. No reply from so long. Please resolve the issue facing.
« Last Edit: September 29, 2017, 09:15:09 am by PostFreeOnline.Com »

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Re: Image Sitemap notice-Undefined index: fk_i_item_id in /home/ [SOLVED]
« Reply #1 on: September 28, 2017, 10:30:52 am »
On 6 Sept 2017 I submitted this topic in Forum but no reply from that date. thats why i said that this forum members are not responding. Very strange i am noticing that no where we are getting response it is forum or it is premium plugin support messages. Please wake up guys and be active.

Hi,

Image Site map is giving so many NOTICES. Please see the log  and resolve it. My Debug log is full of this Notice.


[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
[28-Sep-2017 11:00:17 Asia/Kolkata] PHP Notice:  Undefined index: fk_i_item_id in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/images_sitemap/functions.php on line 29
« Last Edit: September 29, 2017, 09:15:55 am by PostFreeOnline.Com »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Hi.There are some notices like this in osclass as well. I resolved them by adding if(isset($variable['fk_i_item_id'])) you must replace the variable with the name used in your code (this is just a hint. I don't know your code).

Look here https://forums.osclass.org/3-7-x/i'm-getting-php-warnings-in-my-log-files/msg153693/#msg153693
« Last Edit: September 28, 2017, 10:50:05 am by marius-ciclistu »

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Re: Image Sitemap notice-Undefined index: fk_i_item_id in /home/ [SOLVED]
« Reply #3 on: September 28, 2017, 12:21:32 pm »
Hi.There are some notices like this in osclass as well. I resolved them by adding if(isset($variable['fk_i_item_id'])) you must replace the variable with the name used in your code (this is just a hint. I don't know your code).

Look here https://forums.osclass.org/3-7-x/i'm-getting-php-warnings-in-my-log-files/msg153693/#msg153693

What is the path for the file which needs to be amended. Do I need to replace


 /**
    * Gets current item array from view
    *
    * @return array $item, or null if not exist
    */
    function osc_item() {
        if(View::newInstance()->_exists('item')) {
            $item = View::newInstance()->_get('item');
        } else {
            $item = null;
        }

        return($item);
    }



TO


/**
     * Create item url from item data without exported to view.
     *
     * @since 3.3
     * @param array $item
     * @param string $locale
     * @return string
     */
    function osc_item_url_from_item($item, $locale = '')
    {
        if ( osc_rewrite_enabled() ) {
            $url = osc_get_preference('rewrite_item_url');
            if( preg_match('|{CATEGORIES}|', $url) ) {
                $sanitized_categories = array();
487:       if( isset($item["fk_i_category_id"]) ) { //new line
               $cat = Category::newInstance()->hierarchy($item['fk_i_category_id']);   
                for ($i = (count($cat)); $i > 0; $i--) {
                    $sanitized_categories[] = $cat[$i - 1]['s_slug'];
                }
                $url = str_replace('{CATEGORIES}', implode("/", $sanitized_categories), $url);
                } // new line
            }
495            if( isset($item["pk_i_id"]) ) {      $url = str_replace('{ITEM_ID}', osc_sanitizeString($item['pk_i_id']), $url); }
496            if( isset($item["s_city"]) ) {       $url = str_replace('{ITEM_CITY}', osc_sanitizeString($item['s_city']), $url); }
497            if( isset($item["s_title"]) ) {       $url = str_replace('{ITEM_TITLE}', osc_sanitizeString($item['s_title']), $url); }
            $url = str_replace('?', '', $url);
            if($locale!='') {
                $path = osc_base_url().$locale."/".$url;
            } else {
                $path = osc_base_url().$url;
            }
        } else {
            $path = osc_item_url_ns($item['pk_i_id'], $locale);
        }
        return $path;
    }
« Last Edit: September 29, 2017, 09:17:14 am by PostFreeOnline.Com »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
In your case you will find the code in this functions.php on line 29:
oc-content/plugins/images_sitemap/functions.php on line 29

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Re: Image Sitemap notice-Undefined index: fk_i_item_id in /home/ [SOLVED]
« Reply #5 on: September 28, 2017, 12:30:49 pm »
In your case you will find the code in this functions.php on line 29:
oc-content/plugins/images_sitemap/functions.php on line 29

This is the code from Line 29

 $num = $item_id['fk_i_item_id'];
   $id = Item::NewInstance()->FindByPrimaryKey($num);
  $xml  .= '    <image:image>' . PHP_EOL;
  $xml .=  '      <image:loc>'. osc_base_url(). ''.$img.'</image:loc>' .PHP_EOL;
  if(!empty($id)){
   $xml .= '<image:title>'. $id['s_title'] .'</image:title>' . PHP_EOL;
   //$xml .= '<image:caption>'. var_export(substr($id['s_description'],0, 50), true).'</image:caption>' . PHP_EOL;
  } else {
   $xml .= '<image:title>'.$deft.'</image:title>' . PHP_EOL;
   //$xml .= '<image:caption></image:caption>' . PHP_EOL;
  }
  $xml  .= '    </image:image>' . PHP_EOL;
  }
  $xml .= '  </url>' . PHP_EOL;
  $xml .= '</urlset>' . PHP_EOL;
  file_put_contents($filename, $xml, FILE_APPEND);
  if(osc_get_preference('ping_engines', 'images_sitemap')== 1){
   images_map_ping_search_engines();
  }
}

function images_map_ping_search_engines()
{
    // GOOGLE


Do I need to replace only Line 29 which is           $num = $item_id['fk_i_item_id'];



Exactly what to do to resolve this?
« Last Edit: September 29, 2017, 09:17:48 am by PostFreeOnline.Com »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Instead of
Code: [Select]
$num = $item_id['fk_i_item_id'];
You can put

Code: [Select]
if( isset($item_id['fk_i_item_id']))  $num = $item_id['fk_i_item_id'];
This checks if the  $item_id['fk_i_item_id'] value is set. If it is not set, it won't asign it's value to $num and the notice will apear no more.
« Last Edit: September 28, 2017, 12:49:11 pm by marius-ciclistu »

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Re: Image Sitemap notice-Undefined index: fk_i_item_id in /home/ [SOLVED]
« Reply #7 on: September 28, 2017, 12:47:36 pm »
Instead of
Code: [Select]
$num = $item_id['fk_i_item_id'];
You can put

Code: [Select]
if( isset($item_id['fk_i_item_id'])  $num = $item_id['fk_i_item_id'];
This checks if the  $item_id['fk_i_item_id'] value is set. If it is not set, it won't asign it's value to $num and the notice will apear no more.

When I replace that line with

if( isset($item_id['fk_i_item_id'])  $num = $item_id['fk_i_item_id'];

it shows Red marking in front See screen shot.
« Last Edit: September 29, 2017, 09:18:08 am by PostFreeOnline.Com »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Sorry I forgot a ) I edited the original code.

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Re: Image Sitemap notice-Undefined index: fk_i_item_id in /home/ [SOLVED]
« Reply #9 on: September 28, 2017, 12:52:59 pm »
Sorry I forgot a ) I edited the original code.

Its Ok.. Can you past the final code here
« Last Edit: September 29, 2017, 09:18:36 am by PostFreeOnline.Com »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Code: [Select]
if( isset($item_id['fk_i_item_id']))  $num = $item_id['fk_i_item_id'];

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Re: Image Sitemap notice-Undefined index: fk_i_item_id in /home [SOLVED]
« Reply #11 on: September 28, 2017, 01:05:23 pm »
Yes Now all notices Gone. Let me annalyse more.  I am very grateful to you for your help.

 I am also getting similar Notices in en_US in /home/scorp4hj/public_html/postfreeonline.com/oc-content/plugins/jobs_attributes/item_edit.php

So this will wore there also.
« Last Edit: September 29, 2017, 09:18:56 am by PostFreeOnline.Com »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
I don't know, you can try.
See if that $num from line 30 doesn't generate notices after this modification.

Or $id from line 33.

PostFreeOnline.Com

  • Jr. Member
  • **
  • Posts: 77
  • PostFreeOnline.Com
Re: Image Sitemap notice-Undefined index: fk_i_item_id in /home [SOLVED]
« Reply #13 on: September 28, 2017, 01:13:51 pm »
I don't know, you can try.
See if that $num from line 30 doesn't generate notices after this modification.

Or $id from line 33.

Let me see If I will get those (God Forbid) But Now Its gone...  Actually I started receiving those since I updated the php Ver. 71
« Last Edit: September 29, 2017, 09:19:23 am by PostFreeOnline.Com »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
I use 7.0.