Skip to content
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

[TwigBundle] Give some love to exception pages #20525

Merged
merged 1 commit into from
Nov 16, 2016

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 3.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Before:
before

After:
after

@@ -216,6 +215,27 @@ public function formatFileFromText($text)
}

/**
* @internal
*/
public function formatLogMessage($message, $context)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second argument should be typehinted as array IMO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nicolas-grekas nicolas-grekas force-pushed the fix-exception-page branch 2 times, most recently from 7d249b0 to 10b9db2 Compare November 15, 2016 12:11
@javiereguiluz javiereguiluz added this to the 3.3 milestone Nov 15, 2016
@linaori
Copy link
Contributor

linaori commented Nov 15, 2016

Are they opened by default? If so, can you add a limit of maybe 5 or 10 logs? I've had pages where there are 100+ logs and that will make it annoying to find the exception.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Nov 15, 2016

@iltar this PR is about fixing this page, ie make it work again; not about making it better. We could (and should) work on that for 3.3. But this one is a bug fix (placeholders are not replaced right now, and CSS needs a fix in the code block excerpt).

@fabpot
Copy link
Member

fabpot commented Nov 15, 2016

I mis-read the code as well. 👍

@fabpot fabpot modified the milestones: 3.2, 3.3 Nov 15, 2016
@linaori
Copy link
Contributor

linaori commented Nov 15, 2016

Ah my bad, I only saw new code 😆

@@ -151,7 +152,7 @@ public function fileExcerpt($file, $line, $srcContext = 3)
}

for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, count($content)); $i <= $max; ++$i) {
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><div class="anchor" id="line'.$i.'"></div><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><a class="anchor" name="line'.$i.'"></a><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a[name] is not valid HTML5... what about <li id="x"><code></code></li> As anchor linking will work on any ID anyway...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be only one specific id on a page, yet this is called several times.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a static counter internally? To create something unique..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the target is not predictable, we're going to have a hard time linking to it...

Copy link
Contributor

@ro0NL ro0NL Nov 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Maybe generate a hash of file+line.. or something, and only add a unique prefix for the 2nd and upcoming instances (ie. the first instance is predictable).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a with name works, let's not create a pile of code to solve no actual issue...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo. it should produce valid HTML5 :).. but fair enough.

@fabpot
Copy link
Member

fabpot commented Nov 16, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit d8e9b6c into symfony:master Nov 16, 2016
fabpot added a commit that referenced this pull request Nov 16, 2016
…ekas)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[TwigBundle] Give some love to exception pages

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Before:
![before](https://cloud.githubusercontent.com/assets/243674/20304174/e4e0f492-aafc-11e6-8ca4-c76bea856f7a.png)

After:
![after](https://cloud.githubusercontent.com/assets/243674/20304178/e8dcaae6-aafc-11e6-87a0-567be498fc6e.png)

Commits
-------

d8e9b6c [TwigBundle] Give some love to exception pages
@fabpot fabpot mentioned this pull request Nov 17, 2016
@nicolas-grekas nicolas-grekas deleted the fix-exception-page branch November 18, 2016 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants