Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#19,948 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@riasvdv đang làm issue này rồi.

Từ ngày 13/10/2026.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend, database

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
PHP
Star
3.6k
Fork
706
Merge trung bình
12 giờ 34 phút
Pull request đã merge (30 ngày)
268

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của craftcms/cms

Tất cả issue của craftcms/cms

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.