<?xml version="1.0" encoding="utf-8"?>
<feed
    xmlns="http://www.w3.org/2005/Atom"
    xmlns:at="http://www.sixapart.com/ns/at"
    xmlns:icbm="http://postneo.com/icbm"
    xmlns:rvw="http://purl.org/NET/RVW/0.2/"
    xml:lang="en">
    <title>till&#39;s blog</title>
    <link rel="self" type="application/atom+xml" title="till&#39;s blog (Atom)" href="http://till.vox.com/library/posts/tags/oo/page/1/atom.xml" />
    <link rel="alternate" type="text/html" title="till&#39;s blog" href="http://till.vox.com/library/posts/tags/oo/page/1/"/> 
    <link rel="service.post" type="application/atom+xml" title="till&#39;s blog" href="http://www.vox.com/services/atom/svc=post/collection_id=6a00c2251d8a1b549d00c2251e7add8e1d" /> 
    <link rel="service.subscribe" type="application/atom+xml" title="till&#39;s blog" href="http://till.vox.com/library/posts/tags/oo/atom.xml" />   
    <link rel="last" type="application/atom+xml" title="till&#39;s blog" href="http://till.vox.com/library/posts/tags/oo/page/1/atom.xml" />  
    <category term="oo" scheme="http://till.vox.com/tags/oo/?_c=feed-atom-full" label="oo" /> 
    <generator uri="http://www.vox.com/">Vox</generator>
    <updated>2008-03-03T00:36:41Z</updated> 
    <author>
        <name>till</name>
        <uri>http://till.vox.com/?_c=feed-atom-full</uri>
    </author> 
    <id>tag:vox.com,2006:6p00c2251d8a1b549d/tags/oo/</id>  
    
    <entry>
        <title>PHP Fatal error:  Non-static method FOO::FOO() in (...)</title>   
        <link rel="alternate" type="text/html" title="PHP Fatal error:  Non-static method FOO::FOO() in (...)" href="http://till.vox.com/library/post/php-fatal-error-non-static-method-foofoo-in.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="PHP Fatal error:  Non-static method FOO::FOO() in (...)" href="http://till.vox.com/library/post/php-fatal-error-non-static-method-foofoo-in.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="PHP Fatal error:  Non-static method FOO::FOO() in (...)" href="http://www.vox.com/atom/svc=post/asset_id=6a00c2251d8a1b549d00f48ce069930003" />          <id>tag:vox.com,2008-03-02:asset-6a00c2251d8a1b549d00f48ce069930003</id>
        <published>2008-03-03T00:25:00Z</published>
        <updated>2008-03-03T00:36:41Z</updated>
    
        <author>
            <name>till</name>
            <uri>http://till.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://till.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>After bumping up the PHP 5.2.x on one of our servers Friday night, I got reports from some of our clients that certain websites would not work anymore. After investigating this problem, I found that <del>most</del> all of <del>the</del> <em>my</em> problems were in Joomla, Mambo and Drupal plugins/extensions which those people used.</p><p>Of course no offense to those three systems (and their developers and people using them ;-)), but I googled the error and found that many people reported similar issues on support forums of those three. At least the top results suggest that. On the list of offenders are also shops such as the very popular OSCommerce. Anyway - just let me stress this again - no offense meant (but you need to fix your code :-P).</p><p>On to the fix.</p><p>The offending code, could look like (this example is from Mambo&#39;s AKO_Book extension):<br /><blockquote><p><em>MENU_Default::MENU_Default();</em><br /></p></blockquote>
Digging into this, you will probably find a class that would look similar to this:<br /><blockquote><p><em>&lt;?php<br />class MENU_Default {<br />&#160; function MENU_Default() {<br />&#160;&#160;&#160; // do something<br />&#160; }<br />}<br />?&gt;</em><br /></p></blockquote>At first I (paniced and) thought that effectively all static calls without a &quot;static&quot; keyword are broken in PHP5.2.5. But after investigating and raising a bit of havoc on IRC and internals@ (Sorry!), <a href="http://bjori.blogspot.com/">Bjori</a> shed some light into/onto my confusion and figured out that this is just a static call to the constructor of a class.</p><p>And calling the constructor of a class directly is just wrong. And static calls to the constructor have not been allowed since 5.0.0. (I am not sure why no one reported issues before but I guess since I wrote our customers that the update was smooth, they just had to dig up something. :-))</p><p>The fix is simple and should have been there to begin with:<br />
<blockquote><p>// currently:<br /><em>MENU_Default::MENU_Default();</p><p>// replace with:<br /></em>new <em>MENU_Default();</em><br /></p></blockquote> <div>(By the way - it really helps if you set log_errors = On in your php.ini or via php_value in your &lt;VirtualHost&gt; because you are then able to track all errors without reproducing them a dozen times, which is sometimes hard because they might be hidden in a wizard-like process and customers are generally not very good at describing what they did to get the error - they will just say, &quot;It doesn&#39;t work!&quot;.)<br /><br />Issues like that are to be traced back to PHP4&#39;s more &#39;lax <em>interpretation</em> of OO. Even on PHP4 coders should have written the latter, but no one forced them to. And because I know the pain of upgrading a system like Joomla/Mambo, Drupal and others - especially once you put a lot of customization in it, I hope this helps someone out there fix their issues.<br /><br />Debatable is still if any version of PHP5 should really consider this to be a fatal error. Or if this call should be subject to <a href="http://docs.php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-strict">E_STRICT</a> which was introduced in PHP5 to ensure forward compatibility of code, which sounds like the best fit for this. I believe in the E_STRICT way.<br /><br />I know and understand that there are probably about a dozen technical reasons to E_FATAL instead, but in my (very) humble opinion to make people aware with E_STRICT and to add a note that E_STRICT will eventually turn into E_FATAL in PHP6 would have been the right path to persue here.<br />Less breakage and more awareness - they make the &quot;we told you so&quot;-argument more valid. Everything but that just adds to the user&#39;s general fear to adopt PHP5 and to finally get rid off PHP4.<br /><br />On a side note - I feel that I need to add that we only allow those old versions to run because we patched them for our clients and because we use an application firewall called <a href="http://www.modsecurity.org/">mod_security</a>. mod_security is customizable through rule sets and we constantly update them to combat known attacks (e.g. XSS, comment spam, ...).<br /><br />If you don&#39;t have those resources available to yourself, you need to consider an update of the PHP application more sooner than later.<br /></div></p>   <p style="clear:both;"> 
    <a href="http://till.vox.com/library/post/php-fatal-error-non-static-method-foofoo-in.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00c2251d8a1b549d00f48ce069930003?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="update" scheme="http://till.vox.com/tags/update/" label="update" /> 
    <category term="php" scheme="http://till.vox.com/tags/php/" label="php" /> 
    <category term="joomla" scheme="http://till.vox.com/tags/joomla/" label="joomla" /> 
    <category term="upgrade" scheme="http://till.vox.com/tags/upgrade/" label="upgrade" /> 
    <category term="drupal" scheme="http://till.vox.com/tags/drupal/" label="drupal" /> 
    <category term="oo" scheme="http://till.vox.com/tags/oo/" label="oo" /> 
    <category term="php5" scheme="http://till.vox.com/tags/php5/" label="php5" /> 
    <category term="php4" scheme="http://till.vox.com/tags/php4/" label="php4" /> 
    <category term="mamboserver" scheme="http://till.vox.com/tags/mamboserver/" label="mamboserver" /> 
    <category term="e_strict" scheme="http://till.vox.com/tags/e_strict/" label="e_strict" /> 
    <category term="e_fatal" scheme="http://till.vox.com/tags/e_fatal/" label="e_fatal" /> 
    </entry> 
</feed>


