Forum

Thread tagged as: Error, Addons, Field-Types

YouTube Addon PHP Errors

Diangnostic Report

    Perch: 2.8.31, PHP: 5.6.23, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
    Server OS: WINNT, apache2handler
    Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), perch_blog (5.0), perch_events (1.9.3), perch_forms (1.8.3), perch_gallery (2.8.6), perch_backup (1.2)
    App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_events', 'perch_forms', 'perch_gallery', 'perch_blog', );
    PERCH_LOGINPATH: /perch
    PERCH_PATH: C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch
    PERCH_CORE: C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\core
    PERCH_RESFILEPATH: C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\resources
    Image manipulation: GD
    PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M
    F1: 2edba60ed1f613d6dd804feb202456a2
    Resource folder writeable: Yes
    HTTP_HOST: dev1.lakehouse
    DOCUMENT_ROOT: C:/Users/Webmaster-Lobby/Websites/xampp/htdocs/Sites/lakehouse1
    REQUEST_URI: /perch/core/settings/diagnostics/
    SCRIPT_NAME: /perch/core/settings/diagnostics/index.php

Description of Problem

I installed the YouTube field type addon into /perch/addons/fieldtypes/youtube/. I'm trying to use it within a content template to populate a region with an embedded YouTube video. This is what my template file, located in /perch/templates/content/, looks like:

<perch:content id="video" type="youtube" width="800" label="Insert the full URL of a video hosted on YouTube." output="embed" />

When I enter the URL into the field and save changes, PHP error messages appear at the top of the dashboard page. Here is a screenshot: Screenshot of PHP errors at the top of a Perch dashboard web page

Notice: Undefined index: width in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 113

Notice: Undefined index: height in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 114

Notice: Undefined index: height in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 123

Notice: Undefined index: width in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 123

Warning: Division by zero in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 123

I found my PHP error log in XAMPP, not sure how much of it is relevant but these entries seem to correspond with the browser messages:

[Fri Jul 15 16:03:50.498324 2016] [:error] [pid 5164:tid 1852] [client 127.0.0.1:54791] PHP Notice:  Undefined index: width in C:\\Users\\Webmaster-Lobby\\Websites\\xampp\\htdocs\\Sites\\lakehouse1\\perch\\addons\\fieldtypes\\youtube\\youtube.class.php on line 113, referer: https://dev1.lakehouse/perch/core/apps/content/edit/?id=29
[Fri Jul 15 16:03:50.498324 2016] [:error] [pid 5164:tid 1852] [client 127.0.0.1:54791] PHP Notice:  Undefined index: height in C:\\Users\\Webmaster-Lobby\\Websites\\xampp\\htdocs\\Sites\\lakehouse1\\perch\\addons\\fieldtypes\\youtube\\youtube.class.php on line 114, referer: https://dev1.lakehouse/perch/core/apps/content/edit/?id=29
[Fri Jul 15 16:03:50.498324 2016] [:error] [pid 5164:tid 1852] [client 127.0.0.1:54791] PHP Notice:  Undefined index: height in C:\\Users\\Webmaster-Lobby\\Websites\\xampp\\htdocs\\Sites\\lakehouse1\\perch\\addons\\fieldtypes\\youtube\\youtube.class.php on line 123, referer: https://dev1.lakehouse/perch/core/apps/content/edit/?id=29
[Fri Jul 15 16:03:50.498324 2016] [:error] [pid 5164:tid 1852] [client 127.0.0.1:54791] PHP Notice:  Undefined index: width in C:\\Users\\Webmaster-Lobby\\Websites\\xampp\\htdocs\\Sites\\lakehouse1\\perch\\addons\\fieldtypes\\youtube\\youtube.class.php on line 123, referer: https://dev1.lakehouse/perch/core/apps/content/edit/?id=29
[Fri Jul 15 16:03:50.498324 2016] [:error] [pid 5164:tid 1852] [client 127.0.0.1:54791] PHP Warning:  Division by zero in C:\\Users\\Webmaster-Lobby\\Websites\\xampp\\htdocs\\Sites\\lakehouse1\\perch\\addons\\fieldtypes\\youtube\\youtube.class.php on line 123, referer: https://dev1.lakehouse/perch/core/apps/content/edit/?id=29

Output attribute

When I change the "output" attribute to "player" instead of "embed," the edit saves in the dashboard and the YouTube video's URL is output to the webpage.

Paul Lee

Paul Lee 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is that the same for every video?

I have only one video on that page.

I haven't yet tried to use the addon for anything other than the one video.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Could you try with a different video or two to check?

The result is the same with two different videos. However, the preview player embedded in the dashboard pagedoes work. It updates to the new video every time I put in a new video URL, and then I can play the video in it. The PHP errors are still appearing at the top of the dashboard page, and nothing shows up on the actual content webpage.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you added your YouTube API key to the config file?

Drew McLellan said:

Have you added your YouTube API key to the config file?

Yes. My config file located at \xampp\htdocs\lakehouse1\perch\config\config.php has this as the final line, beneath the PERCH_HTML5 define:

define('PERCH_YOUTUBE_API_KEY', '[key redacted, but not actually redacted in the real config file]');
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, great. That's very strange then. I'll see if I can reproduce that here - hopefully it's something simple and not yet another change to the YouTube API.

Okay, here's some more behavior regarding this error.

I just republished the pages, and it showed success for every region except for the one associated with the YouTube addon feather. In the midst of all the green checkmarks, I get this message on republishing:

Notice: Undefined index: width in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 113

Notice: Undefined index: height in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 114

Notice: Undefined index: height in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 123

Notice: Undefined index: width in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 123

Warning: Division by zero in C:\Users\Webmaster-Lobby\Websites\xampp\htdocs\Sites\lakehouse1\perch\addons\fieldtypes\youtube\youtube.class.php on line 123

Drew McLellan

Drew McLellan 2638 points
Perch Support

There's definitely an issue retrieving the details for that video. Do you have any other add-ons installed that interact with a third party API? Do those work?

Drew McLellan said:

Do you have any other add-ons installed that interact with a third party API? Do those work?

Not yet. Does the default map template count? I plan to try using that for a Google street map on the site relatively soon.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I was just wondering if there wasn't anything environmental with your server that might be casing issues when connecting to the remote API. The fact that you can see the preview, but don't have the width or height indicates that you're getting a response, but perhaps tit's not containing all the information that should normally be there.

I've now used the default map template to put in a Google street map, and it appears to work perfectly.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that's a mystery then. I'll take another look at the YouTube field type and see what I can come up with.

I'm having exactly the same issue. I've added the API key to the config like so

define('PERCH_YOUTUBE_API_KEY', 'xxxxxxxxxxxxxxxx');

and enabled the YouTube Data API v3 for that key.

Here's a link to a screen grab of the error output.