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: Request::$uri and current_url(true) behave differently #7296

Closed
kenjis opened this issue Feb 23, 2023 · 1 comment
Closed

Bug: Request::$uri and current_url(true) behave differently #7296

kenjis opened this issue Feb 23, 2023 · 1 comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@kenjis
Copy link
Member

kenjis commented Feb 23, 2023

CodeIgniter Version: 4.3.2

<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index()
    {
        $uri1 = $this->request->getUri();
        var_dump($uri1);

        $uri2 = current_url(true);
        var_dump($uri2);
    }
}

1. baseURL without subfolder

From: https://forum.codeigniter.com/showthread.php?tid=86872

baseURL: http://localhost:8080/null
segments: []['index.php']
path: /'/index.php/'

/Users/kenji/work/codeigniter/official/CodeIgniter4/app/Controllers/Home.php:10:
object(CodeIgniter\HTTP\URI)[13]
  protected 'uriString' => null
  private ?string 'baseURL' => string 'http://localhost:8080/' (length=22)
  protected 'segments' => 
    array (size=0)
      empty
  protected 'scheme' => string 'http' (length=4)
  protected 'user' => null
  protected 'password' => null
  protected 'host' => string 'localhost' (length=9)
  protected 'port' => int 8080
  protected 'path' => string '/' (length=1)
  protected 'fragment' => string '' (length=0)
  protected 'query' => 
    array (size=0)
      empty
  protected 'defaultPorts' => 
    array (size=4)
      'http' => int 80
      'https' => int 443
      'ftp' => int 21
      'sftp' => int 22
  protected 'showPassword' => boolean false
  protected 'silent' => boolean false
  protected 'rawQueryString' => boolean false

/Users/kenji/work/codeigniter/official/CodeIgniter4/app/Controllers/Home.php:13:
object(CodeIgniter\HTTP\URI)[61]
  protected 'uriString' => null
  private ?string 'baseURL' => null
  protected 'segments' => 
    array (size=1)
      0 => string 'index.php' (length=9)
  protected 'scheme' => string 'http' (length=4)
  protected 'user' => null
  protected 'password' => null
  protected 'host' => string 'localhost' (length=9)
  protected 'port' => int 8080
  protected 'path' => string '/index.php/' (length=11)
  protected 'fragment' => string '' (length=0)
  protected 'query' => 
    array (size=0)
      empty
  protected 'defaultPorts' => 
    array (size=4)
      'http' => int 80
      'https' => int 443
      'ftp' => int 21
      'sftp' => int 22
  protected 'showPassword' => boolean false
  protected 'silent' => boolean false
  protected 'rawQueryString' => boolean false

2. baseURL with subfolder

From: #7123 (comment)

baseURL: http://localhost:8888/ci432/public/null
segments: []['ci432', 'public', 'index.php']
path: /'/ci432/public/index.php/'

/Applications/MAMP/htdocs/ci432/app/Controllers/Home.php:10:
object(CodeIgniter\HTTP\URI)[12]
  protected 'uriString' => null
  private ?string 'baseURL' => string 'http://localhost:8080/' (length=22)
  protected 'segments' => 
    array (size=0)
      empty
  protected 'scheme' => string 'http' (length=4)
  protected 'user' => null
  protected 'password' => null
  protected 'host' => string 'localhost' (length=9)
  protected 'port' => int 8080
  protected 'path' => string '/' (length=1)
  protected 'fragment' => string '' (length=0)
  protected 'query' => 
    array (size=0)
      empty
  protected 'defaultPorts' => 
    array (size=4)
      'http' => int 80
      'https' => int 443
      'ftp' => int 21
      'sftp' => int 22
  protected 'showPassword' => boolean false
  protected 'silent' => boolean false
  protected 'rawQueryString' => boolean false

/Applications/MAMP/htdocs/ci432/app/Controllers/Home.php:13:
object(CodeIgniter\HTTP\URI)[51]
  protected 'uriString' => null
  private ?string 'baseURL' => null
  protected 'segments' => 
    array (size=1)
      0 => string 'index.php' (length=9)
  protected 'scheme' => string 'http' (length=4)
  protected 'user' => null
  protected 'password' => null
  protected 'host' => string 'localhost' (length=9)
  protected 'port' => int 8080
  protected 'path' => string '/index.php/' (length=11)
  protected 'fragment' => string '' (length=0)
  protected 'query' => 
    array (size=0)
      empty
  protected 'defaultPorts' => 
    array (size=4)
      'http' => int 80
      'https' => int 443
      'ftp' => int 21
      'sftp' => int 22
  protected 'showPassword' => boolean false
  protected 'silent' => boolean false
  protected 'rawQueryString' => boolean false
@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 23, 2023
@kenjis kenjis changed the title Bug: URI and current_url(true) behave differently Bug: Request::$uri and current_url(true) behave differently Feb 23, 2023
@kenjis
Copy link
Member Author

kenjis commented Aug 17, 2023

Closed by #7282

@kenjis kenjis closed this as completed Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

1 participant