debug_backtrace(), __FILE__, __DIR__ and related should return absolute paths #16

Fermé
ouvert(e) par belliash 2018-07-22 16:32:26 +02:00 · 7 commentaires
Propriétaire

Aer Information

  • Aer Version (or commit ref): 4c81475afb
  • Operating System: Linux
  • System Architecture (eg. arm, x86_64, ...): x86_64

Your problem description

Actually all mentioned methods (and probably more) returns a path relative to executable. As the executable can be located in any directory, this says actually nothing. Absolute path should be returned instead:

echo '[test] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL;

Expected results

[test] file: /path/to/test.php, line: 3, dir: /path/to

Current results

[test] file: test.php, line: 3, dir: .
<!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please take a moment to check that your issue doesn't already exist. 3. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> # Aer Information - Aer Version (or commit ref): 4c81475afb - Operating System: Linux - System Architecture (eg. arm, x86_64, ...): x86_64 # Your problem description Actually all mentioned methods (and probably more) returns a path relative to executable. As the executable can be located in any directory, this says actually nothing. Absolute path should be returned instead: echo '[test] file: ' . __FILE__ . ', line: ' . __LINE__ . ', dir: ' . __DIR__ . PHP_EOL; # Expected results [test] file: /path/to/test.php, line: 3, dir: /path/to # Current results [test] file: test.php, line: 3, dir: .
belliash a ajouté le label
enhancement
2018-07-22 16:32:26 +02:00.
devnexen a fermé ce ticket 2018-07-22 22:47:33 +02:00.
Auteur
Propriétaire

I don't think 4653e5b44e fixes this. I have not tested it, but I believe this should be fixed in Engine code, to address also all includes files. Please correct me if Im wrong.

I don't think 4653e5b44e fixes this. I have not tested it, but I believe this should be fixed in Engine code, to address also all includes files. Please correct me if Im wrong.
belliash a réouvert ce ticket 2018-07-23 06:23:45 +02:00.
Membre

Recommited in same branch.

Recommited in same branch.
devnexen a fermé ce ticket 2018-07-23 07:10:41 +02:00.
Auteur
Propriétaire

This breaks include_once & require_once.

This breaks include_once & require_once.
belliash a réouvert ce ticket 2018-07-23 07:22:41 +02:00.
Membre

Ah right I see why...

Ah right I see why...
Membre

Hopefully this time...

Hopefully this time...
Auteur
Propriétaire

Merged to master branch.

Merged to master branch.
belliash a fermé ce ticket 2018-07-23 07:50:51 +02:00.
belliash a réouvert ce ticket 2018-07-23 19:40:26 +02:00.
Auteur
Propriétaire

I have reverted merge. This cannot be implemented this way because PH7_StreamOpenHandle in vfs.c depends on that.

If filename does not begin with / it assumes it is not an absolute path at it is trying to include file from include path (PH7_VM_CONFIG_IMPORT_PATH).

It was not working, because the path builder working buffer was not reinitialized every loop iteration, thus containing some trash. The result was that it could not find a proper path. This is fixed by 3ed00e610f.

To sum up, I think that the absolute path should be saved together with relative path, so that we can use both together depending on current needs. This would allow us to include the relative filename from include path and display its absolute path. Another option is to replace relative path with absolute path from within PH7_StreamOpenHandle after it gets included (and we make sure it is included).

I have reverted merge. This cannot be implemented this way because PH7_StreamOpenHandle in vfs.c depends on that. If filename does not begin with / it assumes it is not an absolute path at it is trying to include file from include path (PH7_VM_CONFIG_IMPORT_PATH). It was not working, because the path builder working buffer was not reinitialized every loop iteration, thus containing some trash. The result was that it could not find a proper path. This is fixed by 3ed00e610f. To sum up, I think that the absolute path should be saved together with relative path, so that we can use both together depending on current needs. This would allow us to include the relative filename from include path and display its absolute path. Another option is to replace relative path with absolute path from within PH7_StreamOpenHandle after it gets included (and we make sure it is included).
belliash s'est assigné ça 2018-07-24 10:10:45 +02:00.
belliash a référencé ce ticket depuis une révision 2018-07-24 10:11:24 +02:00.
belliash a fermé ce ticket 2018-07-24 10:11:24 +02:00.
Connectez-vous pour rejoindre cette conversation.
2 participants
Notifications
Échéance
Aucune échéance n'a été définie.
Dépendances

Aucune dépendance définie.

Référence : aerscript/Aer#16
Sans contenu.