lonalore / metatag

e107 (v2) plugin - This plugin allows you to automatically provide structured metadata, aka "meta tags", about a website.
GNU General Public License v3.0
12 stars 10 forks source link

problem with unserialize #14

Open Jimmi08 opened 5 years ago

Jimmi08 commented 5 years ago

I know you are working on it, but there was similar problem before, so maybe this is related to core.

Installed latest version, run update to 1.6.

https://github.com/e107inc/e107/issues/3693

image

#0  e_array->unserialize() called at [***\e107_handlers\e107_class.php:1791]
#1  e107::unserialize() called at [***\e107_plugins\metatag\includes\metatag.class.php:2957]
#2  metatag->getDefaultMetaTagsByType() called at [***\e107_plugins\metatag\includes\metatag.class.php:2865]

$data:

$data = array (
  'title' => '',
  'description' => '',
  'abstract' => '',
  'keywords' => '',
  'news_keywords' => '',
  'standout' => '',
  'rating' => '',
  'referrer' => '',
  'generator' => '',
  'rights' => '',
  'image_src' => '',
  'canonical' => '',
  'shortlink' => '',
  'publisher' => '',
  'author' => '',
  'original-source' => '',
  'prev' => '',
  'next' => '',
  'geo.position' => '',
  'geo.placename' => '',
  'geo.region' => '',
  'icbm' => '',
  'refresh' => '',
  'og:site_name' => '',
  'og:type' => '',
  'og:url' => '',
  'og:title' => '',
  'og:determiner' => '',
  'og:description' => '',
  'og:updated_time' => '',
  'og:see_also' => '',
  'og:image' => '',
  'og:image:url' => '',
  'og:image:secure_url' => '',
  'og:image:type' => '',
  'og:image:width' => '',
  'og:image:height' => '',
  'og:latitude' => '',
  'og:longitude' => '',
  'og:street_address' => '',
  'og:locality' => '',
  'og:region' => '',
  'og:postal_code' => '',
  'og:country_name' => '',
  'og:email' => '',
  'og:phone_number' => '',
  'og:fax_number' => '',
  'og:locale' => '',
  'og:locale:alternate' => '',
  'article:author' => '',
  'article:publisher' => '',
  'article:section' => '',
  'article:tag' => '',
  'article:published_time' => '',
  'article:modified_time' => '',
  'article:expiration_time' => '',
  'profile:first_name' => '',
  'profile:last_name' => '',
  'profile:username' => 'admin',
  'profile:gender' => '',
  'og:audio' => '',
  'og:audio:secure_url' => '',
  'og:audio:type' => '',
  'book:author' => '',
  'book:isbn' => '',
  'book:release_date' => '',
  'book:tag' => '',
  'og:video:url' => '',
  'og:video:secure_url' => '',
  'og:video:width' => '',
  'og:video:height' => '',
  'og:video:type' => '',
  'video:actor' => '',
  'video:actor:role' => '',
  'video:director' => '',
  'video:writer' => '',
  'video:duration' => '',
  'video:release_date' => '',
  'video:tag' => '',
  'video:series' => '',
  'fb:admins' => '',
  'fb:app_id' => '',
  'twitter:card' => '',
  'twitter:site:id' => '',
  'twitter:creator' => '',
  'twitter:creator:id' => '',
  'twitter:url' => '',
  'twitter:title' => '',
  'twitter:description' => '',
  'twitter:image' => '',
  'twitter:image:width' => '',
  'twitter:image:height' => '',
  'twitter:image:alt' => '',
  'twitter:image0' => '',
  'twitter:image1' => '',
  'twitter:image2' => '',
  'twitter:image3' => '',
  'twitter:player' => '',
  'twitter:player:width' => '',
  'twitter:player:height' => '',
  'twitter:player:stream' => '',
  'twitter:player:stream:content_type' => '',
  'twitter:app:country' => '',
  'twitter:app:name:iphone' => '',
  'twitter:app:id:iphone' => '',
  'twitter:app:url:iphone' => '',
  'twitter:app:name:ipad' => '',
  'twitter:app:id:ipad' => '',
  'twitter:app:url:ipad' => '',
  'twitter:app:name:googleplay' => '',
  'twitter:app:id:googleplay' => '',
  'twitter:app:url:googleplay' => '',
  'twitter:label1' => '',
  'twitter:data1' => '',
  'twitter:label2' => '',
  'twitter:data2' => '',
  'dcterms.title' => '',
  'dcterms.creator' => '',
  'dcterms.subject' => '',
  'dcterms.description' => '',
  'dcterms.publisher' => '',
  'dcterms.contributor' => '',
  'dcterms.date' => '',
  'dcterms.type' => '',
  'dcterms.format' => '',
  'dcterms.identifier' => '',
  'dcterms.source' => '',
  'dcterms.language' => '',
  'dcterms.relation' => '',
  'dcterms.coverage' => '',
  'dcterms.rights' => '',
  'itemprop:name' => '',
  'itemprop:description' => '',
  'itemprop:image' => '',
);

PATH: /e107_plugins/download/admin_download.php?mode=main&action=list

lonalore commented 5 years ago

Yes, this seems to be a core-related issue.

lonalore commented 5 years ago

Do you have any idea on this? :)

Jimmi08 commented 5 years ago

moved to core issues.

EDIT: I found it. It was caused by installation tagwords plugin (by mistake, I don't use it on live site). So I can continue. Sorry for panic.

Jimmi08 commented 5 years ago

I think that this happens only with update to 1.6. On e107.org there is only 1.3 version. No errors, but there are not hashed data.

EDIT: is there... after saving record with metatags, it happens with reedit...

Jimmi08 commented 5 years ago

This problem is only with 'download-category-list' type. Only with type are data saved wrong way.

image

lonalore commented 5 years ago

Thank you for effort! How can I reproduce this? I enabled debug mode, and modified all kind of meta tags, but no errors.

Jimmi08 commented 5 years ago

Fresh install (deleted metatag tables) go to metatag admin edit default metatag for anything save edit again

lonalore commented 5 years ago

Got it! I had to enable debug mode. Now I see the error. I'll try to use e107::serialize($data, 'json') instead of e107::serialize($data)

lonalore commented 5 years ago

Well, the error message is at least shorter. :D I think we should use own serialize/unserialize functions instead of core ones.

Képernyőkép_2019-04-28_11-33-35

lonalore commented 5 years ago

e107::unserialize() is buggy if json encoded data contains "{" (tokens begins with this char), because it is trying to decode the already decoded string:

if(substr($ArrayData,0,1) === '{' || substr($ArrayData,0,1) === '[') // json
{
    $dat = json_decode($ArrayData, true);

    //   e107::getDebug()->log("Json data found");

    if(json_last_error() !=  JSON_ERROR_NONE && (e_DEBUG === true))
    {
        echo "<div class='alert alert-danger'><h4>e107::unserialize() Parser Error (json)</h4></div>";
        echo "<pre>";
       debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
       echo "</pre>";
    }

    return $dat;
}

EDIT: No, not. There will be something else here.

Jimmi08 commented 5 years ago

deleted, you found it yourself that it's not that case.

Jimmi08 commented 5 years ago

If you add default data to $config['download-category-list'] , problem is solved.

        // Download - Category list page.
        $config['download-category-list'] = array(
            'name'   => LAN_PLUGIN_METATAG_TYPE_11,
            'detect' => 'metatag_entity_download_category_list_detect',
            'load'   => 'metatag_entity_download_category_list_load',
            'file'   => '{e_PLUGIN}metatag/includes/metatag.download.php',
            'default' => array(
                'title'        => '{site:current-page:title} | {site:name}',
                'description'  => '{site:description}',
                'generator'    => 'e107 v2 (http://e107.org)',
                'canonical'    => '{site:current-page:url}',
                'fb:app_id'    => '{site:fb-app-id}',
                'og:site_name' => '{site:name}',
                'og:url'       => '{site:current-page:url}',
                'og:title'     => '{site:current-page:title}',
            ),
            'dependencies' => array(
                'plugin'  => 'download',
            ),
        );

so it is something with entities when default data are not defined. I would solve it this way to move forward.