Last modified: 2012-08-10 16:05:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T41099, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 39099 - PHP Warning: Invalid argument supplied for foreach() in /www/w/includes/Uri.php on line 262
PHP Warning: Invalid argument supplied for foreach() in /www/w/includes/Uri....
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.20.x
All All
: Unprioritized normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: code-update-regression
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-07 13:32 UTC by Niklas Laxström
Modified: 2012-08-10 16:05 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Niklas Laxström 2012-08-07 13:32:03 UTC

    
Comment 1 Niklas Laxström 2012-08-07 13:56:08 UTC
PHP Notice:  Uri::parseUri: Invalid scheme in URL: callto [Called from Uri::setUri in /www/w/includes/Uri.php at line 111] in /www/w/includes/GlobalFunctions.php on line 1070
Comment 2 Tyler Romeo 2012-08-07 15:06:51 UTC
Need more context on this (what were you doing when you received this notice).

The warning shown is called when a URI finds a protocol not in $wgUrlProtocols. In this case it seems a URL is being parsed where the protocol is "callto", but I cannot determine where such a URL is being generated.
Comment 3 Niklas Laxström 2012-08-07 15:17:39 UTC
Can you make it output more useful error output? I don't have time to debug every issue seen at translatewiki.net myself (unless you ask nicely :).
Comment 4 Niklas Laxström 2012-08-07 15:25:12 UTC
Clarification: We have a bot announcing all notices in our IRC channel, so I have no idea what the users are doing to cause it.
Comment 5 Marcin Cieślak 2012-08-07 15:26:43 UTC
It vaguely reminds be of the feature of the Firefox Skype plugin
to put some funny stuff in the text when editing.

Maybe something like a Skype plugin is converting text looking like a phone number
to callto: links?
Comment 6 Tyler Romeo 2012-08-07 16:55:08 UTC
Ah OK. Didn't realize this was bot realized. I'll see if I can try and reproduce it. And Marcin may be onto something.

The easiest way to fix this (and probably the way it will be fixed), will be to add "callto" to the list of allowed protocols, but I want to make sure where this URL is coming from before doing so.
Comment 7 Niklas Laxström 2012-08-07 19:04:50 UTC
One more:
[07-Aug-2012 18:55:27] PHP Notice:  Uri::parseUri: Invalid URL: http:// [Called from Uri::setUri in /www/w/includes/Uri.php at line 111] in /www/w/includes/GlobalFunctions.php on line 1070

But the foreach (the subject) is the most noisiest, about ten times in an hour.
Comment 8 Tyler Romeo 2012-08-07 19:31:09 UTC
So to list the problems:

1) foreach error - No idea why this is happening. This is a bug in the core.
2) callto scheme error - Can be fixed by adding "callto:" to allowed protocols.
3) invalid URL error - This is because PHP's parse_url does not handle empty URLs, i.e., only a protocol.

I cannot seem to reproduce any of these errors on a base MW installation unfortunately, but I'm still looking. Hopefully somebody else has an idea of where these invalid URLs are coming from. The only reason you're getting these warnings now and not previously is because the original URL functions just returned false on error rather than actually issuing a warning.
Comment 9 Bawolff (Brian Wolff) 2012-08-07 19:55:10 UTC
>The only reason you're getting these
>warnings now and not previously is because the original URL functions just
>returned false on error rather than actually issuing a warning

Returning false sounds like the more desired behaviour. If the issue is really something that cannot be ignored, an exception should be thrown. PHP notices are icky. (In this case, I think wfDebug is more appropriate than wfWarn).

>2) callto scheme error - Can be fixed by adding "callto:" to allowed protocols.

If the issue is that Uri.php fails badly when fed an invalid url, making all urls valid is not a good solution, as it would defeat the point of doing url validation.
Comment 10 Tyler Romeo 2012-08-07 20:06:20 UTC
(In reply to comment #9)
> >The only reason you're getting these
> >warnings now and not previously is because the original URL functions just
> >returned false on error rather than actually issuing a warning
> 
> Returning false sounds like the more desired behaviour. If the issue is really
> something that cannot be ignored, an exception should be thrown. PHP notices
> are icky. (In this case, I think wfDebug is more appropriate than wfWarn).
> 
> >2) callto scheme error - Can be fixed by adding "callto:" to allowed protocols.
> 
> If the issue is that Uri.php fails badly when fed an invalid url, making all
> urls valid is not a good solution, as it would defeat the point of doing url
> validation.

I agree, and most likely a switch to wfDebug will be the answer, but I'm still wondering why and in what context MW would be using invalid URLs like that.
Comment 11 Niklas Laxström 2012-08-08 16:44:15 UTC
The change(s) should be reverted if the fix is not coming in very soon.
Comment 12 Tyler Romeo 2012-08-08 19:02:04 UTC
These issues are not bugs with the Uri.php change, but rather are previously unnoticed issues with MW's calls to wfUrlParse(), so reverting the change would be counterproductive.

However, issues 2 and 3 should have been fixed in https://gerrit.wikimedia.org/r/18059
Comment 13 Tyler Romeo 2012-08-08 20:16:44 UTC
And issue 1 has been fixed: https://gerrit.wikimedia.org/r/18181
Comment 14 Niklas Laxström 2012-08-09 06:07:10 UTC
That didn't fix the problem. Our channel was flooded with during the night:
[09-Aug-2012 06:04:45] PHP Warning:  Invalid argument supplied for foreach() in /www/w/includes/Uri.php on line 262

Please fix or revert ASAP, master should always work!
Comment 15 Niklas Laxström 2012-08-09 06:14:03 UTC
<li>Uri.php line 263 calls wfBacktrace()</li>
<li>GlobalFunctions.php line 486 calls Uri->extendQuery()</li>
<li>OutputPage.php line 402 calls wfAppendQuery()</li>
<li>Gadgets_body.php line 226 calls OutputPage->addScriptFile()</li>
<li>Gadgets_body.php line 196 calls GadgetHooks::applyScript()</li>
<li>- line - calls GadgetHooks::beforePageDisplay()</li>
<li>Hooks.php line 216 calls call_user_func_array()</li>
<li>GlobalFunctions.php line 3897 calls Hooks::run()</li>
<li>OutputPage.php line 1995 calls wfRunHooks()</li>
<li>Wiki.php line 543 calls OutputPage->output()</li>
<li>Wiki.php line 446 calls MediaWiki->main()</li>
<li>index.php line 58 calls MediaWiki->run()</li>
</ul>

3943299 <- value passed in
Comment 16 daniel 2012-08-09 08:02:51 UTC
I am also getting this error in my http error file


[Thu Aug 09 00:43:07 2012] [error] [client {IP}] PHP Warning:  Invalid argument supplied for foreach() in {dir}/w/includes/Uri.php on line 262, referer: http://internationalguidetoavoiddying.com/wiki/{page}

This happens when any page is loaded
Comment 17 Sam Reed (reedy) 2012-08-09 13:43:23 UTC
I'm guessing that $parameters is not an array (but is something that allows count to return true..) at the point of iteration

Add a is_array( $parameters ) && ?

Which presumably it wasn't decided to be a string when it was passed in either
Comment 18 Niklas Laxström 2012-08-09 13:47:05 UTC
It's int. count returns 1 for any non-array which is not false-like.
Comment 19 daniel 2012-08-09 13:49:06 UTC
and for every page load it gives four of these errors is there any other information i can provide to help?
Comment 20 Sam Reed (reedy) 2012-08-09 13:57:26 UTC
(In reply to comment #17)
> I'm guessing that $parameters is not an array (but is something that allows
> count to return true..) at the point of iteration
> 
> Add a is_array( $parameters ) && ?
> 
> Which presumably it wasn't decided to be a string when it was passed in either

https://gerrit.wikimedia.org/r/#/c/18232/
Comment 21 Tyler Romeo 2012-08-09 14:32:47 UTC
Success! Finally figured out what the problem is. It seems certain components (such as the Gadgets extension) are passing numeric queries. Uri::extendQuery() is coded to pass any strings to wfCGIToArray, but doesn't account for the fact that the parameter can be an integer. A patchset will be submitted shortly.
Comment 22 Tyler Romeo 2012-08-09 14:38:29 UTC
https://gerrit.wikimedia.org/r/18237
Comment 23 Sam Reed (reedy) 2012-08-09 14:39:50 UTC
(In reply to comment #15)
> 3943299 <- value passed in

		$u = $t->getLocalURL( 'action=raw&ctype=' . $wgJsMimeType );
		$out->addScriptFile( $u, $t->getLatestRevID() );

https://gerrit.wikimedia.org/r/#/c/18232/

patch 2..
Comment 24 Sam Reed (reedy) 2012-08-09 14:41:33 UTC
(In reply to comment #22)
> https://gerrit.wikimedia.org/r/18237

(In reply to comment #23)
> (In reply to comment #15)
> > 3943299 <- value passed in
> 
>         $u = $t->getLocalURL( 'action=raw&ctype=' . $wgJsMimeType );
>         $out->addScriptFile( $u, $t->getLatestRevID() );
> 
> https://gerrit.wikimedia.org/r/#/c/18232/
> 
> patch 2..

I've removed the count call as it's superfluous, if we make sure there's an array to iterate over it..
Comment 25 daniel 2012-08-10 04:09:42 UTC
Seams to have worked :) pages load ... and no errors ... I think you can close this bug :) and thank you very much :)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links