Skip to:
Content

BuddyPress.org

Opened 3 months ago

Last modified 3 weeks ago

#9175 new defect (bug)

Unable to send "0" in messages through REST API

Reported by: niftythree's profile niftythree Owned by: espellcaste's profile espellcaste
Milestone: 15.0.0 Priority: highest
Severity: normal Version:
Component: REST API Keywords: has-patch has-unit-tests
Cc: emaralive

Description

Hello,

We've found that the REST API cannot send 0 (i.e. the digit for zero) as the only content for a message. This applies to messages in both new and existing threads (see first screenshot). However, it will accept other variations. E.g. 00; 01; 10; etc. as the only content of a message, and it doesn't appear to be an issue for any other numbers/digits (see second screenshot).

We've tested all of the above with the following set-up:
WordPress version: 6.5.3
BuddyPress version: 12.5.0
BuddyPress Template: Legacy
Theme: Twenty Twenty-Four
Plugins active: BuddyPress, JSON Basic Authentication (https://github.com/WP-API/Basic-Auth)
PHP: 7.4

Thanks.

Attachments (2)

0.png (102.3 KB) - added by niftythree 3 months ago.
00.png (98.2 KB) - added by niftythree 3 months ago.

Download all attachments as: .zip

Change History (10)

@niftythree
3 months ago

@niftythree
3 months ago

#1 @espellcaste
3 months ago

  • Milestone changed from Awaiting Review to Up Next

That's a good catch, actually.

In PHP, empty("0") returns true while empty("00") does not. I can update this to better check what's truly empty.

#2 @niftythree
3 months ago

Thanks @espellcaste; we appreciate it being updated and the context you've provided.

#3 @imath
2 months ago

  • Milestone changed from Up Next to 15.0.0

This ticket was mentioned in PR #330 on buddypress/buddypress by renatonascalves.


2 months ago
#4

  • Keywords has-patch has-unit-tests added

#5 @emaralive
6 weeks ago

  • Cc emaralive added

@espellcaste are the unit tests sufficient to move this ticket & associated PR along or do we also need to manually test the change in PR 330 in conjunction with PR 511?

#6 @espellcaste
6 weeks ago

In 13986:

Allow creating messages with non-empty content.

Use of the PHP empty function to check if the message content is empty is not ideal when creating a message. Update the logic to consider any string as non-empty.

Props emaralive, niftythree.

See #9175
Closes https://github.com/buddypress/buddypress/pull/330

#7 @espellcaste
6 weeks ago

@emaralive The code from the REST API will be bundled with #9145, since we will add a V2. I'll keep this ticket open until we introduce it. :)

#8 @espellcaste
3 weeks ago

  • Priority changed from normal to highest
Note: See TracTickets for help on using tickets.