Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Bug: Entity::toRawArray() may return Time object

Abierto
#8,302 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@jalexiscv ya está trabajando en esto.

Desde el 18/5/2026.

  • #9286 de @ping-yee — cerrado sin fusionar
  • #10207 de @jalexiscv — abierto
  • #10400 de @gr8man — cerrado sin fusionar
  • #10401 de @gr8man — cerrado sin fusionar
  • #10402 de @gr8man — cerrado sin fusionar

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
mysql, php
Área
backend, database

Línea de trabajo

Comienza rastreando Entity::toRawArray() con la entidad User y los campos de fecha mostrados en la reproducción. Vuelve a ejecutar la secuencia proporcionada de find, asignación y toRawArray, y verifica después que updated_at se devuelva como el string esperado en lugar de como un objeto CodeIgniter\I18n\Time.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
PHP Version

8.1

CodeIgniter4 Version

4.4.3 and develop

CodeIgniter4 Installation Method

Git

Which operating systems have you tested for this bug?

macOS

Which server did you use?

cli-server (PHP built-in webserver)

Database

MySQL 8.0.34

What happened?

The following code returns Time object.

        $user->updated_at = '2023-12-12 12:12:12';
        var_dump($user->toRawArray());
Steps to Reproduce
+----+------------+--------------------+---------+--------------------+--------------------+------------+
| id | name       | email              | country | created_at         | updated_at         | deleted_at |
+----+------------+--------------------+---------+--------------------+--------------------+------------+
| 1  | John Smith | [email protected]... | US      | 2023-12-07 04:0... | 2023-12-07 04:0... |            |
+----+------------+--------------------+---------+--------------------+--------------------+------------+
<?php

namespace App\Models;

use App\Entities\User;
use CodeIgniter\Model;

class UserModel extends Model
{
    protected $table            = 'user';
    protected $returnType       = User::class;
    protected $allowedFields    = [
        'name',
        'email',
        'country',
    ];

    // Dates
    protected $useTimestamps = true;
    protected $dateFormat    = 'datetime';
    protected $createdField  = 'created_at';
    protected $updatedField  = 'updated_at';
    protected $deletedField  = 'deleted_at';
}
<?php

namespace App\Entities;

use CodeIgniter\Entity\Entity;

class User extends Entity
{
    protected $datamap = [];
    protected $dates   = ['created_at', 'updated_at', 'deleted_at'];
    protected $casts   = [];
}
    public function index()
    {
        $users = new UserModel();
        /** @var User $user */
        $user = $users->find(1);
        var_dump($user->toRawArray());

        $user->updated_at = '2023-12-12 12:12:12';
        var_dump($user->toRawArray());

        $user = $users->find(1);
        var_dump($user->toRawArray());
    }
/Users/kenji/work/codeigniter/official/CodeIgniter4/app/Controllers/Home.php:15:
array (size=7)
  'id' => string '1' (length=1)
  'name' => string 'John Smith' (length=10)
  'email' => string '[email protected]' (length=16)
  'country' => string 'US' (length=2)
  'created_at' => string '2023-12-07 04:00:48' (length=19)
  'updated_at' => string '2023-12-07 04:00:48' (length=19)
  'deleted_at' => null

/Users/kenji/work/codeigniter/official/CodeIgniter4/app/Controllers/Home.php:18:
array (size=7)
  'id' => string '1' (length=1)
  'name' => string 'John Smith' (length=10)
  'email' => string '[email protected]' (length=16)
  'country' => string 'US' (length=2)
  'created_at' => string '2023-12-07 04:00:48' (length=19)
  'updated_at' => 
    object(CodeIgniter\I18n\Time)[88]
      protected 'timezone' => 
        object(DateTimeZone)[90]
          public 'timezone_type' => int 3
          public 'timezone' => string 'UTC' (length=3)
      protected 'locale' => string 'en' (length=2)
      protected 'toStringFormat' => string 'yyyy-MM-dd HH:mm:ss' (length=19)
      public 'date' => string '2023-12-12 12:12:12.000000' (length=26)
      public 'timezone_type' => int 3
      public 'timezone' => string 'UTC' (length=3)
  'deleted_at' => null

/Users/kenji/work/codeigniter/official/CodeIgniter4/app/Controllers/Home.php:21:
array (size=7)
  'id' => string '1' (length=1)
  'name' => string 'John Smith' (length=10)
  'email' => string '[email protected]' (length=16)
  'country' => string 'US' (length=2)
  'created_at' => string '2023-12-07 04:00:48' (length=19)
  'updated_at' => string '2023-12-07 04:00:48' (length=19)
  'deleted_at' => null
Expected Output

Returns string value '2023-12-12 12:12:12'?

Anything else?

No response

Lenguaje dominante
PHP
Estrellas
6k
Forks
2k
Merge medio
1 d 22 h
PR fusionados (30 d)
59

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de codeigniter4/CodeIgniter4

Todos los issues de codeigniter4/CodeIgniter4

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.