Make WordPress Core

Opened 15 years ago

Closed 10 years ago

Last modified 10 years ago

#14207 closed defect (bug) (worksforme)

streams.php, POMO_FileReader $length parameter of fread

Reported by: bueltge's profile bueltge Owned by: nbachiyski's profile nbachiyski
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: I18N Keywords: has-patch reporter-feedback
Focuses: Cc:

Description (last modified by SergeyBiryukov)

the fread function run with an error, when you have the length-paramter ist 0. This is possible on use WP in local engines and intranet.
Small changes on the function: read in class POMO_FileReader

	function read($bytes) {
		if ( isset($bytes) && ( 0 > $bytes ) )
			return fread($this->_f, $bytes);
		else
			return;
	}

Attachments (4)

streams.patch (637 bytes) - added by bueltge 15 years ago.
streams.php (4.7 KB) - added by bueltge 15 years ago.
14207.patch (416 bytes) - added by SergeyBiryukov 14 years ago.
14207.2.patch (891 bytes) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (18)

#1 @nacin
15 years ago

  • Component changed from Administration to i18n
  • Severity changed from critical to major

Without speaking at all to the validity of the patch, checking for empty() would be much simpler.

Lowering priority a bit as fread() with zero length fires only a warning, not a fatal, and I'm still not sure of the steps to reproduce an instance where 0 is requested.

#2 @bueltge
15 years ago

the warning is an problem when you work with WP_DEBUG true; its not possible to use the backend. Yes, you can change this to empty().

@bueltge
15 years ago

@bueltge
15 years ago

#3 @nacin
14 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Owner set to nbachiyski
  • Status changed from new to assigned

#4 @SergeyBiryukov
14 years ago

  • Keywords reporter-feedback added

What are the steps to reproduce this?

#5 @Bueltge
14 years ago

"the fread function run with an error, when you have the length-paramter ist 0. This is possible on use WP in local engines and intranet"
when the blog in a landscape without internet-connection

#6 @SergeyBiryukov
14 years ago

Still don't quite understand the connection between intranet and reading .mo files.

However I guess the condition in the patch should be inverted:

if ( !empty($bytes) )
	return fread($this->_f, $bytes);
else
	return false;

Uploaded new patch.

#7 @bueltge
14 years ago

I have check this on my development-version and now works fine, no errors for fread. Thanks

	function read($bytes) {
		if ( !empty($bytes) )
			return fread($this->_f, $bytes);
		else
			return false;
	}

#9 @SergeyBiryukov
14 years ago

  • Keywords reporter-feedback removed

#10 @nacin
13 years ago

Perhaps the read() method should be avoided if ! $bytes?

#11 @SergeyBiryukov
13 years ago

  • Keywords reporter-feedback added

read() method is only called for an arbitrary number of bytes in lines 160 and 169 of mo.php:
http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/pomo/mo.php#L160

14207.2.patch makes sure the values passed to read() are not zero.

I'm still not sure what are we trying to fix here though. I've checked a localized install without Internet access with WP_DEBUG on and didn't see any warnings.

#12 @chriscct7
10 years ago

  • Keywords dev-feedback added; reporter-feedback removed
  • Resolution set to worksforme
  • Status changed from assigned to closed

Seems this is an impossible scenario to generate. Closing as worksforme.

#13 @SergeyBiryukov
10 years ago

  • Description modified (diff)
  • Keywords reporter-feedback added; dev-feedback removed
  • Milestone Future Release deleted

#14 @SergeyBiryukov
10 years ago

  • Severity changed from major to normal
Note: See TracTickets for help on using tickets.