22-Feb-2017

More on PHP 5.3 and beyond
I remembered I defined PHP_ERROR.LOG in PHP.ini, and took a look into that file. There I found what I ran into some time ago:

[31-May-2015 12:13:48 UTC] PHP Parse error: syntax error, unexpected end of file in /sysblog/000000/wp-includes/post-template.php on line 734

This was because the file (in fact, many files) missed the PHP end tag “?>”. I recall I contacted Mark Berryman on this but it never came to an conclusion.
With 5.4, the problem is a bit different:

[19-Feb-2017 19:53:09 UTC] PHP Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE) in /sysblog/000000/wp-load.php on line 94

So I looked into this file; The weird thing is that in the editor, the file is only 93 lines long, ending in
...
        wp_die( $die, __( 'WordPress › Error' ) );
}
[End of file]
 Buffer: WP-LOAD.PHP                                                                                                  | Write | Insert | Forward
Command: line 94
You are already at the bottom of the buffer.

and the result is

Buffer has only 93 lines.  (Now going to End of Buffer).

So, there is no line 94????

Dumped the file – and behold: after the last LF, there is another character:


Dump of file WP472:[000000]wp-load.php;1 on 22-FEB-2017 21:25:30.44
File ID (14870,4,0) End of file block 7 / Allocated 8

Virtual block number 7 (00000007), 512 (0200) bytes

666E6F63 2D70773E 65646F63 3C270909 0A2C2920 222E656C 69662065 68742065 e the file." ),...'<code>wp-conf 000000
69642409 0A3B273E 702F3C27 202E2029 090A273E 65646F63 2F3C7068 702E6769 ig.ph</code>'..) . '</p>';..$di 000020
2227202E 20687461 7024202E 2027223D 66657268 20613C3E 703C2720 3D2E2065 e .= '<p><a href="' . $path . '" 000040
2E20273E 22656772 616C2D6E 6F747475 62206E6F 74747562 223D7373 616C6320 class="button button-large">' . 000060
6C694620 6E6F6974 61727567 69666E6F 43206120 65746165 72432220 285F5F20 __( "Create a Configuration Fil 000080
5F202C65 69642420 28656964 5F707709 0A0A3B27 3E612F3C 27202E20 29202265 e" ) . '</a>';...wp_die( $die, _ 0000A0
20292027 726F7272 45203B6F 75716173 72262073 73657250 64726F57 2720285F _( 'WordPress › Error' ) 0000C0
00000000 00000000 00000000 00000000 00000000 00000000 0000270A 7D0A3B29 );.}.'.......................... 0000E0
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 000100
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 000120
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 000140
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 000160
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 000180
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 0001A0
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 0001C0
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ................................ 0001E0

Removed that byte – and that solved this problem, for this file.
There were numerous other ones that need a similar edit, because each of these files appear to be one byte too long.
Looked into the directory listing of the file, before edit:

$ dir/full wp472:[000000]wp-load.php;1

Directory WP472:[000000]

wp-load.php;1                 File ID:  (14870,4,0)
Size:            7/8          Owner:    [SYSTEM]
Created:    25-OCT-2016 03:15:30.00
Revised:    25-OCT-2016 03:15:30.00 (0)
Expires:    
Backup:     
Effective:  
Recording:  

Accessed:    4-FEB-2017 21:35:34.00
Attributes: 25-OCT-2016 03:15:30.00
Modified:   25-OCT-2016 03:15:30.00
Linkcount:  1
File organization:  Sequential
Shelved state:      Online
Caching attribute:  Writethrough
File attributes:    Allocation: 8, Extend: 0, Global buffer count: 0, No version limit
Record format:      Stream_LF, maximum 0 bytes, longest 0 bytes
Record attributes:  Carriage return carriage control
RMS attributes:     None
Journaling enabled: None
File protection:    System:RWED, Owner:RWD, Group:R, World:R
Access Cntrl List:  None
Client attributes:  None

Total of 1 file, 7/8 blocks.

and after edit:
$ dir/full wp472:[000000]wp-load.php;2

Directory WP472:[000000]

wp-load.php;2                 File ID:  (16777,7,0)
Size:            7/8          Owner:    [SYSTEM]
Created:    22-FEB-2017 16:05:59.27
Revised:    22-FEB-2017 16:05:59.30 (1)
Expires:    
Backup:     
Effective:  
Recording:  

Accessed:   

Attributes: 22-FEB-2017 16:05:59.30
Modified:   22-FEB-2017 16:05:59.27
Linkcount:  1
File organization:  Sequential
Shelved state:      Online
Caching attribute:  Writethrough
File attributes:    Allocation: 8, Extend: 0, Global buffer count: 0, No version limit
Record format:      Stream_LF, maximum 0 bytes, longest 
153
 bytes
Record attributes:  Carriage return carriage control
RMS attributes:     None
Journaling enabled: None
File protection:    System:RWED, Owner:RWD, Group:R, World:R
Access Cntrl List:  None
Client attributes:  None

Total of 1 file, 7/8 blocks.
$

So edit adds the size…There is more to check…

As stated, quite a lot of files need to be edited before the blog shows in PHP 5.4, but eventually is succeeds. Admin works as well but the page doesn’t show right – there may be things missing (not executed directly but referenced and linked so if that fails, there is no error.
It seems that all files are one byte longer than is actually the case. Not sure yet where it comes from, The fun part (luckily) is that 5.2 is fine, even with the edited files. But PHP 5.3 and later consider the file one byte longer. Now it.s a matter to find out what causes this extra byte: is it Unzip.exe, or is it added when the kit is created?

Anyway, if this is the case with all files (it looks as it is) it might be that a procedure to remove the last byte could do the trick.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.