#506 ✓resolved
Martijn Bosgraaf

Bug: expCore:resolveFilePaths - Template locating fails when the themename occurs in the docroot path name

Reported by Martijn Bosgraaf | January 28th, 2012 @ 10:07 PM | in 2.0.5 (closed)

The issue has been verified to exist in version 2.0.2 upto and including 2.0.4

When the theme name of an Exponent installation occurs in the pathname of the docroot for the hosting environment, a failure will occur in finding the default modules-1 templates. This will result in a disfunctional CMS system.

I came across the situation when I wanted to move a website I developed to a production server. On my development server everything was just fine (as the theme name did not occur in the docroot filepath), on the production server however it failed.

An example situation:
Theme name: mycompanyname (not really uncommon)
Docroot on the server: /home/users/mycompanyname.com

The failing function:

public static function resolveFilePaths($type, $name, $subtype, $subname) {

The failing piece of code (in Exponent 2.0.4, starting at line 440 in file: framework/core/subsystems/expCore.php):

foreach($locations as $location) {
    $checkpaths[] = $location . $typepath . $relpath2;
    //if (strstr($location,DISPLAY_THEME_REAL) && strstr($relpath,"framework/modules-1")) {
    if (strstr($location,DISPLAY_THEME) && strstr($relpath,"framework/modules-1")) {
        $checkpaths[] = $location . str_replace("framework/modules-1", "modules", $relpath);
    } else {
        $checkpaths[] = $location . $relpath;

In above example situation you will end up with:
A PHP define DISPLAY_THEME with a value of "mycompanyname"

$locations being: Array(

Now this line will fail as ALL $locations will match strstr($location, DISPLAY_THEME):

if (strstr($location,DISPLAY_THEME) && strstr($relpath,"framework/modules-1")) {

Please work towards a safer way to determine if the locations need to be changed. The current solution is guaranteed to fail on more users then just me. I will for now just rename my theme to get this resolved, although it is not my preferred way to get it solved for now.

Comments and changes to this ticket

  • dleffler

    dleffler January 29th, 2012 @ 02:36 AM

    • Title changed from “Template locating fails when the themename occurs in the docroot path name” to “Bug: expCore:resolveFilePaths - Template locating fails when the themename occurs in the docroot path name”
    • Milestone set to 2.0.5
    • Milestone order changed from “162” to “0”

    fwiw, the expCore::resolveFilePaths method is pretty much a hack that has been further hacked from 1.0 code...meaning it's not the most efficient algorithm to begin with. Now that we've streamlined the folder layout, it should be easier to clean up.

    Probably needs to follow an algorithm similar to what we use in the autoload/installtables methods to find controllers/models/definitions.

  • dleffler

    dleffler January 29th, 2012 @ 03:02 AM

    • Assigned user set to “dleffler”

    Try changing line #443 from:

      if (strstr($location,DISPLAY_THEME) && strstr($relpath,"framework/modules-1")) {


      if ($location==THEME_ABSOLUTE) && strstr($relpath,"framework/modules-1")) {

    Please report the results.

  • expNinja

    expNinja January 31st, 2012 @ 08:21 PM

    • State changed from “new” to “resolved”

    (from [f9b6de8bb38d282416d9dde9f9ebad2cfd90744a]) Should fix a problem with old school module views when the theme name is also the name of the root folder. [#506 state:resolved] https://github.com/exponentcms/exponent-cms/commit/f9b6de8bb38d2824...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Bug Tracker for Exponent CMS

Shared Ticket Bins

People watching this ticket