Welcome Guest, Not a member yet? Register   Sign In
Filters:after appears to be ignored
#11

(This post was last modified: 04-22-2020, 01:08 PM by Gary.)

Ok... I have some answers:

1) Regarding the toolbar, which was not being updated, and which I've found to frequently disappear (if one looks at several older questions/posts by other users regarding the toolbar not showing, this may be related):

In system\Debug\Toolbar.php:
Code:
public function prepare(RequestInterface $request = null, ResponseInterface $response = null)
{
  if (CI_DEBUG && ! is_cli())
  {
    ...
    // Non-HTML formats should not include the debugbar
    // then we send headers saying where to find the debug data
   // for this response
    if ($request->isAJAX() || strpos($format, 'html') === false) // << request AJAX || response doesn't have a 'html' content-type header
    {
      $response->setHeader('Debugbar-Time', "$time")
        ->setHeader('Debugbar-Link', site_url("?debugbar_time={$time}"))
        ->getBody();
       return;
     }                                                                      

If one's site is navigated by AJAX posts (as my current one is), this will have a notable impact on the toolbar's behavior.  If there are no knock-ons elsewhere in the framework, may I suggest investigating the possible removal of $request->isAJAX() from the check (since it is not uncommon for an AJAX request to result in a redirection or something that does force a page refresh).  The strpos($format, 'html') check currently prevents- and after the mod, will contunue to prevent- the toolbar script from being injected when the reply looks like it's destined for JavaScript digestion** (as does the <head> check in the code following this extract (not shown here)).

2) Regarding the related phenomenon of my code not having other AFTER filters applied... it so happened that the bits of code I was working on (that was outputting material destined for client-side JavaScript) ended in 'exit' and not 'return'... which works great, IF there is nothing else to be done by the framework. As soon as one requires additional AFTER filter processing, if 'exit' is used, this obviously stops these filters from being invoked. Adding a comment about this in the User Guide under Filters may perhaps save other folk a lot of time and headache in the future (?).

** $format is generated from $response->getHeaderLine('content-type'), and MAY also require $response->populateHeaders() to be run before it is called in this check to refresh the array it references (?)
Reply


Messages In This Thread
Filters:after appears to be ignored - by Gary - 04-20-2020, 06:33 AM
RE: Filters:after appears to be ignored - by Gary - 04-20-2020, 07:21 AM
RE: Filters:after appears to be ignored - by Gary - 04-21-2020, 03:50 AM
RE: Filters:after appears to be ignored - by Gary - 04-21-2020, 06:39 AM
RE: Filters:after appears to be ignored - by Gary - 04-21-2020, 08:48 AM
RE: Filters:after appears to be ignored - by Gary - 04-21-2020, 09:21 AM
RE: Filters:after appears to be ignored - by Gary - 04-22-2020, 04:38 AM
RE: Filters:after appears to be ignored - by Leo - 04-23-2020, 12:54 AM
RE: Filters:after appears to be ignored - by Gary - 04-23-2020, 03:14 AM
RE: Filters:after appears to be ignored - by Leo - 04-23-2020, 05:14 AM
RE: Filters:after appears to be ignored - by Gary - 04-24-2020, 09:07 AM
RE: Filters:after appears to be ignored - by Gary - 04-28-2020, 10:09 AM
RE: Filters:after appears to be ignored - by Leo - 04-29-2020, 01:07 AM
RE: Filters:after appears to be ignored - by Gary - 04-30-2020, 06:10 AM
RE: Filters:after appears to be ignored - by Leo - 04-30-2020, 12:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB