mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
General: Fix various issues flagged by the PHPCompatibilityWP PHPCS ruleset.
As part of the continued effort to improve PHP compatibility, the following improvments are being made: - Removing deprecated PHP `safe_mode` checks not found in bundled external libraries. - Change the remaining `while` loops using `each()` to `foreach` loops. - Prevent false positives from being flagged for the `sodium_compat` library being caused by loading this in a non-standard way. - Add inline comments to not flag deprecated PHP directives in the getID3 library. Props desrosj, earnjam, dryanpress. See #49922. Built from https://develop.svn.wordpress.org/trunk@47735 git-svn-id: http://core.svn.wordpress.org/trunk@47511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
10945d2f3d
commit
89ddd19884
@ -369,13 +369,6 @@ function populate_options( array $options = array() ) {
|
||||
*/
|
||||
do_action( 'populate_options' );
|
||||
|
||||
if ( ini_get( 'safe_mode' ) ) {
|
||||
// Safe mode can break mkdir() so use a flat structure by default.
|
||||
$uploads_use_yearmonth_folders = 0;
|
||||
} else {
|
||||
$uploads_use_yearmonth_folders = 1;
|
||||
}
|
||||
|
||||
// If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.
|
||||
$stylesheet = WP_DEFAULT_THEME;
|
||||
$template = WP_DEFAULT_THEME;
|
||||
@ -466,7 +459,7 @@ function populate_options( array $options = array() ) {
|
||||
'db_version' => $wp_db_version,
|
||||
|
||||
// 2.0.1
|
||||
'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
|
||||
'uploads_use_yearmonth_folders' => 1,
|
||||
'upload_path' => '',
|
||||
|
||||
// 2.1
|
||||
|
@ -285,7 +285,7 @@ class getID3
|
||||
}
|
||||
|
||||
// Check safe_mode off
|
||||
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
|
||||
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { // phpcs:ignore // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated
|
||||
$this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
|
||||
}
|
||||
|
||||
@ -300,13 +300,13 @@ class getID3
|
||||
if (version_compare(PHP_VERSION, '7.4.0', '<')) {
|
||||
// Check for magic_quotes_runtime
|
||||
if (function_exists('get_magic_quotes_runtime')) {
|
||||
if (get_magic_quotes_runtime()) {
|
||||
if (get_magic_quotes_runtime()) { // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated
|
||||
$this->startup_error .= 'magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).'."\n";
|
||||
}
|
||||
}
|
||||
// Check for magic_quotes_gpc
|
||||
if (function_exists('get_magic_quotes_gpc')) {
|
||||
if (get_magic_quotes_gpc()) {
|
||||
if (get_magic_quotes_gpc()) { // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated
|
||||
$this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n";
|
||||
}
|
||||
}
|
||||
@ -1560,7 +1560,7 @@ class getID3
|
||||
// page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
|
||||
// currently vorbiscomment only works on OggVorbis files.
|
||||
|
||||
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
|
||||
if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { // phpcs:ignore // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated
|
||||
|
||||
$this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
|
||||
$this->info[$algorithm.'_data'] = false;
|
||||
|
@ -183,7 +183,7 @@ class Snoopy
|
||||
$frameurls = $this->_frameurls;
|
||||
$this->_frameurls = array();
|
||||
|
||||
while(list(,$frameurl) = each($frameurls))
|
||||
foreach ( $frameurls as $frameurl )
|
||||
{
|
||||
if($this->_framedepth < $this->maxframes)
|
||||
{
|
||||
@ -243,7 +243,7 @@ class Snoopy
|
||||
$frameurls = $this->_frameurls;
|
||||
$this->_frameurls = array();
|
||||
|
||||
while(list(,$frameurl) = each($frameurls))
|
||||
foreach ( $frameurls as $frameurl )
|
||||
{
|
||||
if($this->_framedepth < $this->maxframes)
|
||||
{
|
||||
@ -341,7 +341,7 @@ class Snoopy
|
||||
$frameurls = $this->_frameurls;
|
||||
$this->_frameurls = array();
|
||||
|
||||
while(list(,$frameurl) = each($frameurls))
|
||||
foreach ( $frameurls as $frameurl )
|
||||
{
|
||||
if($this->_framedepth < $this->maxframes)
|
||||
{
|
||||
@ -408,7 +408,7 @@ class Snoopy
|
||||
$frameurls = $this->_frameurls;
|
||||
$this->_frameurls = array();
|
||||
|
||||
while(list(,$frameurl) = each($frameurls))
|
||||
foreach ( $frameurls as $frameurl )
|
||||
{
|
||||
if($this->_framedepth < $this->maxframes)
|
||||
{
|
||||
@ -629,13 +629,13 @@ class Snoopy
|
||||
|
||||
// catenate the non-empty matches from the conditional subpattern
|
||||
|
||||
while(list($key,$val) = each($links[2]))
|
||||
foreach ( $links[2] as $key => $val )
|
||||
{
|
||||
if(!empty($val))
|
||||
$match[] = $val;
|
||||
}
|
||||
|
||||
while(list($key,$val) = each($links[3]))
|
||||
foreach ( $links[3] as $key => $val )
|
||||
{
|
||||
if(!empty($val))
|
||||
$match[] = $val;
|
||||
@ -821,7 +821,7 @@ class Snoopy
|
||||
{
|
||||
if(!is_array($this->rawheaders))
|
||||
$this->rawheaders = (array)$this->rawheaders;
|
||||
while(list($headerKey,$headerVal) = each($this->rawheaders))
|
||||
foreach ( $this->rawheaders as $headerKey => $headerVal )
|
||||
$headers .= $headerKey.": ".$headerVal."\r\n";
|
||||
}
|
||||
if(!empty($content_type)) {
|
||||
@ -985,7 +985,7 @@ class Snoopy
|
||||
{
|
||||
if(!is_array($this->rawheaders))
|
||||
$this->rawheaders = (array)$this->rawheaders;
|
||||
while(list($headerKey,$headerVal) = each($this->rawheaders))
|
||||
foreach ( $this->rawheaders as $headerKey => $headerVal )
|
||||
$headers[] = $headerKey.": ".$headerVal;
|
||||
}
|
||||
if(!empty($content_type)) {
|
||||
@ -1204,9 +1204,9 @@ class Snoopy
|
||||
switch ($this->_submit_type) {
|
||||
case "application/x-www-form-urlencoded":
|
||||
reset($formvars);
|
||||
while(list($key,$val) = each($formvars)) {
|
||||
foreach ( $formvars as $key => $val ) {
|
||||
if (is_array($val) || is_object($val)) {
|
||||
while (list($cur_key, $cur_val) = each($val)) {
|
||||
foreach ( $val as $cur_key => $cur_val ) {
|
||||
$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
|
||||
}
|
||||
} else
|
||||
@ -1218,9 +1218,9 @@ class Snoopy
|
||||
$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
|
||||
|
||||
reset($formvars);
|
||||
while(list($key,$val) = each($formvars)) {
|
||||
foreach ( $formvars as $key => $val ) {
|
||||
if (is_array($val) || is_object($val)) {
|
||||
while (list($cur_key, $cur_val) = each($val)) {
|
||||
foreach ( $val as $cur_key => $cur_val ) {
|
||||
$postdata .= "--".$this->_mime_boundary."\r\n";
|
||||
$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
|
||||
$postdata .= "$cur_val\r\n";
|
||||
@ -1233,9 +1233,9 @@ class Snoopy
|
||||
}
|
||||
|
||||
reset($formfiles);
|
||||
while (list($field_name, $file_names) = each($formfiles)) {
|
||||
foreach ( $formfiles as $field_name => $file_names ) {
|
||||
settype($file_names, "array");
|
||||
while (list(, $file_name) = each($file_names)) {
|
||||
foreach ( $file_names as $file_name ) {
|
||||
if (!is_readable($file_name)) continue;
|
||||
|
||||
$fp = fopen($file_name, "r");
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-47734';
|
||||
$wp_version = '5.5-alpha-47735';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user