baseUri pointing to index.php causes double calls do IndexAction

Hi,

I started a new project using dev-tols.

And noticed that indexAction was running twice (saving the record in the database twice).

This was being triggered by the favicon address in layout.

This is the baseUri defined in config.php created by dev-tols (create-project command)

'baseUri' => preg_replace('/public([\/\\])index.php$/', '', $_SERVER["PHP_SELF"]),

Im my setup $_SERVER["PHP_SELF"] point to "/index.php"

Because "public" does not exist in [$_SERVER["PHP_SELF"] the baseUri returned is "/index.php"

Then the urls are generated this way

<link rel="shortcut icon" type="image/x-icon" href="<?php echo $this->url->get('img/favicon.ico')?>"/>

<link rel="shortcut icon" type="image/x-icon" href="/index.php/img/favicon.ico"/>

The workaround was to remove "public" or leave a static value ""

'baseUri' => preg_replace('/([\/\\])index.php$/', '', $_SERVER["PHP_SELF"]),

or

'baseUri' => "/",

This produces

<link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico"/>

But was the question whether this is a specific case in my setup? Or should I open a pull request to change de code generated?

My setup:

Xampp fresh install

PHP 7.2.5

Phalcon 3.4.0

Structure of directories generated by dev-tool unchanged

Have you tried to define baseUri as just /? No need for preg here.



148

Yes, i fixed this as stated in post.

My question is if I should open a pull request to change this in the generator code, because I imagine that many have the same problem, perhaps without knowing it.

I just realized that double calls to indexAction were being made because I put a test code to save a record in this action.