WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#52996 closed defect (bug) (fixed)

Coding standard : Undefined varible $results

Reported by: ravipatel Owned by: SergeyBiryukov
Milestone: 5.8 Priority: low
Severity: trivial Version: 3.0
Component: Import Keywords: has-patch
Focuses: coding-standards Cc:

Description

Variable "$results" is undefined.

Attachments (1)

52996-class-wp-importer.php.patch (372 bytes) - added by ravipatel 7 months ago.
undefine variable $results

Download all attachments as: .zip

Change History (7)

@ravipatel
7 months ago

undefine variable $results

#1 @jrf
7 months ago

  • Milestone changed from Awaiting Review to 5.8
  • Priority changed from normal to low
  • Severity changed from normal to trivial
  • Version set to trunk

@ravipatel The report is valid and the patch good. Thanks for that.

Having said that, I think we may need to rethink the practice happening here.

The first few functions in this file, all end with something along the lines of:

<?php
// Unset to save memory.
unset( $results, $r );

return $hashtable;

With how PHP memory management and garbage collection works, this, to me, is ludicrous.

Variables created within the scope of a function are discarded automatically when PHP leaves the scope of the function, i.e. on return, so doing a call to unset() straight before a return statement is absolutely unnecessary and useless.

These statements can, and should be, removed.

#2 @rachelbaker
7 months ago

  • Component changed from General to Import
  • Version changed from trunk to 3.0

Introduced in [14760] from #13034.

#4 @mukesh27
7 months ago

PR1181 removes all resets.

Please check and let me know in case of any changes. Feel free to update.

#5 @SergeyBiryukov
7 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 50692:

Coding Standards: Remove unnecessary unset() calls in WP_Importer methods.

Variables created within the scope of a function are discarded automatically when PHP leaves the scope of the function, i.e. on return, so doing a call to unset() straight before a return statement is redundant.

Props jrf, ravipatel, rachelbaker, mukesh27.
Fixes #52996.

#6 @jrf
7 months ago

Thanks @mukesh27 and @SergeyBiryukov for getting that fixed up!

Note: See TracTickets for help on using tickets.