Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

クローズ
#19,948 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@riasvdv がすでに取り組んでいます。

2026年10月13日 から。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php
領域
backend, database

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
PHP
スター
3.6k
フォーク
706
平均マージ
12時間 30分
マージ済み PR(30日)
274

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

craftcms/cms のほかの issue

craftcms/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。