3

I'm using SimplePie with PHP 5.2.17 to parse my RSS feeds through the WordPress plugin feedwordpress. This works well and without problems if I make sure to use this patch to simplepie (in the file IRI.php).

However, if I change my PHP to use version 5.3.28 - the memory leak (or some other memory leak) starts and my site crashes. Any idea what might be causing it / how to solve it?

(or in other words, is there a reason this patch should work in 5.2 and not in PHP 5.3?)

Thanks.

Community
  • 1
  • 1
Tal Galili
  • 24,605
  • 44
  • 129
  • 187
  • patch looks clean to me, what error log says about your crash? – Gowri Dec 22 '14 at 12:53
  • Thanks Gowri. I use a managed VPS so I don't have access to all of the logs. Which error logs should I ask for? (I checked in the FTP and there was no error_logs file that seemed relevant) – Tal Galili Dec 22 '14 at 16:15

1 Answers1

6

PHP 5.3 isn't fully backward compatible with PHP 5.2,

In your case, the use of the clearstatcache() is probably the cause of the memory leak.

As you can see in the Migrating from PHP 5.2.x to PHP 5.3.x document:

clearstatcache() no longer clears the realpath cache by default.

This issue can be fixed by explicitly setting the $clear_realpath_cache parameter to true

clearstatcache(true)
Uri Goren
  • 13,386
  • 6
  • 58
  • 110
  • That is very interesting Uri! Where should I include that code? (in IRI.php ? in the beginning of it/ or somewhere else?) – Tal Galili Dec 22 '14 at 18:47
  • @TalGalili I'd suggest including it directly on SimplePie source code. ☺ (I was thinking about linking to their source code from here, than I found your recent activity on their Github issues…) – Tomer Cohen Dec 22 '14 at 21:12
  • @TomerCohen - I'd be happy to. But where should it go? – Tal Galili Dec 22 '14 at 21:27
  • Adding this line to the destructor at `SimplePie_IRI` should do the trick – Uri Goren Dec 23 '14 at 07:14
  • Thanks Uri. Just to be sure, you mean to add it to the beginning of "__destruct() "? And would it be PHP 5.2 compatible? – Tal Galili Dec 23 '14 at 07:17
  • 1
    I'd put it at the end of the the `__destruct()` function, PHP 5.2 clears the realpath cache by default, so it should have no effect – Uri Goren Dec 23 '14 at 07:21