Important 2.1 info for third party devs: Building file paths to your add-ons
I wanted to make a quick broadcast to third party developers about a potential issue in the upcoming ExpressionEngine 2.1 release with your add-ons, depending on how you were building file paths with CodeIgniter. If affected, your add-ons will break in ExpressionEngine 2.1, so it is very important for users of your add-ons to have updated code prior to its launch. If you have been building your file paths with PATH_THIRD or APPPATH*, you should not be affected.
In our testing we discovered some developers building paths like so:
BASEPATH.'expressionengine/third_party/my_addon/some/file.php';
In CodeIgniter, the constant BASEPATH points to the CodeIgniter system folder. Because of its default location in CodeIgniter 1.x, the application folder (which contains the controllers, views, models, libraries, and so on that are specific to the application) would often reside inside CodeIgniter’s system folder, like in the above path example. Developers have many reasons for not wanting the application folder to reside inside the CodeIgniter system folder, though, like running multiple applications from a single set of core files, or putting the application folder under source control without having to include all of CodeIgniter. For these and other reasons, CodeIgniter 2.x moved the application folder outside of the system folder by default.
In ExpressionEngine 2, ‘expressionengine’ is the renamed ‘application’ folder. While it is true the old common convention in CodeIgniter for it to reside in the system folder was the default during the beta, the location of the application folder is not something that you can assume a location on - you never know what the user may have done with it. And in ExpressionEngine 2.1, it follows CodeIgniter 2’s pattern of residing outside of the CodeIgniter files right from the get go. This is not a concern for you if when building paths to the third_party folder you were using the constant PATH_THIRD which, as indicated by the name, always gives direct access to the third party folder.
PATH_THIRD.'my_addon/some/file.php';
We apologize to ExpressionEngine developers who are new to CodeIgniter for not giving better direction in the transition documentation on which constants to use when building paths, and will be adding some documentation to that effect shortly.
We recommend that all developers with 2.0 compatible add-ons do a quick project-wide find for BASEPATH, and adjust their paths accordingly. Doing so now will not affect your current compatibility with the beta version, because PATH_THIRD will always be correct, regardless of where the system and application folders are located.
* Warning, Geek Content Ahead. If you are coming from the CodeIgniter world and aren’t familiar with some of EE’s constants, you may have been using the APPPATH constant. For the uninitiated, APPPATH gives direct access to the ‘application’ folder, regardless of what the user has done with it.
APPPATH.'third_party/my_addon/some/file.php';
However it is still preferable to use the PATH_THIRD constant. For instance, the ExpressionEngine installer is actually a separate CodeIgniter application, so its APPPATH does not contain ./expressionengine/third_party/. For this reason, a constant exists in the installer, EE_APPPATH, when it needs to reach into the expressionengine application folder (some shared internal libraries for instance).
So if your upd. files try to use APPPATH, and are installed by the user during ExpressionEngine’s installation, it will be looking for files in the installer application and will fail. You could use EE_APPPATH in those files, but since your add-ons should never have to venture outside of the third party folder with hand-built paths, it is sanest to just use PATH_THIRD, which always points to the same location in both the application and the installer.↩






