Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[6.x]: yii2-adapter: yii\db\Expression assigned to an ActiveRecord attribute becomes a JSON string

Chiusa
#19,948 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@riasvdv ci sta già lavorando.

Dal 13/10/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend, database

Direzione di ricerca

Start by tracing how yii\db\Expression is handled when assigned to an ActiveRecord attribute and passed through update(), comparing the Craft 5 and Craft 6 behavior described here. Reproduce with the shown assignment and MySQL 8.4.5; done means the column receives the expression result (today + 1) rather than its JSON representation. The issue names no source file or test, so locating the relevant code and a regression test will take project familiarity.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug repo:cms
What happened?
Description

I’m testing a plugin for Craft 6 via yii2-adapter. I found a behavior change with yii\db\Expression.

This code works in the previous Craft version:

$record->today = new \yii\db\Expression('today + 1');
$record->update();

in craft 5, var_dump($record->today) shows an Expression object:

object(yii\db\Expression)#572 (2) { ["expression"]=> string(9) "today + 1" ... }

In Craft 6, the same dump shows a JSON string:

string(38) "{"expression":"today + 1","params":[]}"

update() returns 1. But the column gets that JSON text, not today + 1. So the counter never increases.

I’m not sure this is related to Craft 6. It may be caused by something else in my setup or plugin.
Thanks!

Craft CMS version

6.0.0-alpha.20

PHP version

No response

Operating system and version

No response

Database type and version

MySQL 8.4.5

Image driver and version

No response

Installed plugins and versions
  • vnali/craft-counter
Lingua principale
PHP
Stelle
3.6k
Fork
706
Merge medio
12h 54m
PR unite (30g)
274

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di craftcms/cms

Tutte le issue di craftcms/cms

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.