Welcome Guest, Not a member yet? Register   Sign In
View loading failure
#1

[eluser]ralf57[/eluser]
I've just found a strange behaviour trying to load a view while adding dynamic data to it.
It's a peculiar case and i need it to be confirmed before i submit it to the Bug Tracker.
My controller:
Code:
class MyController extends Controller
    {
    
        function MyController()
        {
            parent::Controller();
        }
    
        function index()
        {
            $data = array(
                'title' => 'My Title',
                'path' => 'My Title',
                'heading' => 'My Heading',
                'message' => 'My Message'
            );
            
            $this->load->view('myview', $data);
        }
    
    }

If in the passed array there is a key named "path" the view is not loaded at all
throwing this warning:

Code:
A PHP Error was encountered

Severity: Warning

Message: CI_Loader::include(My Title) [function.CI-Loader-include]: failed to open stream: No such file or directory

Filename: libraries/Loader.php

Line Number: 652

a quick check reveals that $data['path'] is used in libraries/Loader.php line 652 instead of the correct path.
Removing the $data['path'] key will fix the problem.

Is this a bug? Can you reproduce it?

------------------

Environement:
PHP Version 5.2.1
Apache 2.2.3
#2

[eluser]jedre[/eluser]
Hi, maybe it's small offtopic,
but if you use PHP v. 5.2.1 why u write constructor in PHP4 style?
#3

[eluser]deviant[/eluser]
To make it compatible with PHP4?
#4

[eluser]ralf57[/eluser]
Instead of going off-topic, did you try and reproduce
the behaviour/bug?
#5

[eluser]xwero[/eluser]
do you have a myview.php file?

ok that was not the question, you can skip my question.

I tried to reproduce it and i got an error in the Loader class on line 639, a variable $path is used there.
#6

[eluser]ralf57[/eluser]
[quote author="xwero" date="1188408739"]
I tried to reproduce it and i got an error in the Loader class on line 639, a variable $path is used there.[/quote]

if you do a "var_dump($path)" you get "My Title" instead of the path/to/the/myview, don't you?
#7

[eluser]xwero[/eluser]
Yes the $path value in the loader class was the value from the array. I used different values but with the same path key as you.
#8

[eluser]ralf57[/eluser]
It looks like a bug.
I will post it to the bugtracker.
#9

[eluser]coolfactor[/eluser]
I've notified the person in charge of maintaining CI.
#10

[eluser]barbazul[/eluser]
As I mentioned in this topic there are some reserved words in views.

Check the loader class and you'll notice that there are some assignments to the $data array.

The following are reserved variable names:
view
vars
path
return

and they should be documented




Theme © iAndrew 2016 - Forum software by © MyBB