Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Closed
#19,948 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@riasvdv is already working on this.

Since Oct 13, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
backend, database

Research direction

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.

Written by the indexing model from the issue text.

Description

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
Dominant language
PHP
Stars
3.6k
Forks
706
Avg merge
11h 2m
Merged PRs (30d)
252

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from craftcms/cms

All issues in craftcms/cms

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.