Skip to content

Fix delete language and script notes field (#2392) - #2396

Open
melaniekung wants to merge 1 commit into
qa/2.xfrom
dev/2392-fix-delete-lang-notes
Open

Fix delete language and script notes field (#2392)#2396
melaniekung wants to merge 1 commit into
qa/2.xfrom
dev/2392-fix-delete-lang-notes

Conversation

@melaniekung

Copy link
Copy Markdown
Contributor

No description provided.

@melaniekung melaniekung added this to the 2.11 milestone Jul 22, 2026
@melaniekung
melaniekung requested a review from a team July 22, 2026 20:06
@melaniekung melaniekung self-assigned this Jul 22, 2026
@melaniekung melaniekung added the Type: bug A flaw in the code that causes the software to produce an incorrect or unexpected result. label Jul 22, 2026
Comment on lines +83 to +85
if (0 == strlen($value)) {
if (0 == strlen($value) || (!$missingNote && is_countable($note))) {
// Delete note if it's available
if (!$missingNote && is_countable($note)) {
$note->delete();
}
$note->delete();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing this block from a new test file (test/phpunit/sfIsadPlugin/sfIsadPluginTest.php - feel free to use it!) and the last case listed in the table fails with this change, i.e. when the submitted value is empty and no note exists, $note contains the empty ArrayObject, so the call to the delete method produces:

Call to undefined method ArrayObject::delete()

Here's an alternative that passes in all four test cases. $note is consistently either a QubitNote or null, which I find a little easier to read:

case 'languageNotes':
    $notes = $this->resource->getMemoryNotesByType(['noteTypeId' => QubitTerm::LANGUAGE_NOTE_ID]);
    $note = $notes[0] ?? null;

    // Clear the stored note when the field is empty; otherwise create the
    // note if necessary and update its content.
    if (0 === strlen($value)) {
        if (null !== $note) {
            $note->delete();
        }

        break;
    }

    if (null === $note) {
        $note = new QubitNote();
        $note->typeId = QubitTerm::LANGUAGE_NOTE_ID;
        $note->userId = sfContext::getInstance()
            ->user
            ->getAttribute('user_id');

        $this->resource->notes[] = $note;
    }

    $note->content = $value;

    return $this;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @sevein!

@melaniekung
melaniekung force-pushed the dev/2392-fix-delete-lang-notes branch from bdbabdb to 0d18b77 Compare July 23, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: bug A flaw in the code that causes the software to produce an incorrect or unexpected result.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem: Emptying the textbox for Language and script notes does not save.

2 participants