Welcome Guest, Not a member yet? Register   Sign In
  forge->addColumn
Posted by: Chroma - 05-21-2025, 10:24 AM - Replies (2)

Hi All,

CI 4.6.1.

I am trying to add a new column to an existing table. I am not having any luck.


PHP Code:
        $val                  = array();
        $obj['email_private'] = $this->getEmailField();
        $val                  $obj['email_private'] + ['after' => 'email_public'];
        $this->forge->addColumn('entry_requests'$val); 


getEmailFields looks like


PHP Code:
    protected function getEmailField()
    {
        $str = ['type' => 'VARCHAR''constraint' => '128''DEFAULT' => ' ''null' => 'false',];
        return $str;
    // end of method 

The error I am getting is an exception inside forge->addField. It seems that for some reason, it doesn't like the VARCHAR part of the definition. It throws a "Field information is required for that operation." exception, from line 387.

The variable $val contains:
  • type = "VARCHAR"
  • constraint = "128"
  • DEFAULT = " "
  • null = "false"
  • after = "email_public"

I don't see what I have done wrong and cannot find the error on the internet to track it down further.

Any help is much appreciated.


  Validation Rules: Valid email, but allow null?
Posted by: sevmusic - 05-19-2025, 02:05 PM - Replies (3)

In my app I have 2 email address fields.

The first field is required because it's the main account.

The second field is optional.

Here are my rules currently.

PHP Code:
public $profile = [
    
'login_email' => ['label' => 'Login Email''rules' => 'required|valid_email'],
    
'login_email_2' => ['label' => '2nd Login Email''rules' => 'valid_email'
]; 

But when I leave the login_email_2 field blank it complains that it's not a valid email.

How can I ignore the valid email rule if the field is blank?

I think I solved my own problem with permit_empty

Is there a listing of all the codeigniter validation rules?

I didn't see them singled out in the docs.


  Changing Session cookie - samesite v4.6.1
Posted by: codeus - 05-17-2025, 01:07 AM - Replies (12)

Hi all,
Using v4.6.1 - in app/Config/Cookie.php - after changing samesite setting to 'None'

PHP Code:
    public string $samesite 'None'

Console error is:
Quote:Cookie “pm_id” has been rejected because it is in a cross-site context ...

Still get cross-site errors. I'm doing this for testing, connecting to the remote CI4 server from localhost on local machine.

I've tried using Cookie helper to no avail-:
PHP Code:
helper('cookie');
 
set_cookie('session_id'''3600'',''truetrue'None'); 

Is it possible to force samesite to 'None' for the CI session cookie?

Many thanks,
Mike


  using app/Config/App.php in CodeIgniter 4
Posted by: sam547 - 05-16-2025, 03:04 PM - No Replies

Hello folks,
Does anyone know that if I put some codes in app/Config/App.php

PHP Code:
public function __construct()
    {
 
parent::__construct();
 
$services = new Services();
 
$services->loadServices();
 
    
does this get called at every request or when apache is restarted ?

Thanks


  hot-reload side effects seem to be clobbering my app
Posted by: PaulC - 05-14-2025, 05:09 AM - Replies (10)

Hi Team,
I am slowly losing the will ...
I think the debug toolbar and tracing is very helpful but at the moment my app is not behaving as expected ie serving a login view when someone logs out after redirect.
Looking at the FF java console I see messages like this:

The connection to https://localhost/__hot-reload was interrupted while the page was loading. login line 37 > injectedScript:702:29
EventSource failed:
error { target: EventSource, isTrusted: true, srcElement: EventSource, currentTarget: EventSource, eventPhase: 2, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, … }
login line 37 > injectedScript:710:21
    onerror https://localhost/login line 37 > injectedScript:710
    (Async: EventHandlerNonNull)
    hotReloadConnect https://localhost/login line 37 > injectedScript:709
    setHotReloadState https://localhost/login line 37 > injectedScript:697
    init https://localhost/login line 37 > injectedScript:27
    onreadystatechange https://localhost/?debugbar:49
    (Async: EventHandlerNonNull)
    loadDoc https://localhost/?debugbar:14
    (Async: EventListener.handleEvent)
    <anonymous> https://localhost/?debugbar:1
This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”. login
XHRGET
https://localhost/?debugbar_time=1747223756.436512
[HTTP/1.1 200 OK 78ms]

XHRGET
https://localhost/__hot-reload


At this moment I am trying to redirect to "https//localhost/login" which I have successfully proved works when I initially login, but once I logout and redirect back to the same place I never see the login screen again.
I am very frustrated and really cannot work out why.
Any help would be appreciated, Thx, Paul


Bug Missing closing bracket when there is cached query & multiple nested bracket
Posted by: abf - 05-13-2025, 07:27 PM - No Replies

There is an issue where 'closing bracket' does not appear when there is 'cached query' and 'multiple nested brackets'.

Here is the example code:

PHP Code:
// cached query
$this->db->start_cache();
$this->db->where("col_desc"'test_inside_bracket');
$this->db->stop_cache();

// add additional 'where' using bracket (used to implement 'keyset pagination')
$this->db->bracket();
    $this->db->bracket();
        $this->db->where("col_name > 'test_name'");
    $this->db->bracket_close();
    $this->db->or_bracket();
        $this->db->where("col_name = 'test_name'");
        $this->db->where("col_id < 12345");
    $this->db->bracket_close();
$this->db->bracket_close();
$this->db->order_by("col_name asc, col_id desc");

// check the query
$check_query $this->db->_get_select();
die(
$check_query); 

---
The result from code above is:
Code:
SELECT *
WHERE col_desc = 'test_inside_bracket'
AND  (
  (
col_name > 'test_name'
  )
OR    (
col_name = 'test_name'
AND col_id < 12345
)
ORDER BY col_name asc, col_id desc

The above result is missing 1 closing bracket.
The expected output should be like this:
Code:
SELECT *
WHERE col_desc = 'test_inside_bracket'
AND  (
  (
col_name > 'test_name'
  )
OR    (
col_name = 'test_name'
AND col_id < 12345
)
)
ORDER BY col_name asc, col_id desc

---
The issue above is gone when I remove the start_cache() and stop_cache() line (or one of those).
PHP Code:
// no cache, just plain where and some brackets
$this->db->where("col_desc"'test_inside_bracket');
$this->db->bracket();
    $this->db->bracket();
        $this->db->where("col_name > 'test_name'");
    $this->db->bracket_close();
    $this->db->or_bracket();
        $this->db->where("col_name = 'test_name'");
        $this->db->where("col_id < 12345");
    $this->db->bracket_close();
$this->db->bracket_close();
$this->db->order_by("col_name asc, col_id desc");

// check the query
$check_query $this->db->_get_select();
die(
$check_query); 

And the issue above is also gone when there is only one nested bracket:
PHP Code:
// cached query
$this->db->start_cache();
$this->db->where("col_desc"'test_inside_bracket');
$this->db->stop_cache();

// add additional 'where' using bracket (used to implement 'keyset pagination')
$this->db->bracket();
    $this->db->bracket();
        $this->db->where("col_name > 'test_name'");
    $this->db->bracket_close();
    // $this->db->or_bracket(); // if this bracket (and closing bracket) is uncommented, the closing bracket will be missing
    //    $this->db->where("col_name = 'test_name'");
    //    $this->db->where("col_id < 12345");
    // $this->db->bracket_close();
$this->db->bracket_close();
$this->db->order_by("col_name asc, col_id desc");

// check the query
$check_query $this->db->_get_select();
die(
$check_query); 

---
Please help with the issue above.
Any feedback / workaround would be greatly appreciated.
Thank you.

NB:
Temporary solusion for that issue is doing 'cache query' manually (put the query in function, then call that function to get the query. Not using start_cache()).


  Setting baseURL in Registrar not working
Posted by: petewulf1 - 05-13-2025, 03:20 AM - Replies (9)

Hey guys,
the registrar does not seem to work (at least for me). I followed th documentation and set it up like so:
-------------------

Code:
<?php

namespace Config;

class Registrar{

  public function __construct(){
    defined('LOCATION') || define('LOCATION', $_SERVER['CI_ENVIRONMENT']);
    }

  public static function App(): array{
     
    $conf = [];
    $conf['baseURL'] = 'http://192.168.0.1:81/'; 
    if(LOCATION == 'staging') $conf['baseURL'] = 'http://mydomain.com/';

    return $conf;

    }
  }
---------------------

I always get the error 
Fatal error: Uncaught CodeIgniter\Exceptions\ConfigException: Config\App::$baseURL "/" is not a valid URL. in ...\vendor\codeigniter4\framework\system\HTTP\SiteURI.php:201

Autodiscovery is set to true.
Its only workig if a manually set the baseURL in App.php but the URL should be set dynamically based on the environment. CI3 was way more comfortable and dynamic to set up.
Anybody knows the problem?

Thanks and kind regards,
Daniel


  Sessions old files are deleted
Posted by: Stord1980 - 05-11-2025, 11:31 PM - Replies (1)

Currently, within the Session library when using file - we see CI_Session_files_driver::read taking up to 120s to process 
Sessions old files are deleted but after some time I see still see these performance issues on requests tracked in NewRelic where it takes 100-120s


  Update from 4.6.0 to 4.6.1 failed
Posted by: Vespa - 05-11-2025, 07:13 AM - Replies (8)

I got in trouble with latest update...it's my fault for sure but each update it's a pain.
I run composer update to update new files...then I downloaded the latest package and manually replaced the following files in the project space:

Code:
app/Config/Autoload.php

app/Config/Cache.php

app/Config/DocTypes.php

app/Config/Mimes.php

app/Config/Modules.php

app/Config/Optimize.php

app/Config/Paths.php

app/Views/errors/html/debug.css

preload.php

public/index.php

spark

Now, when I try to run spark serve file I got the follwoing error:
Code:
PHP Warning:  require(D:\_GAVS_nuovo_sito\project-root\app\Config/../../system/Boot.php): Failed to open stream: No such file or directory in D:\_GAVS_nuovo_sito\project-root\spark on line 85

Warning: require(D:\_GAVS_nuovo_sito\project-root\app\Config/../../system/Boot.php): Failed to open stream: No such file or directory in D:\_GAVS_nuovo_sito\project-root\spark on line 85
PHP Fatal error:  Uncaught Error: Failed opening required 'D:\_GAVS_nuovo_sito\project-root\app\Config/../../system/Boot.php' (include_path='.;C:\php\pear') in D:\_GAVS_nuovo_sito\project-root\spark:85
Stack trace:
#0 {main}
  thrown in D:\_GAVS_nuovo_sito\project-root\spark on line 85

Fatal error: Uncaught Error: Failed opening required 'D:\_GAVS_nuovo_sito\project-root\app\Config/../../system/Boot.php' (include_path='.;C:\php\pear') in D:\_GAVS_nuovo_sito\project-root\spark:85
Stack trace:
#0 {main}
  thrown in D:\_GAVS_nuovo_sito\project-root\spark on line 85

Honestly I have no idea what I did wrong...any hint or help? Thanks a lot


  Ajax post failing with TypeError
Posted by: PaulC - 05-10-2025, 06:25 AM - Replies (4)

I have defined the route and when I actually fire the JS I end up with the following: (CI 4.6.0, on FireFox). Is this a CI problem please?
{
    "title": "TypeError",
    "type": "TypeError",
    "code": 500,
    "message": "CodeIgniter\\HTTP\\Request::fetchGlobal(): Argument #3 ($filter) must be of type ?int, true given, called in /var/www/html/gnb/ci460/system/HTTP/IncomingRequest.php on line 714",
    "file": "/var/www/html/gnb/ci460/system/HTTP/RequestTrait.php",
    "line": 258,
    "trace": [
        {
            "file": "/var/www/html/gnb/ci460/system/HTTP/IncomingRequest.php",
            "line": 714,
            "function": "fetchGlobal",
            "class": "CodeIgniter\\HTTP\\Request",
            "type": "->"
        },
        {
            "file": "/var/www/html/gnb/ci460/app/Controllers/TheBigPicture.php",
            "line": 148,
            "function": "getPost",
            "class": "CodeIgniter\\HTTP\\IncomingRequest",
            "type": "->"
        },
        {
            "file": "/var/www/html/gnb/ci460/system/CodeIgniter.php",
            "line": 933,
            "function": "interact",
            "class": "App\\Controllers\\TheBigPicture",
            "type": "->"
        },
        {
            "file": "/var/www/html/gnb/ci460/system/CodeIgniter.php",
            "line": 507,
            "function": "runController",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/var/www/html/gnb/ci460/system/CodeIgniter.php",
            "line": 354,
            "function": "handleRequest",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/var/www/html/gnb/ci460/system/Boot.php",
            "line": 334,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "/var/www/html/gnb/ci460/system/Boot.php",
            "line": 67,
            "function": "runCodeIgniter",
            "class": "CodeIgniter\\Boot",
            "type": "::"
        },
        {
            "file": "/var/www/html/gnb/ci460/public/index.php",
            "line": 56,
            "function": "bootWeb",
            "class": "CodeIgniter\\Boot",
            "type": "::"
        }
    ]
}


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
AssetConnect - a powerful...
by maniaba
Yesterday, 03:53 AM
twig and view cell
by foxbille
Yesterday, 01:58 AM
Best Way to Implement Aff...
by InsiteFX
07-04-2025, 09:58 PM
The pipe operator in PHP ...
by InsiteFX
07-04-2025, 04:18 PM
Heads up for users using ...
by FlavioSuar
07-04-2025, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
curl + response body
by michalsn
07-03-2025, 10:10 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 154,955
» Latest member: banhopchairking
» Forum threads: 78,441
» Forum posts: 379,731

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB