dannypritchett01 Posted December 7, 2020 Share Posted December 7, 2020 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/311813-encountering-this-error/ Share on other sites More sharing options...
Barand Posted December 7, 2020 Share Posted December 7, 2020 $metaTagsHTML .= '<meta property="' . $propertyName . '" content="' . htmlspecialchars($tagContent,'ENT_IGNORE','UTF-8') . '" />' . "\n"; | | |__REMOVE__| ENT_IGNORE is a constant definition, not a string literal - remove the quotes. Quote Link to comment https://forums.phpfreaks.com/topic/311813-encountering-this-error/#findComment-1582863 Share on other sites More sharing options...
dannypritchett01 Posted December 7, 2020 Author Share Posted December 7, 2020 (edited) 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 December 7, 2020 by dannypritchett01 Quote Link to comment https://forums.phpfreaks.com/topic/311813-encountering-this-error/#findComment-1582864 Share on other sites More sharing options...
requinix Posted December 7, 2020 Share Posted December 7, 2020 What version of PHP are you running? Quote Link to comment https://forums.phpfreaks.com/topic/311813-encountering-this-error/#findComment-1582865 Share on other sites More sharing options...
dannypritchett01 Posted December 7, 2020 Author Share Posted December 7, 2020 I am on 5.6 right now, but am working on moving to 7.4 in the next few days. Quote Link to comment https://forums.phpfreaks.com/topic/311813-encountering-this-error/#findComment-1582866 Share on other sites More sharing options...
Solution Barand Posted December 7, 2020 Solution Share Posted December 7, 2020 (edited) Strange, ENT_IGNORE was added in v5.3. However its use is discouraged as a potential security risk. Try replacing ENT_IGNORE with NULL EDIT: As of 5.4, UTF-8 is the default so just go with htmlspecialchars($tagContent) Edited December 7, 2020 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/311813-encountering-this-error/#findComment-1582867 Share on other sites More sharing options...
dannypritchett01 Posted December 11, 2020 Author Share Posted December 11, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/311813-encountering-this-error/#findComment-1582952 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.