It’s somehow hard to understand. PHP Variables and how they do References to the according data. This Blog post is a collection of articles related to the topic and a short review of those I found valuable. Maybe there are more important ones, please let me know via the comments.

The story behind this post is, that within the WordPress project we need to currently still keep PHP 4.3 backwards compability. One topic that is related to the differences between the outdated 4.3 version and the current 5.2 version is the handling of values for object variables.
I saw some issues within the core-code and I was asking in some tickets (#11663, #11780) about how to handle them. It was important to me to get feedback from core developers because in other situations when it came to references in a patch nothing concrete was available and specs were missing. That lead to the situation that certain myth and wrong information is circulating. At least partly wrong information. I do not like that and I would love to see this clarified.
I thought: Well even if we’re currently wrong with the topic, it would be good to have a spec or similar at least to referer to while trying to figure things out. And while discussing those in IRC yesterday, we came to the point that it’s often a question how a value is to be used then the type only. For example in PHP 5 passing or returning references can be counter-productive where in some cases in PHP 4 those are a need to get certain functions in wordpress to work.
Functions returning cache objects were named as examples where that is the case. Otherwise those objects would get copied on change and the changes won’t be reflected overall in memory and/or within the database or on disk occasionally. And the cache should be something where it’s possible to write into.
Another thing is the $this variable. By PHP Documentation that one is “by reference” automatically so there never is need to prefix it with a &-sign. But within the core-code this is done all the time when it is passed it into the hook system. Myth or reality? At least that’s the documented behavior.

But those are some aspects of the problems within the wordpress project only. In general the topic is not easy to understand and I thought it’s time to collect some valuable resources. On the way to do so, I revealed some pretty interesting texts incl. one that is mathematically proving why the topic is hard to get. Because the implementation in PHP comes with it’s flaws. Continue reading →
Enhancing Feeds: Limiting the Comments Feed
In a recent ticket (#7092), redsweater was asking for a missing feature: A separate setting for limiting the numbers of comments in the comments feed. He drives multiple sites that have such a high user traffic which results in soo many comments that it was his wish to have more control over the number of comments listed in the comments feeds. By default it’s limited to the value set for the standard feed, but that was not a pleasing option for him any longer.
Separate Setting for Limiting Comments Feed
There is actually a patch and a plugin offered in trac. So it’s quite new (3 weeks ago) and quite untested but if you’re missing that feature as well you can give the patch or plugin a try. Whichever is the best option for your site. The patch might become part of the core code some day. Let’s see.
For those missing that option, this is a path to follow. Patch was provided by Nacin, I wrote the Plugin. Redsweater himself was not very happy about the plugin provided because he really wants to see this setting as part of the main product and not inside the plugin. If that is your wish too, please support him and the ticket. I think it’s a usefull setting for active sites.
All Posts of the Enhancing Feeds Series