Skip to content

PHP Error Notices - Undefined index when PHP is run from the command line #9

Open

Description

@lencioni

When a script is run from the command line, three notices are generated in external/header.php:

Undefined index: REMOTE_ADDR in external/header.php on 16
Undefined index: REQUEST_URI in external/header.php on 39
Undefined index: REMOTE_ADDR in external/header.php on 5

Activity

  1. preinheimer commented on Jan 5, 2011

    @preinheimer
    Owner

    Hrm...

    I hadn't really considered the use case of running this from the command line, so the request parameters are presumed to exist. Any suggestions on the best way to handle this?

    paul

  2. lencioni commented on Jan 5, 2011

    @lencioni
    Author

    Yeah, running PHP from the command line typically doesn't happen for us except for cron jobs.

    You could either determine if it is being run from the command line and then have it skip out on xhprof (so the command line stuff wouldn't be ever profiled) or you could add some isset() checks for each of these.

    For example, line 5 would be:

    if(isset($_SERVER['REMOTE_ADDR']) && in_array($_SERVER['REMOTE_ADDR'], $controlIPs) && isset($_GET['_profile']))
    

    and line 16 would be:

    if (isset($_SERVER['REMOTE_ADDR']) && in_array($_SERVER['REMOTE_ADDR'], $controlIPs) && (isset($_COOKIE['_profile']) && $_COOKIE['_profile']))
    
  3. lencioni commented on Jan 5, 2011

    @lencioni
    Author

    Also found Undefined index: REQUEST_URI in utils/xhprof_runs.php on 424

  4. lencioni commented on Jan 5, 2011

    @lencioni
    Author

    I'm thinking that if REQUEST_URI doesn't exist, you might be able to substitute $_SERVER['PHP_SELF'] which would be the path of the file that is being run.

  5. lencioni commented on Jan 10, 2011

    @lencioni
    Author

    Also found

    Undefined index: c_url in xhprof_html/index.php on 167
    Undefined index: timestamp in xhprof_html/index.php on 171

    when requesting /xhprof_html/?hit=50&days=1

  6. preinheimer commented on Nov 24, 2011

    @preinheimer
    Owner

    #23 might help a bunch of items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions