1 | <?php |
||
2 | |||
3 | /* For licensing terms, see /license.txt */ |
||
4 | |||
5 | use Chamilo\PluginBundle\Entity\XApi\ToolLaunch; |
||
6 | use Symfony\Component\HttpFoundation\Request as HttpRequest; |
||
0 ignored issues
–
show
|
|||
7 | |||
8 | require_once __DIR__.'/../../main/inc/global.inc.php'; |
||
9 | |||
10 | api_protect_course_script(true); |
||
11 | api_protect_teacher_script(); |
||
12 | |||
13 | $request = HttpRequest::createFromGlobals(); |
||
14 | |||
15 | $em = Database::getManager(); |
||
16 | |||
17 | $toolLaunch = $em->find( |
||
18 | ToolLaunch::class, |
||
19 | $request->query->getInt('delete') |
||
20 | ); |
||
21 | |||
22 | if (null === $toolLaunch |
||
23 | || $toolLaunch->getCourse()->getId() !== api_get_course_entity()->getId() |
||
24 | ) { |
||
25 | api_not_allowed(true); |
||
26 | } |
||
27 | |||
28 | $plugin = XApiPlugin::create(); |
||
29 | |||
30 | $em = Database::getManager(); |
||
31 | $em->remove($toolLaunch); |
||
32 | $em->flush(); |
||
33 | |||
34 | Display::addFlash( |
||
35 | Display::return_message($plugin->get_lang('ActivityDeleted'), 'success') |
||
36 | ); |
||
37 | |||
38 | header('Location: '.api_get_course_url()); |
||
39 | exit; |
||
40 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: