Jump to content

Encountering this error...


dannypritchett01
Go to solution Solved by Barand,

Recommended Posts

If yall have a moment go read my introductions. The short version is that I lost a lot of my memory due to a fall I had in 2014 while working for the big blue retail store with one or two registers open! haha. I am not allowed to talk about it so maybe you will know who I am referring too. Anyhow before that I was pretty knowledgeable and was doing great at fixing things as they came up. Now unfortunately while working on something my mind sometimes slips and I forget what I was working on and cant solve issues. The last couple of days has been a struggle for me. I have a error showing up and I know its got to be a stupidly simple fix I am overlooking or overthinking and I cant figure it out. The first issue I resolved. It was a typo. But this one is out to corrupt my brain even more, every time I go to think about it my brain craps out on me and I begin phasing out as I look onward on the screen. The error is filling my log full of entries over this one simple issue. I think its something to do with a facebook addition we added a few years back.

The Errors are:

htmlspecialchars() expects parameter 2 to be long, string given in class.opengraph.php at 67
File    Line    Function

         _LOG->HandlePHPErrors
class.opengraph.php    67    htmlspecialchars
class.page.php    249   s_OPENGRAPH::getMetaTags
class.page.php    187    _PAGE->ShowPage
pages.php    5    _PAGE->HandlePage

I think I fixed this one below, look at the code and you can double check.

Use of undefined constant ENT_IGNORE - assumed 'ENT_IGNORE' in class.opengraph.php at 67
File    Line    Function
class.opengraph.php    67    _LOG->HandlePHPErrors
class.page.php    249    _OPENGRAPH::getMetaTags
class.page.php    187    _PAGE->ShowPage
pages.php    5    _PAGE->HandlePage

<?php
class ISC_OPENGRAPH {
	/**
	* Gets a list of valid object types
	*
	* @param bool $includeLabels Set to true to return an associative array that includes the labels for each type
	* @return array The array of object types
	*/
	public static function getObjectTypes($includeLabels = false)
	{
		$objectTypes = array(
			'product' 	=> GetLang('TypeProduct'),
			'album'		=> GetLang('TypeAlbum'),
			'book'		=> GetLang('TypeBook'),
			'drink'		=> GetLang('TypeDrink'),
			'food'		=> GetLang('TypeFood'),
			'game'		=> GetLang('TypeGame'),
			'movie'		=> GetLang('TypeMovie'),
			'song'		=> GetLang('TypeSong'),
			'tv_show'	=> GetLang('TypeTVShow'),
		);

		if (!$includeLabels) {
			return array_keys($objectTypes);
		}

		return $objectTypes;
	}

	/**
	* Generates meta HTML tags using the Open Graph schema
	*
	* @param string $type The object type
	* @param string $title The object's title
	* @param string $description Description of the object
	* @param string $image URL to an image of the object
	* @param string $url The URL to the object itself
	* @return string The HTML meta tags
	*/
	public static function getMetaTags($type = 'product', $title = '', $description = '', $image = '', $url = '')
	{
		$imgfile = parse_url(urldecode($image));
		if(isset($imgfile['fragment'])){
 		 $localfile = $_SERVER['DOCUMENT_ROOT'].$imgfile['path'].'#'.$imgfile['fragment'];
	}else{
 		 $localfile = $_SERVER['DOCUMENT_ROOT'].$imgfile['path'];
		}
		list($width, $height) = getimagesize("$localfile");
		$tags = array(
  		'og:type' => $type,
  		'og:title' => $title,
  		'og:description' => $description,
  		'og:image' => $image,
  		'og:image:width' => $width,
  		'og:image:height' => $height,
  		'og:image:alt' => $title,
  		'og:url' => $url,
  		'og:site_name' => GetConfig('StoreName')
		);

		if (GetConfig('FacebookLikeButtonAdminIds')) {
			$tags['fb:admins'] = GetConfig('FacebookLikeButtonAdminIds');
		}

		$metaTagsHTML = '';
		foreach ($tags as $propertyName => $tagContent) {
			$metaTagsHTML .= '<meta property="' . $propertyName . '" content="' . htmlspecialchars($tagContent,'ENT_IGNORE','UTF-8') . '" />' . "\n";
		}

		return $metaTagsHTML;
	}
}

 

Link to comment
Share on other sites

It didnt have quotes before and then was throwing another error. Thats why I added quotes. When quotes arent there it gives:

NOTICE: Use of undefined constant ENT_IGNORE - assumed 'ENT_IGNORE'

 

It also tells me...

NOTICE: getimagesize() [function.getimagesize]: Read error! in /includes/classes/class.opengraph.php at 48

Edited by dannypritchett01
Link to comment
Share on other sites

I appreciate your help. I went page by page, link by link and found a few other errors like this and by you pointing this out, I figured out how to fix this error in my other pages too. It appears that the freelancer I hired for a project set it up like this. All of the areas needed fixed had to do with areas they had coded. You're the best. Do you have any interest in in using your knowledge to add new functionality to our website? Id pay of course within my budget and if I couldn't afford it, Id just wait on it until I could. The freelancers I have been working with have been great but it is a pain in the neck to deal with them because so many of them code poorly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.