| Conditions | 2 |
| Paths | 2 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | function jquery_out() { |
||
| 24 | $cache = new Cache('jquery', '.js'); |
||
| 25 | $files = array( |
||
| 26 | DOKU_INC . 'lib/scripts/jquery/jquery.min.js', |
||
| 27 | DOKU_INC . 'lib/scripts/jquery/jquery-ui.min.js', |
||
| 28 | ); |
||
| 29 | $cache_files = $files; |
||
| 30 | $cache_files[] = __FILE__; |
||
| 31 | |||
| 32 | // check cache age & handle conditional request |
||
| 33 | // This may exit if a cache can be used |
||
| 34 | $cache_ok = $cache->useCache(array('files' => $cache_files)); |
||
| 35 | http_cached($cache->cache, $cache_ok); |
||
| 36 | |||
| 37 | $js = ''; |
||
| 38 | foreach($files as $file) { |
||
| 39 | $js .= file_get_contents($file)."\n"; |
||
| 40 | } |
||
| 41 | stripsourcemaps($js); |
||
| 42 | |||
| 43 | http_cached_finish($cache->cache, $js); |
||
| 44 | } |
||
| 45 |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: