{"id":4,"date":"2007-06-10T16:29:24","date_gmt":"2007-06-10T14:29:24","guid":{"rendered":"http:\/\/vladimir-shapiro\/en\/blog\/?p=4"},"modified":"2007-10-27T02:44:04","modified_gmt":"2007-10-27T00:44:04","slug":"wordpress-cannot-redeclare-class","status":"publish","type":"post","link":"https:\/\/vladimir-shapiro.com\/en\/blog\/2007\/06\/10\/wordpress-cannot-redeclare-class\/","title":{"rendered":"WordPress: Cannot redeclare class problem"},"content":{"rendered":"<p>Wired, wired bug. It happens with <a href=\"http:\/\/www.toppa.com\/shashin-wordpress-plugin\/\" title=\"Shashin - A WordPress Plugin for Displaying Picasa Photos\">Sashin<\/a>, it happens with <a href=\"http:\/\/wpforum.designpraxis.at\/topic\/fatal-error-cannot-redeclare-class-phpmailer\">phpMailer class<\/a>, it happens <a href=\"http:\/\/www.google.com\/search?hl=en&amp;q=wordpress+plugin+cannot+redeclare+class&amp;btnG=Search\">everywhere<\/a>. As three plugins crashed after each other with the same reason on my brand-new WordPress installation, I&#8217;ve decided to invest an evening to find out the reason.<\/p>\n<p><!--more-->Let us localize the problem at first:<\/p>\n<p>1) It happens only on Win32 installations.<\/p>\n<p>2) It happens only in WordPress 2.1 or earlier.<\/p>\n<p>After debugging a code for a couple of hours, I&#8217;ve found a bug with processing a win32 path in plugin_basename() function located in wp-includes\/plugin.php.<\/p>\n<p>Now skip the next two paragraphs if you are not a &#8220;techi&#8221; geek and simply scroll down to the solution.<\/p>\n<p>This bug indirectly leads to the construction of a wrong hookname and to the missing page hook as the result. Missing page hook drives the process in the admin.php on line 44 (release 2.1) to the totally wrong if-branch. Finally this ends up with the attempt to include a plugin file once again.<\/p>\n<p><strong>Solution<\/strong><\/p>\n<p>Two minutes later I was reading the <a href=\"http:\/\/trac.wordpress.org\/ticket\/4408\" title=\"plugin_basename() fix\">bug report #4408<\/a> which fixed the plugin_basename() in the version 2.2. So there are two options:<\/p>\n<p>1) Upgrade your WordPress to version 2.2. or higher<\/p>\n<p>2)  Implement a fix from the bug report.<\/p>\n<p>It is always good to have a choice. Enjoy it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wired, wired bug. It happens with Sashin, it happens with phpMailer class, it happens everywhere. As three plugins crashed after each other with the same reason on my brand-new WordPress installation, I&#8217;ve decided to invest an evening to find out the reason.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/posts\/4"}],"collection":[{"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":0,"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"wp:attachment":[{"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vladimir-shapiro.com\/en\/blog\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}