New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String of custom admin path causes conflict with datasource / events names #2339

Closed
marciotoledo opened this Issue Jan 30, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@marciotoledo

marciotoledo commented Jan 30, 2015

Hi,

I used 'back' as custom admin path to a new project.
When I was trying create a datasource with name "feedback" an error was returned.

The lastest stable version: 2.5.2

https://gist.github.com/anonymous/12ddd1f8dc4f4a39555e

On this parte of error:
"Symphony Fatal Error: Could not find Data Source feedcreated. If it was provided by an Extension"

The string was broken 'feedcreated'.

If I change de name to 'fedback', the error return 'fedcreated', so maybe the problem is about 'back' as I used on admin path.

Another information, the datasource / event with name 'feedback' was created but when try edit, same error again.

If need more information, let me know.

@nitriques

This comment has been minimized.

Show comment
Hide comment
@nitriques

nitriques Jan 30, 2015

Member

I think I found it.

What do you get if you replace this line with this one.

if (isset($_GET['symphony-page']) && strpos($_GET['symphony-page'], $adminPath, 0, 1) === 0) {

Notice the extra 1 parameter in the strpos call ?? This will limit the replacement to only one (your's get two replacement!!)

Does it fix the problem ?

@jensscherbl This kind of fix would get release as 2.5.3 with the new branching model ? I am willing to fix both integration a the 2.5.x branch.... How should I do it ?

Member

nitriques commented Jan 30, 2015

I think I found it.

What do you get if you replace this line with this one.

if (isset($_GET['symphony-page']) && strpos($_GET['symphony-page'], $adminPath, 0, 1) === 0) {

Notice the extra 1 parameter in the strpos call ?? This will limit the replacement to only one (your's get two replacement!!)

Does it fix the problem ?

@jensscherbl This kind of fix would get release as 2.5.3 with the new branching model ? I am willing to fix both integration a the 2.5.x branch.... How should I do it ?

@nitriques

This comment has been minimized.

Show comment
Hide comment
@nitriques

nitriques Jan 30, 2015

Member

Sorry, just tested my fix and it obviously does not work.
Been looking around and it seems like we have two choice.

  1. Use preg_replace
  2. Use this, which looks less nice, but is faster
$pos = strpos($haystack,$needle);
if ($pos !== false) {
    $newstring = substr_replace($haystack,$replace,$pos,strlen($needle));
}

From: http://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match

And I think that this should go in General as str_replace_first

Member

nitriques commented Jan 30, 2015

Sorry, just tested my fix and it obviously does not work.
Been looking around and it seems like we have two choice.

  1. Use preg_replace
  2. Use this, which looks less nice, but is faster
$pos = strpos($haystack,$needle);
if ($pos !== false) {
    $newstring = substr_replace($haystack,$replace,$pos,strlen($needle));
}

From: http://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match

And I think that this should go in General as str_replace_first

@nitriques nitriques self-assigned this Jan 30, 2015

@brendo

This comment has been minimized.

Show comment
Hide comment
@brendo

brendo Jan 31, 2015

Member

Use preg_replace. I favour readability of code than milliseconds.

Member

brendo commented Jan 31, 2015

Use preg_replace. I favour readability of code than milliseconds.

@brendo brendo added this to the 2.6.0 milestone Jan 31, 2015

@brendo brendo assigned brendo and unassigned nitriques Jan 31, 2015

@brendo brendo closed this Jan 31, 2015

@nitriques

This comment has been minimized.

Show comment
Hide comment
@nitriques

nitriques Feb 3, 2015

Member

Thanks Brendan.

Member

nitriques commented Feb 3, 2015

Thanks Brendan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment