View Issue Details

IDProjectCategoryView StatusLast Update
0005916OXID eShop (all versions)4.10. AutoLoaderpublic2024-02-14 10:51
Reporterthomas_oppelt Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.9.0 / 5.2.0 
Fixed in Version6.0.0-beta.1 
Summary0005916: oxAutoload can cause preg_match compilation warnings on namespaced class names
DescriptionAlthough OXID does not make use of namespaces itself of course, the autoloader must not cause any warnings when it comes to autloading of full qualified class names.
Steps To ReproduceTry wherever in OXID framework context the following check (or any other where e.g. this 'P‘ follows up a backslash):

class_exists('Foo\Bar\Provider');

=> the oxid autloader comes up with this warning:

Warning: preg_match(): Compilation failed: unknown property name after \P or \p at offset ...

caused by l. 111 of file oxfunctions.php
TagsNo tags attached.
ThemeAll
BrowserAll
PHP VersionNot defined
Database VersionNot defined

Relationships

has duplicate 0006228 closed oxAutoload can cause preg_match compilation warnings on namespaced class names => Bug 5916 is not resolved 

Activities

revoltek

2014-10-17 11:31

reporter   ~0010249

Same Problem here.

My solution as pull request:
See pull Request: https://github.com/OXID-eSales/oxideshop_ce/pull/178

thomas_oppelt

2014-10-17 11:53

reporter   ~0010250

+1

andrius.silgalis

2014-10-27 14:34

reporter   ~0010274

Last edited: 2014-10-27 14:34

The fix according to pull request no. 178 looks correct (also for another case):
1. must escape backslash '\' character for classes with namespaces, this is the current problem - "... whenever you reference a namespace in a string, each backslash must be escaped with another backslash because of how PHP handles strings" (from php.net docs).
2. escaping forward slash '/' is not required, but as it is used as preg_match delimiter it is safe to do so.

arturas.sevcenko

2014-10-29 13:47

reporter   ~0010287

Fixed with pull request https://github.com/OXID-eSales/oxideshop_ce/pull/178