|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54138 DOMNode::getLineNo() doesn't return line number higher than 65535
Submitted: 2011-03-02 15:23 UTC Modified: 2015-06-08 11:07 UTC
From: dmitrij at stepanov dot lv Assigned: cmb (profile)
Status: Closed Package: XML Reader
PHP Version: 5.6.9 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: dmitrij at stepanov dot lv
New email:
PHP Version: OS:


 [2011-03-02 15:23 UTC] dmitrij at stepanov dot lv
DOMNode::getLineNo() doesn't return line number higher than 65535.

I assume that unsigned short is used for file line enumeration either in XMLReader 
or DOMNode internals.

Test script:
Try reading with XMLReader an XML file that has more than 65535 lines.

Then, when line nr. > 65535 is reached, call XMLReader::expand()->getLineNo().

Expected result:
Correct line number.

Actual result:
65535 for lines, higher than 65525.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-02 16:17 UTC]
-Status: Open +Status: Bogus
 [2011-03-02 16:17 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Known limitation of libxml2
 [2012-06-19 12:42 UTC] hanskrentel at yahoo dot de
The function DOMNode::getLineNo() is not able to return a line number higher 
than 65535.

Test Script:

$xml = "<?xml version=\"1.0\"?><root>".str_repeat("\n", 65537)
echo dom_import_simplexml(

Expected result: 65537

Actual result: 65535

Summary: Reported back in 2007, upstream does not know how to fix this w/o 
breaking stuff (binary compatibility). 
It's also worth to mention that normally files with more than 65k lines aren't 
written by hand so don't require that 
type of functionality. Naturally this is subjective.

To fix this this requires a different upstream/patch of one of the underlying 
libraries, e.g. libxml2. The debian 
ticket has a patch.
 [2013-10-25 21:09 UTC] ruud at vanmelick dot com
This is solved in libxml2 version 2.9+.
However, you have to explicitly tell libxml to support it, which you can do in PHP by using using the options parameter in functions like DOMDocument::load (option 2^22 = 4194304 = XML_PARSE_BIG_LINES). Currently there's no PHP libxml constant for that purpose.
 [2015-06-03 12:56 UTC]
-Status: Not a bug +Status: Re-Opened -Assigned To: +Assigned To: cmb
 [2015-06-03 12:56 UTC]
Re-opened according to Ruud's comment. Not sure, whether that should be categorized as feature request, though.
 [2015-06-03 23:15 UTC]
-Operating System: Windows 7 +Operating System: * -PHP Version: 5.3.5 +PHP Version: 5.6.9
 [2015-06-03 23:15 UTC]
Thanks for the hint, Ruud. Indeed, as of libxml2 2.9.0 there is
the constant XML_PARSE_BIG_LINES available:

I'll make a PR to add a respective constant to PHP, so users don't
have to rely on a hard to remember and potentially changing
numeric value.
 [2015-06-03 23:16 UTC]
-Assigned To: cmb +Assigned To:
 [2015-06-08 11:07 UTC]
-Status: Re-Opened +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-06-08 11:07 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 23:01:31 2024 UTC