Notice: Undefined Offset : 2 How to Solve?

SYSTEM INFORMATION
OS type and version UBUNTU 20.04
Webmin version 1.994
Virtualmin version 7.1-1
Related packages SUGGESTED

Hello all,

I have FFMPEG conversion script running on my Virtualmin box with PHP7.4 installed. Everytime when I try to convert a video I get an error

This page isn’t working91.xxx.156.xxx is currently unable to handle this request.
HTTP ERROR 500

When I check the error log I see this error

[Wed Jul 06 20:30:12.758777 2022] [proxy_fcgi:error] [pid 842:tid 139961936357120] [client 2.xx.xxx.9:56176] AH01071: Got error 'PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 2 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Warning:  A non-numeric value encountered in /home/testdomain/public_html/lib/extractors/yt.php on line 202PHP message: PHP Fatal error:  Uncaught Error: Unsupported operand types in /home/testdomain/public_html/lib/extractors/yt.php:202\nStack trace:\n#0 /home/testdomain/public_html/lib/VideoConverter.php(258): YouTubeMp3Converter\\lib\\extractors\\yt->RetrieveVidInfo()\n#1 /home/testdomain/public_html/inc/index_header.php(175): YouTubeMp3Converter\\lib\\VideoConverter->ValidateConversionForm()\n#2 /home/testdomain/public_html/index.php(4): include('/home/testdomai...')\n#3 {main}\n  thrown in /home/testdomain/public_html/lib/extractors/yt.php on line 202', referer: http://91.xxx.xxx.xxx/?config=complete
[Wed Jul 06 20:36:49.899796 2022] [proxy_fcgi:error] [pid 842:tid 139961886000896] [client 2.xx.xxx.9:56487] AH01071: Got error 'PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Notice:  Undefined offset: 1 in /home/testdomain/public_html/lib/extractors/Extractor.php on line 205PHP message: PHP Warning:  A non-numeric value encountered in /home/testdomain/public_html/lib/extractors/yt.php on line 202PHP message: PHP Fatal error:  Uncaught Error: Unsupported operand types in /home/testdomain/public_html/lib/extractors/yt.php:202\nStack trace:\n#0 /home/testdomain/public_html/lib/VideoConverter.php(258): YouTubeMp3Converter\\lib\\extractors\\yt->RetrieveVidInfo()\n#1 /home/testdomain/public_html/inc/index_header.php(175): YouTubeMp3Converter\\lib\\VideoConverter->ValidateConversionForm()\n#2 /home/testdomain/public_html/index.php(4): include('/home/testdomai...')\n#3 {main}\n  thrown in /home/testdomain/public_html/lib/extractors/yt.php on line 202', referer: http://91.xxx.xxx.xxx/index.php

This is on line 205 in /lib/extractors/Extractor.php

		protected function ExtractCookies()
		{
			$cookies = '';
			$cookieNames = array();
			$headers = array_reverse($this->_headers);
			foreach ($headers as $headr)
			{
				$cookies .= (preg_match('/^(Set-Cookie:\s*(\w+)=([^;]+))/i', $headr, $matches) == 1 && !in_array($matches[2], $cookieNames)) ? $matches[2] . "=" . $matches[3] . ";" : '';
				$cookieNames[] = $matches[2];
			}
			return trim($cookies, ";");	
		}

This is on line 202 in /lib/extractors/yt.php

			parse_str(parse_url($vidUrl, PHP_URL_QUERY), $urlVars);
			if (isset($urlVars['viewkey']))
			{
				$videoInfo = array('id' => $urlVars['viewkey'], 'title' => $vidTitle, 'thumb_preview' => $vidImage, 'src_sd' => $srcUrl, 'src_hd' => $srcUrl, 'cookies' => preg_replace('/^(Cookie: )/', "", $this->_reqHeaders[count($this->_reqHeaders) - 1])) + $vidDuration + $mp4Data_pre;
			}				
			
			//die(print_r($videoInfo));
			//print_r($videoInfo);
			return $videoInfo;
		}

When I use different control panels such as aaPanel , Vestacp, etc with the same PHP version installed I have no issues and everything is working perfectly fine but when I’m using the script on Virtualmin I get this issue.

I don’t want to use other panels bcoz I have been using Virtualmin for over 10+ years and I really love this panel.

Hope someone here can figure out what is missing here.

Thanks in advance.

This is definitely not a Virtualmin issue.

That’s not possible. If it is the same version of everything (including all the libraries you’re using) and the same execution mode, then it will behave the same. The control panel managing the configuration has nothing to do with it. We manage config files, we do not provide or maintain PHP or any of its libraries.

@Joe Thank you for your reply. I just installed aapanel freshly by selecting PHP7.4 and installed the script and it worked but when I freshly install it on Virtualmin it gives me this error :frowning:

I don’t understand why this only happens in Virtualmin and not in other CP.

It is not happening in the control panel. It is happening in PHP. Something is different about PHP between the two systems. You’re looking at the wrong variable.

I don’t know what’s different. But, something is different about PHP; either version (we use the OS provided PHP packages, perhaps your other system does not do that), execution mode, or libraries. I don’t know, but the control panel is irrelevant.

Yea for sure this has something to do with the PHP. any advice to find out what’s going on? or check what’s missing in PHP or what’s not installed in Virtualmin PHP.

@anthonyinit2012,

I’m available for “paid” support tomorrow if you’d like to have this matter diagnosed by a professional. As @Joe has stated, this has nothing to do with Virtualmin itself, but perhaps there is something different about the overall “environment” or how PHP has been configured which is causing the problem. Either way I’ll help you track down the cause and address it. No solution, no cost.

*** Professional, Affordable, Technical Support: https://tpnassist.com ***

@Joe

I see that aapanel PHP is different compared to Virtualmin. can someone plz tell me what is the difference here and how can i get the exact version installed in Virtualmin if it is possible so that I can test and see if my script will work.

aaPanel PHP 7.3
Screen Shot 2022-07-09 at 4.26.35 AM

Virtualmin PHP 7.3
Screen Shot 2022-07-09 at 4.28.23 AM

Thank you.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.