Skip to content
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

Bug toolbar #834

Closed
deathart opened this issue Nov 17, 2017 · 15 comments · Fixed by #843
Closed

Bug toolbar #834

deathart opened this issue Nov 17, 2017 · 15 comments · Fixed by #843

Comments

@deathart
Copy link
Contributor

deathart commented Nov 17, 2017

Hello,

Following the change felt on the debug toolbar, the javascript side no longer works.
I started by checking if there were any JS errors on the console, but no errors!
I then tried to put back

    <script>
        ciDebugBar.init();
    </script>

At the end of the file "tootbar. tpl. php" and everything works again!
Knowing that I have the last commit!
So the problem is me? or is this piece of code really missing?

Sorry for my English.

@lonnieezell
Copy link
Member

I'll try to look into that tonight. I know that it works on a default CI4 install. However, I did notice late last night that it didn't work on one of my test sites, but hadn't had a chance to determine why, yet. That gives me something to look into though, if no one else fixes it before I can :)

Thanks!

@lonnieezell
Copy link
Member

Figured out why - since you've got a test application I'm assuming your application/Config folders were not being updated, just the system directory. There are a couple of big changes to the way the toolbar works that require you do a couple of things in your application folder to migrate to the latest change:

  1. Add the following line to application/Config/Events.php, just under the Database one:
Events::on('pre_system', 'CodeIgniter\Debug\Toolbar::eventHandler');
  1. Replace the contents of the existing Toolbar filter (application/Filters/DebugToolbar.php) with the one in the current version.

Then you should be good to go.

@deathart
Copy link
Contributor Author

@deathart
Copy link
Contributor Author

deathart commented Nov 17, 2017

But now the rest of my JS code doesn't work anymore because of
id="debugbar_loader" in the code:

$script = PHP_EOL
                . '<script type="text/javascript" id="debugbar_loader" '
                . 'data-time="' . $time . '" '
                . 'src="' . rtrim(site_url(), '/') . '?debugbar"></script>'
                . PHP_EOL;

https://github.com/bcit-ci/CodeIgniter4/blob/develop/application/Filters/DebugToolbar.php#L64

@deathart deathart reopened this Nov 17, 2017
@lonnieezell
Copy link
Member

What problems are you seeing because of that? From what I understand an "id" attribute is valid on all html5 pages. Are you seeing issues validating against HTML4?

@natanfelles
Copy link
Contributor

Well, I having am issue related here. The toolbar is not loading in two ways:

1 - /

Accessing http://localhost:8080 the toolbar do not appears. I followed the script url http://localhost:8080/index.php?debugbar and see that this page has the same html of the welcome_message.php view.

To solve this and load the js page I removed the rtrim() to just . 'src="' . site_url() . '?debugbar"></script>'.

The toolbarloader also was not loading the toolbar html, then removing other rtrim() to just var url = "<?= site_url() ?>"; the toolbar back to be showed.

My doubt is why to use the rtrim()?

Without the / after index.php the http get method is not working here.

2 - /index.php

Also if I access http://localhost:8080/index.php the toolbar do not appears and this occurs for some strange reason that the $_SERVER['CI_ENVIRONMENT'] = 'development'; of the rewrite.php is not being declared. Of course, I do not understand, yet, why this is being ignored.

Yes, I am running the php serve CLI.


Had you some issue related or is it occurring only with me? If it is a general issue, I believe that the rtrim()'s is not necessary, to begin...

@gustavojm
Copy link
Contributor

Both rtrim were put because if $indexPage = index.php in App.php the toolbar would be loaded from
index.php/?debugbar generating a HTTP 301 redirect.
After the redirect the toolbar worked, but it created an unnecessary request.
Please check the network tab of the developper tools on the browser to see if the redirects happen without the rtrim.
Maybe it's just my rewrite config in .htaccess that causes it.
I'm on holidays so unaware of investigating this issue further.

@natanfelles
Copy link
Contributor

Hi, @gustavojm . Good evening.

Not redirect here:

captura de tela de 2017-11-18 21-16-37

@gustavojm
Copy link
Contributor

Thanks @natanfelles I guess that the rtrims can be removed then, and I'll try to figure out what's wrong in my setup. If you can, create the PR.
Sorry for that!

@deathart
Copy link
Contributor Author

So my pages are in html5, but the problem is that because of this id="debugbar_loader" the rest of my JS scripts don't work anymore.

On the other hand, the debug toolbar works without worries.

And my problem has nothing to do with rtrims, because with or without it there is no difference.

@natanfelles
Copy link
Contributor

Here has difference:

captura de tela de 2017-11-19 18-27-32

Look that the xhr is not loaded. It occurs because the index.php?debugbar is returning the html view.

Of course this could not have difference with or without a /.


@deathart Is the id debugbar_loader being duplicated? What your console show about your javascript code? Is your javascript really being loaded?

@deathart
Copy link
Contributor Author

deathart commented Nov 20, 2017

So no it's not duplicating, I have no info in the console logs and yes all this load correctly it's for that I don't understand at all.

Edit :
On the other hand I just thought, I use twig system for the views, so it can come from the no?

@puschie286
Copy link
Contributor

puschie286 commented Nov 23, 2017

hey, same problem here. some js interactions doesnt work anymore ( onclick still get triggered )
( the toolbar works great, no problems with that )

tested on all browsers ( firefox, chrome, edge ) with same result, so guess its no js implementation bug
@deathart i use just ci and have the same problem

i will have a closer look tomorrow

@deathart
Copy link
Contributor Author

I confirm that https://github.com/bcit-ci/CodeIgniter4/pull/843/files solves my problem.

@natanfelles
Copy link
Contributor

@deathart if you want, you can close this issue. My "related issue" is solved too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants