Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Look at file_get_contents in sitemap class #1428
See if this can be improved in some way.
Some terrible hosts can potentially have a problem with seeking https://wordpress.org/support/topic/errors-creating-sitemap/#post-9808145
User reports error only comes on PHP 7.10, and not on either earlier or later versions of PHP
According to the changelog for PHP: "7.1.0 | Support for negative offsets has been added."
Our longtime use of the offsets parameter should be investigated, and why it's ONLY on exactly PHP 7.10.
I've been able to reproduce the issue, and investigated it a bit, and it seems the main issue is the difference between remote and local. Both files are local, but the compression prefix is causing PHP to recognize the string file path to be a remote file. The .xml file however works fine.
The issue also seems to be the cause of another issue, and happens that the warning function used also throws a PHP Warning since 7.1.0+.
This issue also affects other versions from 7.1.0 to 7.2.0 (current), and can be reproduced fairly easy. To reproduce...
I was thinking of handling the compress file separately with PHP's gzfile() for this section of code, but the initial problem seems to be handled differently using WP's filesystem object; which may need to be investigated further.
Additional environmental conditions that may contribute to bug...
7.1.0+ PHP Development
It may already be assumed that this was an intended change with PHP, and when investigating the matter, it may lead someone to believe that this is a PHP bug; there are some mentions of 7.1+ issues related to the new forced rule. So this may or may not be a PHP bug.
The reason for the change was due to an exploit that could allow hackers to get into a server through a remote file being used. However, AIOSEOP files are locally stored, but the issue is with the compress streams in file_get_contents(). Which makes it appear as a bug, or a feature/concept that hasn't been added to Compression Streams yet; possibly being fixed/added in the future
Compress files are handled separately to prevent conflicts, and the offset for files_get_content() was changed from -1 to 0 to fix what lead the sitemap not being recognized, and possibly deleted.
A note/todo was added which identifies a possible flaw; may be partially intended.