Make WordPress Core

Opened 3 years ago

Closed 8 months ago

#16754 closed enhancement (fixed)

PHP5-port - srand()

Reported by: hakre Owned by: dd32
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.1
Component: Formatting Keywords: has-patch commit
Focuses: Cc:


No need to seed the random number generator.

See srand() for details.

Related: #16753

Attachments (3)

16754.patch (447 bytes) - added by hakre 3 years ago.
Probably this just was forgotten
18999.diff (1.2 KB) - added by crrobi01 3 years ago.
16754.diff (1.3 KB) - added by duck_ 8 months ago.

Download all attachments as: .zip

Change History (17)

hakre3 years ago

Probably this just was forgotten

comment:1 nacin3 years ago

  • Type changed from defect (bug) to enhancement

crrobi013 years ago

comment:2 crrobi013 years ago

  • Version changed from 3.1 to 3.3
  • Removed srand()
  • There's no reason to do floor(rand()) when rand() always returns an integer.
  • Renamed $emailNOSPAMaddy to $email_no_spam_addy to match Coding Standards
  • Replaced "$i = $i + 1" with "$i++" which is more common in WordPress

comment:3 SergeyBiryukov3 years ago

  • Version changed from 3.3 to 3.1

Version field indicates when the enhancement was initially suggested.

comment:4 c3mdigital8 months ago

  • Keywords close added; has-patch removed
  • Resolution set to maybelater
  • Status changed from new to closed

comment:5 SergeyBiryukov8 months ago

  • Component changed from General to Formatting
  • Keywords close removed
  • Milestone Awaiting Review deleted

comment:6 SergeyBiryukov8 months ago

  • Milestone set to 3.7
  • Resolution maybelater deleted
  • Status changed from closed to reopened

Actually, removing srand() and floor() seems valid here. It's removing obsolete and redundant code, not just a readability enhancement.

comment:7 SergeyBiryukov8 months ago

  • Keywords has-patch added

comment:8 dd328 months ago

  • Keywords commit added

Agreed, Lets just clean this entire function up.

comment:9 dd328 months ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from reopened to closed

In 25055:

Remove some PHP4-ness from the antispambot() function, and update it to match some modern coding standards. Props hakre and crrobi01 for initial patches. Fixes #16754

comment:10 buffler8 months ago

It's not going to affect the functionality but it does look like there's a typo in the docblock - line 1487 reads @param int $extra_entrpoy rather than @param int $extra_entropy

comment:11 dd328 months ago

In 25058:

Correct a typo in a docblock in [25055]. Props buffler. See #16754

duck_8 months ago

comment:12 duck_8 months ago

I'd argue that $extra_entropy is a misleading name for the variable. 16754.diff switches to $hex_encoding and uses array style character access instead of substr().

comment:13 dd328 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I agree that it's not exactly a great name, and am fine with it being changed (anything was better than $mailto)

At first, $hex_encoding doesn't feel right, because it just randomly hex's characters, it doesn't turn it on for the entire link, but at the same time, it does what it says on the box, enables some hex encoding.

comment:14 dd328 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 25146:

Use a better variable name in antispambot() introduced with [25055]. Props duck_ Fixes #16754

Note: See TracTickets for help on using tickets.