Skip to content

Bugfix: PHP on internal webserver + win + env ANSICON set #2

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

Closed
wants to merge 1 commit into from
Closed

Bugfix: PHP on internal webserver + win + env ANSICON set #2

wants to merge 1 commit into from

Conversation

benjamin-carl
Copy link

This fixes a bug with formatted output (formatted for CLI instead Web) when running PHP on internal webserver on windows with having ANSICON set.

This fixes a bug with formatted output (formatted for CLI instead Web) when running PHP on internal webserver on windows with having ANSICON set.
@fabpot
Copy link
Member

fabpot commented Sep 14, 2015

ping @nicolas-grekas

@nicolas-grekas
Copy link
Member

I'm confused, this can't be the right fix unless I miss something: this line is only for reducing the color palette to 16. Nothing related to the internal webserver. CLI vs HTML mode is made in src/Symfony/Component/VarDumper/VarDumper.php.
Can you provide more details or even better: a reproducer script/gist?

@benjamin-carl
Copy link
Author

This is the fix for the following scenario - Sry but I can't provide a reproducer script/gist - but more Details and if you read the following line for line I'm pretty sure you will get me :) :

The facts:

  1. HtmlDumper extends CliDumper
  2. In HtmlDumper the __construct(or) calls parents __construct(or)

... and exactly THIS is the problem:

The CliDumper needs a (not specially mine but any) additional check to verify that it is really in CONSOLE mode cause it is definitively executed in Html mode as well - the line:
if ('\\' === DIRECTORY_SEPARATOR && false !== @getenv('ANSICON')) {
will be executed also when in HTML/WEB environment (Browser or something).

read: If WINDOWS and ANSICON set true
(both matches in my case although I'm using the Browser for output! maybe cause of ANSICON set to TRUE if PHP's internal webserver is started in cygwin/gitbash on win)

Another fix would be another structure AbstractDumper (core logic) and a CliDumper and a HtmlDuper both extending the this abstract base class not each other. This would be also a bit cleaner from my point of view. Please don't get me wrong: Not saying it's dirty implemented! ;)

Thanks for all your work - i really like this piece of software.

@nicolas-grekas
Copy link
Member

Understood! See symfony/symfony#15804

nicolas-grekas added a commit to symfony/symfony that referenced this pull request Sep 17, 2015
… (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[VarDumper] Fix HtmlDumper constructor calling CliDumper's

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/var-dumper#2 (comment)
| License       | MIT
| Doc PR        | -

Commits
-------

4c7bb9c [VarDumper] Fix HtmlDumper constructor calling CliDumper's
@nicolas-grekas
Copy link
Member

Fixed

@fabpot fabpot closed this Sep 18, 2015
symfony-splitter pushed a commit that referenced this pull request Jul 20, 2022
…afimArts)

This PR was squashed before being merged into the 6.2 branch.

Discussion
----------

[VarDumper] Add `FFI\CData` and `FFI\CType` types

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Added support of FFI:
```php
$ffi = \FFI::cdef(<<<'CPP'
    typedef struct { int x; int y; } Point;
    typedef struct Example {
        uint8_t array[32];
        long longVal;
        __extension__ union {
            __extension__ struct { short shortVal; };
            struct { Point point; float e; };
        };
        bool boolValue;
        int (*func)(struct __sub *h);
    } Example;
CPP);

$struct = $ffi->new('Example');
$struct->func = (static fn (object $ptr) => 42);

dump($struct);
```

**Before**

```
FFI\CData {#2}
```

**After**

```
FFI\CData<struct Example> size 64 align 8 {#2
  +array: FFI\CData<uint8_t[32]> size 32 align 1 {#18}
  +int32_t longVal: 0
  +int16_t shortVal: 0
  +point: FFI\CData<struct <anonymous>> size 8 align 4 {#17
    +int32_t x: 0
    +int32_t y: 0
  }
  +float e: 0.0
  +bool boolValue: false
  +func: [cdecl] callable(struct __sub*): int32_t {#20
    returnType: FFI\CType<int32_t> size 4 align 4 {#25}
  }
}
```

P.S. I apologize for the multiple force pushes, errors in tests and codestyle have been fixed.

## Review And TODOs

- Pointers
  - [x] Pointer to scalar tests.
  - [x] Pointer to struct tests.
  - [x] "Special" pointer to `char*` tests (with `\0` and without `\0`).
- Possible Errors
  - [x] Do not dump union fields with pointer references (possible SIGSEGV).

Commits
-------

1c7dc52abb [VarDumper] Add `FFI\CData` and `FFI\CType` types
omarjiuiuki pushed a commit to omarjiuiuki/var-dumper that referenced this pull request Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants