The task is to change the function to:

<?php
function file_stream_wrapper_valid_scheme($scheme) {
  return
$scheme && class_exists(file_stream_wrapper_get_class($scheme));
}
?>

and then take these:

<?php
346
:  if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
596:  if (empty($uri_scheme) || !file_stream_wrapper_valid_scheme($uri_scheme)) {
1171:  if (!$destination_scheme || !file_stream_wrapper_valid_scheme($destination_scheme)) {
1598:  if ((!$scheme || !file_stream_wrapper_valid_scheme($scheme)) && (substr(PHP_OS, 0, 3) == 'WIN')) {
1671:  if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
1764:  if ((!$scheme || !file_stream_wrapper_valid_scheme($scheme)) && (substr(PHP_OS, 0, 3) == 'WIN')) {
1800:  if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
?>

and remove the superflous testing for $scheme, ie make the first if (file_stream_wrapper_valid_scheme($scheme)) {, the second if (!file_stream_wrapper_valid_scheme($uri_scheme)) {

Note that #1874562: Upgrade path broken and yet tests pass adds one more so if it is committed, then that needs to be done too.

Files: 
CommentFileSizeAuthor
#4 rewrite_checking_schema-1874612-4.patch4.12 KBplopesc
PASSED: [[SimpleTest]]: [MySQL] 49,696 pass(es).
[ View ]
#1 rewrite_checking_schema-1874612-1.patch4.12 KBplopesc
FAILED: [[SimpleTest]]: [MySQL] 49,877 pass(es), 109 fail(s), and 428 exception(s).
[ View ]

Comments

plopesc’s picture

StatusFileSize
new4.12 KB
FAILED: [[SimpleTest]]: [MySQL] 49,877 pass(es), 109 fail(s), and 428 exception(s).
[ View ]

Hello

Attaching patch that rewrites the checking process through the suggested function.

The function is also called from system module. The suferfluous testing has been removed too.

Regards

plopesc’s picture

Status:Active» Needs review

Changing status.

Status:Needs review» Needs work

The last submitted patch, rewrite_checking_schema-1874612-1.patch, failed testing.

plopesc’s picture

Status:Needs work» Needs review
StatusFileSize
new4.12 KB
PASSED: [[SimpleTest]]: [MySQL] 49,696 pass(es).
[ View ]

Re-rolling patch. Testing problems should be fixed now.

chx’s picture

Status:Needs review» Reviewed & tested by the community

The reason for test failures were: file_valid_uri and drupal_rmdir had file_stream_wrapper_valid_scheme instead of !file_stream_wrapper_valid_scheme. The patch at this point contains no functional change just simplifies code.

catch’s picture

Title:Simplify file.inc by file_stream_wrapper_valid_scheme(FALSE) return FALSE» Change notice: Simplify file.inc by file_stream_wrapper_valid_scheme(FALSE) return FALSE
Priority:Normal» Critical
Status:Reviewed & tested by the community» Active

Very nice. Could use a small change notice so contrib can remove similar checks.

chx’s picture

Title:Change notice: Simplify file.inc by file_stream_wrapper_valid_scheme(FALSE) return FALSE» Simplify file.inc by file_stream_wrapper_valid_scheme(FALSE) return FALSE
Priority:Critical» Normal
Status:Active» Fixed

Automatically closed -- issue fixed for 2 weeks with no activity.