Skip to content

php server/index.php (CLI) crashes on undefined $_SERVER keys #95

@zacaway

Description

@zacaway

Running the entry point directly from the CLI — e.g. for the cron feed-update path guarded by PHP_SAPI === 'cli' in server/index.php — fatals before reaching that code, because three $_SERVER keys that only exist under a web server are accessed unconditionally:

  • server/index.php:5$_SERVER['REQUEST_URI']
  • server/_inc.php:46$_SERVER['SERVER_PORT'] (in the HTTP_SCHEME default)
  • server/_inc.php:76-77$_SERVER['SERVER_NAME'] / SERVER_PORT (building BASE_URL)

On PHP 8+ these produce Undefined array key warnings and a parse_url(null) deprecation, and the error handler aborts the run.

Reproduce

php server/index.php
Warning: Undefined array key "REQUEST_URI" in server/index.php on line 5
Deprecated: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in server/index.php on line 5
 /!\ PHP error
Warning: Undefined array key "SERVER_PORT"

Expected

The CLI path should run (it's intended — it calls updateAllFeeds()), not fatal on missing web-server superglobals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions