Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#52996 closed defect (bug) (fixed)

Coding standard : Undefined varible $results

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

Description

Variable "$results" is undefined.

Attachments (1)

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

Download all attachments as: .zip

Change History (7)

#1 @jrf
6 years ago

  • Milestone Awaiting Review → 5.8
  • Priority normal → low
  • Severity normal → trivial
  • Version → 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
6 years ago

  • Component General → Import
  • Version trunk → 3.0

Introduced in [14760] from #13034.

#4 @mukesh27
6 years ago

​PR1181 removes all resets.

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

#5 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → 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
6 years ago

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

Note: See TracTickets for help on using tickets.