Jump to content

Compile error during upgrade to 3.x


valan
 Share

Recommended Posts

I'm trying to upgrade PW from 2.8 to 3.0 and get:

Compile Error: Cannot declare class Order\Order_Status, because the name is already in use (line 6 of /path-to-file/Order_Status.class.php) 

File Order_Status.class.php:

<?php
namespace Order;

require_once('SomeClass.php');

class Order_Status {
   // ...
}
?>

File where compiler breaks Master_Order.class.php:

<?php
namespace MM\User\Master;

require_once('/path-to-file/Order_Status.class.php');

use Order\Order_Status;

class Master_Order {
   // ...
}

 

I've checked FileCompiler cache and discovered that:

  • Order_Status.class.php is compiled as expected (e.g. there is 'SomeClass.php' wrapped by file compiler)
  • Master_Order.class.php is uncompiled as required_once('/path-to-file/Order_Status.class.php') is not wrapped

Most probably conflict appears as a result of Order_Status.class.php compilation and its usage at early stage (this class is used both in modules and in template files).

So my question is - how to fix compiler error in this case?

Link to comment
Share on other sites

@BitPoet thank you for link. Haven't heard about this setting, as well as about FileCompiler=?

Checked. Doesn't help. As far as I understand, because PHP compiler already declared class earlier.

Looks like in my case Order_Status.class.php should not be required_once as soon as it has been compiled somewhere before + class is in use already.

Or (I guess) Order_Status.class.php should never be compiled. But this scenario looks ugly to me as there are a lot of files that I need to prevent from compilation...).

Link to comment
Share on other sites

I think your files shouldn't be compiled (or at least the compiled files not used) at all. Does moving the namespace declaration to the very first line of your php files change anything? How you specify the include files' paths might also be relevant if you use different approaches in your class files and templates.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...