Bug #620

PHP Catchable fatal error: Argument 1 passed to iterator_to_array() must implement interface Traversable, instance of DOMNamedNodeMap given

Added by Dave Berndt about 2 years ago. Updated about 2 years ago.

Status:ClosedStart date:03/24/2013
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:1.7.6
Resolution:fixed

Description

Updated to 1.7.5 from 1.7.3 on fully updated platform:

Distributor ID: Ubuntu
Description:    Ubuntu 10.04.4 LTS
Release:        10.04
Codename:       lucid

Everything was working fine in previous release, now when I click on an article to read I receive "Communication problem with server" on the client and the following in the apache log:

[Sat Mar 23 18:19:34 2013] [error] [client xxx.xxx.xxx.xxx] PHP Catchable fatal error:  Argument 1 passed to iterator_to_array() must implement interface Traversable, instance of DOMNamedNodeMap given, called in /home/httpd/tinytinyrss/include/functions.php on line 2660 and defined in /home/httpd/tinytinyrss/include/functions.php on line 2688, referer: http://tinyrss.mydomain.com/

Don't know for certain if there is a failure in my upgrade process somewhere, but all of my sanity checks per the FAQ and elsewhere don't seem to resolve the issue.

check-if-traversable.patch Magnifier (846 Bytes) Jenz E, 03/25/2013 05:01 AM

History

#1 Updated by Philippe Mongeau about 2 years ago

I have the same issue, I was able to fix it by changing

foreach (iterator_to_array($entry->attributes) as $attr) {

to

foreach ($entry->attributes as $attr) {

on line 2688 of functions.php

#2 Updated by Dave Berndt about 2 years ago

Philippe Mongeau wrote:

I have the same issue, I was able to fix it by changing

[...]

to

[...]

on line 2688 of functions.php

Thanks much, I had just commented out the strip_harmful_tags call and it also got me going again. I like your fix better.

#3 Updated by Andrew Dolgov about 2 years ago

iterator_to_array is supposed to be there because we're modifying stuff while iterating through it which could lead to missed tags and whatnot. Why doesn't it work I have no idea. What's your PHP version?

#4 Updated by Jenz E about 2 years ago

I ran into this issue as well on my server which runs
PHP 5.3.2-1ubuntu4.19 with Suhosin-Patch (cli)

It worked fine on my local Windows 7 though, which has
PHP 5.3.8 (cli)

Hope it helps.

#5 Updated by Andrew Dolgov about 2 years ago

It works on 5.3.3 on squeeze, so maybe it's something that got fixed right after 5.3.2?

#6 Updated by Dave Berndt about 2 years ago

I have the same version as Jenz, so might be something with PHP:
PHP 5.3.2-1ubuntu4.19 with Suhosin-Patch (cli) (built: Mar 11 2013 15:23:48)

#7 Updated by Jenz E about 2 years ago

Attached patch seems to solve the issue for me. Must admit I haven't done any thorough testing though. Worst case would be that it bypasses the foreach..

What the patch does it to implement a check to see if the attributes array is an "instanceof Traversable".

#8 Updated by Andrew Dolgov about 2 years ago

It should bypass the attribute cleaning if not traversable which would leave scripts and whatnot wide open.

#9 Updated by Andrew Dolgov about 2 years ago

Can someone check if it is possible to foreach over this in 5.3.2? I can just remove iterator_to_array() and do it manually then, like referenced diff.

#10 Updated by Jenz E about 2 years ago

Of course... you are right about that.

Removing iterator_to_array() as suggested in #1 works for me on 5.3.2.

#12 Updated by Jenz E about 2 years ago

That seems to be working. I can't say if the script does what it's supposed to do, but I don't get any error messages and the issue is resolved.

#13 Updated by Andrew Dolgov about 2 years ago

It's easy to check. For example, in this feed, if images are not aligned to the right of text, then attributes are being stripped properly: http://feeds.feedburner.com/neowin-main

(the image should be above text in tt-rss)

#14 Updated by Jenz E about 2 years ago

(the image should be above text in tt-rss)

I can confirm that. The style attribute gets stripped and images are not left aligned (floated).

#15 Updated by Andrew Dolgov about 2 years ago

  • Resolution set to fixed
  • Target version set to 1.7.6
  • Status changed from New to Closed

Excellent. Marking as fixed then.

#16 Updated by Jenz E about 2 years ago

Andrew Dolgov wrote:

Excellent. Marking as fixed then.

Sounds good to me. Thanks for being on top of things!

Also available in: Atom PDF