Extremely odd error I am getting...

Jaxel

Well-known member
Okay I am using the following code to retrieve the list of bbcode media sites, and their regexes:

Code:
$mediaSites = $this->getModelFromCache('XenForo_Model_BbCode')->getAllBbCodeMediaSites();
foreach ($mediaSites AS $siteId => &$site)
{
    $site['regexes'] = $this->getModelFromCache('XenForo_Model_BbCode')->convertMatchUrlsToRegexes($site['match_urls'], $site['match_is_regex']);
}
print_r($mediaSites);

This is working fine. If I then print out the contents I get:

Code:
Array
(
    [youtube] => Array
        (
            [media_site_id] => youtube
            [site_title] => YouTube
            [site_url] => http://www.youtube.com
            [match_urls] => youtube.com/watch?v={$id}
youtube.com/v/{$id}
youtu.be/{$id}
youtube.com/watch?feature=player_embedded&v={$id}
            [match_is_regex] => 0
            [match_callback_class] =>
            [match_callback_method] =>
            [embed_html] => <iframe type="text/html" width="640" height="390" src="https://www.youtube.com/embed/{$id}?fs=1&rel=0" frameborder="0" allowfullscreen></iframe>
            [embed_html_callback_class] =>
            [embed_html_callback_method] =>
            [supported] => 1
            [addon_id] =>
            [regexes] => Array
                (
                    [0] => #youtube\.com/watch\?v\=(?P<id>[^"'?&;/<>\#\[\]]+)#i
                    [1] => #youtube\.com/v/(?P<id>[^"'?&;/<>\#\[\]]+)#i
                    [2] => #youtu\.be/(?P<id>[^"'?&;/<>\#\[\]]+)#i
                    [3] => #youtube\.com/watch\?feature\=player_embedded&v\=(?P<id>[^"'?&;/<>\#\[\]]+)#i
                )

        )
    [youtube_list] => Array
        (
            [media_site_id] => youtube_list
            [site_title] => YouTube (Playlist)
            [site_url] => http://www.youtube.com
            [match_urls] => youtube.com/playlist?list={$id}
            [match_is_regex] => 0
            [match_callback_class] =>
            [match_callback_method] =>
            [embed_html] => <iframe type="text/html" width="640" height="390" src="https://www.youtube.com/embed/videoseries?list={$id}&fs=1&rel=0" frameborder="0" allowfullscreen></iframe>
            [embed_html_callback_class] =>
            [embed_html_callback_method] =>
            [supported] => 0
            [addon_id] => EWRtorneo
            [regexes] => Array
                (
                    [0] => #youtube\.com/playlist\?list\=(?P<id>[^"'?&;/<>\#\[\]]+)#i
                )

        )
)

Notice the contents of the "youtube_list" sub array. Everything appears proper.

However, if instead of using the straight print_r, I do the following:

Code:
foreach ($mediaSites AS $site)
{
    print_r($site);
}

I get the following result:

Code:
Array
(
    [media_site_id] => youtube
    [site_title] => YouTube
    [site_url] => http://www.youtube.com
    [match_urls] => youtube.com/watch?v={$id}
youtube.com/v/{$id}
youtu.be/{$id}
youtube.com/watch?feature=player_embedded&v={$id}
    [match_is_regex] => 0
    [match_callback_class] =>
    [match_callback_method] =>
    [embed_html] => <iframe type="text/html" width="640" height="390" src="https://www.youtube.com/embed/{$id}?fs=1&rel=0" frameborder="0" allowfullscreen></iframe>
    [embed_html_callback_class] =>
    [embed_html_callback_method] =>
    [supported] => 1
    [addon_id] =>
    [regexes] => Array
        (
            [0] => #youtube\.com/watch\?v\=(?P<id>[^"'?&;/<>\#\[\]]+)#i
            [1] => #youtube\.com/v/(?P<id>[^"'?&;/<>\#\[\]]+)#i
            [2] => #youtu\.be/(?P<id>[^"'?&;/<>\#\[\]]+)#i
            [3] => #youtube\.com/watch\?feature\=player_embedded&v\=(?P<id>[^"'?&;/<>\#\[\]]+)#i
        )

)
Array
(
    [media_site_id] => youtube
    [site_title] => YouTube
    [site_url] => http://www.youtube.com
    [match_urls] => youtube.com/watch?v={$id}
youtube.com/v/{$id}
youtu.be/{$id}
youtube.com/watch?feature=player_embedded&v={$id}
    [match_is_regex] => 0
    [match_callback_class] =>
    [match_callback_method] =>
    [embed_html] => <iframe type="text/html" width="640" height="390" src="https://www.youtube.com/embed/{$id}?fs=1&rel=0" frameborder="0" allowfullscreen></iframe>
    [embed_html_callback_class] =>
    [embed_html_callback_method] =>
    [supported] => 1
    [addon_id] =>
    [regexes] => Array
        (
            [0] => #youtube\.com/watch\?v\=(?P<id>[^"'?&;/<>\#\[\]]+)#i
            [1] => #youtube\.com/v/(?P<id>[^"'?&;/<>\#\[\]]+)#i
            [2] => #youtu\.be/(?P<id>[^"'?&;/<>\#\[\]]+)#i
            [3] => #youtube\.com/watch\?feature\=player_embedded&v\=(?P<id>[^"'?&;/<>\#\[\]]+)#i
        )

)

Notice how the contents of the second array are now completely wrong. Why is this happening?
 
Back
Top Bottom