Absolute path in BasePeer::CLASS_DEFAULT #183

tentacode opened this Issue Nov 8, 2011 · 7 comments


None yet
4 participants

We are using namespaced Propel classes.

In PHP5PeerBuilder::addConstantsAndAttribute is the following code :

  /** A class that can be returned by this peer. */
  const CLASS_DEFAULT = '".$this->getStubObjectBuilder()->getClasspath()."';

the resulting generated code is something like :

  /** A class that can be returned by this peer. */
  const CLASS_DEFAULT = 'home/gpillet/workspace/src/Pmsipilot/MyBundle/Model.MyClass';

It's a problem because each time we rebuild the model, we have diff in our version control system (ignoring these files is out of question).

Overridind the builder with a relative path for our specific needs like

  /** A class that can be returned by this peer. */
  const CLASS_DEFAULT = '".'../../../../myPath'."';

Does not work because Propel::importClass replaces each . by a /

        // turn to filesystem path
        $path = strtr($path, '.', DIRECTORY_SEPARATOR) . '.php';

The easiest way to solve this problem would be to modify Propel::importClass to first detect if file_exists before replacings dots by slashes. But I wanted your opinion before submitting a PR.


fzaninotto commented Feb 13, 2012

I think this only happens with PropelBundle in Symfony2. Propel alone adds the relative path to the project directory in this constant.

Could you reopen the issue in the PropelBundle tracker?

fzaninotto closed this Feb 13, 2012


fzaninotto commented Feb 13, 2012

Note that I believe this constant is not used (except in getOMClass(), in a use case that never happens), so I think the safest fix is to remove it and modify the getOMClass code.

@fzaninotto fzaninotto added a commit to fzaninotto/Propel that referenced this issue Feb 13, 2012

@fzaninotto fzaninotto Remove BasePeer::CLASS_DEFAULT constant.
This constant, generated by `PHP5PeerBuilder::addConstantsAndAttribute()`, is no longer in use
now that autoloading works for models. Besides, it creates problems (see #183) and complexity
in the code. Removing it is painless - all the tests are green.

havvg commented Feb 13, 2012

What version of PropelBundle are you using @gabrielpillet?

I don't have this issue, I know however I encountered it before and solved it.

We're connected to the 2.0 branch of the PropelBundle.


havvg commented Feb 14, 2012

I just checked it, the commits are in the 2.0 already. Could you update to current 2.0 and verify the problem still exists? The commit fixing the problem: propelorm/PropelBundle@beab50c

Thanks, we will check this sometime today.

Thanks guys, everything is working using 2.0 branch :)

@willdurand willdurand added a commit that referenced this issue Sep 9, 2013

@willdurand willdurand Merge pull request #183 from staabm/patch-1
Update behaviors/query-cache.markdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment