-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Conversation
@@ -216,6 +215,27 @@ public function formatFileFromText($text) | |||
} | |||
|
|||
/** | |||
* @internal | |||
*/ | |||
public function formatLogMessage($message, $context) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
7d249b0
to
10b9db2
Compare
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. |
@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). |
10b9db2
to
d8e9b6c
Compare
I mis-read the code as well. 👍 |
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>'; |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
Thank you @nicolas-grekas. |
…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
Before:
After: