Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’ve just used this for a site I’m working on. It may need tweaking for you own set up:

    /**
     * Convert Yoast breadcrumbs to use Microdata
     *
     * @params string $breadcrumbs Breadcrumb HTML
     * @return string
     * @author Jaik Dean
     **/
    function convertBreadcrumbsToMicrodata($breadcrumbs)
    {
        // remove the XML namespace
        $breadcrumbs = str_replace(' xmlns:v="https://rdf.data-vocabulary.org/#"', '', $breadcrumbs);
    
        // convert each breadcrumb
        $breadcrumbs = preg_replace(
            '/<span typeof="v:Breadcrumb"><a href="([^"]+)" rel="v:url" property="v:title">([^<]+)<\\/a><\\/span>/',
            '<span itemscope itemtype="https://data-vocabulary.org/Breadcrumb"><a href="$1" itemprop="url"><span itemprop="title">$2</span></a></span>',
            $breadcrumbs
        );
    
        $breadcrumbs = preg_replace(
            '/<span typeof="v:Breadcrumb"><span class="breadcrumb_last" property="v:title">([^<]+)<\\/span><\\/span>/',
            '<span itemscope itemtype="https://data-vocabulary.org/Breadcrumb"><span class="breadcrumb_last" itemprop="title">$1</span></span>',
            $breadcrumbs
        );
    
        return $breadcrumbs;
    }
    
    add_filter('wpseo_breadcrumb_output', 'convertBreadcrumbsToMicrodata');

    My bug report on MySQL has now been verified.

    This problem is definitely due to a change in MySQL 5.6 for us. It may well be a MySQL 5.6 bug, I’ll be reporting it to them too.

    Assuming there is no post ID 99999, running the following query shows different results in <5.6 and 5.6…

    SELECT IFNULL(DATE_ADD(CAST(NOW() AS DATETIME), INTERVAL a.meta_value SECOND), 'duration is null') AS duration, a.meta_value
    FROM wp_postmeta m
    LEFT JOIN wp_postmeta a ON a.post_id = 99999
    LIMIT 0,1

    MySQL 5.5 result (which is expected by the Events Calendar code):
    duration: “duration is null”
    meta_value: NULL

    MySQL 5.6 result:
    duration: “2013-04-03 17:27:49.000000”
    meta_value: NULL

    Interestingly, if we just do the following query the results differ:

    SELECT IFNULL(DATE_ADD(CAST(NOW() AS DATETIME), INTERVAL null SECOND), 'duration is null') AS duration

    MySQL 5.5 result:
    duration: “duration is null”

    MySQL 5.6 result:
    duration: “duration is null”

    Looking at the plugin code, it appears to be doing various calculations and checks using a piece of postmeta with the key _EventDuration which I don’t have in my database.

    Specifically, it looks like this piece of SQL may be the culprit:

    IFNULL(DATE_ADD(CAST(eventStart.meta_value AS DATETIME), INTERVAL eventDuration.meta_value SECOND), eventEnd.meta_value) as EventEndDate

    Replacing it with the following means I get the correct end date through, but I expect this will break things in other circumstances:

    eventEnd.meta_value as EventEndDate

    It looks like MySQL is treating the null value of eventDuration.meta_value as 0 for the purposes of the DATE_ADD() call. Perhaps this is specific to certain versions of MySQL and is why not everyone is getting the problem? I’m on MySQL 5.6.10.

    I’m having exactly the same issue. A var_dump($post) shows the following values for the start and end dates:

    ["EventStartDate"]=> string(19) "2013-04-04 08:00:00"
    ["EventEndDate"]=> string(26) "2013-04-04 08:00:00.000000"

    However, the database has these as:

    _EventStartDate 2013-04-04 08:00:00
    _EventEndDate 2013-04-19 17:00:00
Viewing 6 replies - 1 through 6 (of 6 total)