WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.056 --> 00:00:05.386 align:middle
Triaging issues and pull
requests is seriously, the best.

00:00:05.946 --> 00:00:10.006 align:middle
But, occasionally, you might be
the person who finds the bug!

00:00:10.916 --> 00:00:14.646 align:middle
That happened to me just
today, and I want to report it!

00:00:15.816 --> 00:00:20.376 align:middle
To make the best possible bug report,
we should create a "reproducer":

00:00:20.376 --> 00:00:25.586 align:middle
a Symfony project that shows the
bug with as little code as possible.

00:00:26.306 --> 00:00:30.186 align:middle
I don't have the error I saw in front
of me now, but it was pretty simple:

00:00:30.776 --> 00:00:35.616 align:middle
I created a form class, tried to
use it in my controller, then boom!

00:00:36.186 --> 00:00:39.676 align:middle
I got a very strange container cache error.

00:00:40.566 --> 00:00:44.026 align:middle
The bug happened when I was playing
with the master branch of Symfony.

00:00:44.786 --> 00:00:48.736 align:middle
So, let's create our new
reproducer project based on that:

00:00:50.376 --> 00:00:55.376 align:middle
composer create-project
symfony/skeleton:dev-master

00:00:55.746 --> 00:01:05.236 align:middle
container_bug_reproducer When that
finishes, move into the new directory.

00:01:07.376 --> 00:01:10.796 align:middle
The one package I know I need is form.

00:01:12.016 --> 00:01:18.506 align:middle
Get it installed: composer require form
While we're waiting for this to finish,

00:01:18.756 --> 00:01:23.896 align:middle
go back to PhpStorm, close a few
files, and go into the new directory.

00:01:25.306 --> 00:01:29.196 align:middle
To reproduce my error, I
know I need a new form class.

00:01:30.126 --> 00:01:34.956 align:middle
Right inside src/, create a
new PHP class: SomeFormType.

00:01:35.526 --> 00:01:38.416 align:middle
My creativity today is off the charts.

00:01:39.516 --> 00:01:42.076 align:middle
Make this extend the usual AbstractType.

00:01:43.706 --> 00:01:47.196 align:middle
Normally, we would also add
the buildForm() method.

00:01:47.716 --> 00:01:50.976 align:middle
But... I'm not even sure that's
needed to trigger the bug.

00:01:51.776 --> 00:01:57.816 align:middle
So, in the spirit of making our reproducer
as small and focused as possible,

00:01:58.146 --> 00:02:01.896 align:middle
let's skip it, until we know it's needed.

00:02:03.206 --> 00:02:06.606 align:middle
In the Controller/ directory,
create another new PHP class:

00:02:07.546 --> 00:02:11.836 align:middle
ContainerTestController in
the App\Controller namespace.

00:02:14.936 --> 00:02:17.536 align:middle
Give it the usual public function test().

00:02:19.236 --> 00:02:23.006 align:middle
Because we need to create a
form, extend AbstractController

00:02:23.106 --> 00:02:25.606 align:middle
from FrameworkBundle so we have that shortcut.

00:02:27.876 --> 00:02:35.236 align:middle
Then, $form = $this-&gt;createForm()
and pass SomeFormType::class.

00:02:36.876 --> 00:02:40.596 align:middle
If I'm right, the error will happen right here.

00:02:43.706 --> 00:02:50.666 align:middle
To test this, find routes.yaml, uncomment the
route and point the controller to our code.

00:02:53.106 --> 00:02:53.756 align:middle
We're ready!

00:02:54.426 --> 00:02:57.306 align:middle
Go back to the terminal and
start the built-in web server:

00:02:57.306 --> 00:03:08.446 align:middle
php -S localhost:8000 -t public Move
back, find that browser tab and...

00:03:08.776 --> 00:03:17.556 align:middle
refresh! Say hello to the super weird error:
Compile error: failed opening required file ...

00:03:17.776 --> 00:03:19.846 align:middle
in some var/cache/dev directory.

00:03:20.876 --> 00:03:25.856 align:middle
This is related to the container,
and it's very low-level code.

00:03:26.996 --> 00:03:31.776 align:middle
It's possible I'm doing something
wrong, but this really looks like a bug.

00:03:33.086 --> 00:03:37.916 align:middle
To be sure, let's stop the web server,
manually clear the cache directory with:

00:03:38.206 --> 00:03:45.536 align:middle
rm -rf var/cache/* restart
the server and try it again.

00:03:48.026 --> 00:03:49.526 align:middle
Same error.

00:03:50.486 --> 00:03:57.536 align:middle
Let's take a screenshot: it's so useful to be
able to see the full stacktrace of an error.

00:03:58.746 --> 00:04:01.876 align:middle
Go back to the Symfony repository
and click to open a new issue.

00:04:06.786 --> 00:04:08.736 align:middle
Yep, this is a "Bug Report".

00:04:08.736 --> 00:04:12.046 align:middle
And, this is cool!

00:04:12.556 --> 00:04:15.106 align:middle
We have a nice outline of all the info needed.

00:04:17.206 --> 00:04:18.916 align:middle
Affected versions: master.

00:04:19.576 --> 00:04:24.726 align:middle
This could be a bug on a stable version,
and that is something we could check.

00:04:25.486 --> 00:04:30.706 align:middle
But, since it would be such a critical and
obvious bug, it's probably just on master.

00:04:32.426 --> 00:04:36.946 align:middle
For description, let's describe
what we're trying to do.

00:04:37.006 --> 00:04:39.346 align:middle
I'll also upload my error screenshot.

00:04:45.406 --> 00:04:50.136 align:middle
Oh, and I forgot a title: I'll reference
part of the error message for this.

00:04:51.876 --> 00:04:58.206 align:middle
Under "How to Reproduce", ah, this
is where our issue will shine!

00:04:59.406 --> 00:05:02.736 align:middle
Let's push our test project up
to GitHub so we can share it.

00:05:04.236 --> 00:05:09.336 align:middle
Move back to the terminal, stop the web server,
then initialize a new Git repository with:

00:05:09.816 --> 00:05:18.366 align:middle
git initgit add .git commit and a message.

00:05:23.606 --> 00:05:36.016 align:middle
Next, go to GitHub, click "New", type
a name and click "Create Repository".

00:05:39.536 --> 00:05:42.956 align:middle
Copy the two lines near the
bottom for an existing repository.

00:05:43.646 --> 00:05:46.016 align:middle
Then, find your terminal and...

00:05:46.186 --> 00:05:50.146 align:middle
paste! That's it!

00:05:51.216 --> 00:05:56.926 align:middle
Refresh the page on GitHub: here
is our simple reproducer app.

00:05:57.916 --> 00:05:58.926 align:middle
Copy its URL.

00:05:59.916 --> 00:06:01.656 align:middle
Then, head back to the issue.

00:06:02.306 --> 00:06:07.436 align:middle
Let's mention our reproducer app first
and how to trigger the error on it.

00:06:08.346 --> 00:06:13.396 align:middle
Then, to make life even easier,
summarize what we did to get the error.

00:06:13.396 --> 00:06:20.916 align:middle
As extra credit, I'll even link
right to the line that triggers it.

00:06:25.806 --> 00:06:27.046 align:middle
And... that's it!

00:06:27.636 --> 00:06:32.956 align:middle
I don't have any possible solution:
this error is way above my pay grade.

00:06:32.956 --> 00:06:34.256 align:middle
And, that's ok.

00:06:34.726 --> 00:06:35.986 align:middle
Finish the message and...

00:06:41.756 --> 00:06:42.286 align:middle
submit! We're done!

00:06:42.976 --> 00:06:46.686 align:middle
This is a bug report worth being proud of.

00:06:47.386 --> 00:06:49.106 align:middle
And, to prove it!

00:06:49.106 --> 00:06:50.266 align:middle
I have an update!

00:06:50.946 --> 00:06:55.996 align:middle
This issue was fixed less than
3 hours after we posted this.

00:06:56.686 --> 00:06:58.026 align:middle
That's amazing.

00:06:59.086 --> 00:07:04.686 align:middle
Next, let's jump into how we can contribute
code to Symfony via a pull request.

