Skip to content

Conversation

@terdia
Copy link

@terdia terdia commented Dec 17, 2020

public static function isPathAbsolute($path)
  {
    if ($path{0} === '/' || $path{0} === '\\' ||
        (strlen($path) > 3 && ctype_alpha($path{0}) &&
         $path{1} === ':' &&
         ($path{2} === '\\' || $path{2} === '/')
        )
       )
    {
      return true;
    }

    return false;
  }

Causes deprecation warning:

Deprecated: Array and string offset access syntax with curly braces is deprecated in /var/www/vendor/lexpress/symfony1/lib/util/sfFinder.class.php on line 586

$this->getParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_GET) : $_GET;
Deprecated: Function get_magic_quotes_gpc() is deprecated in /var/www/vendor/lexpress/symfony1/lib/request/sfWebRequest.class.php on line 78

@terdia terdia requested a review from obukhov December 17, 2020 13:01
@terdia terdia changed the title Fix deprecations Fix PHP 7.4 deprecation warnings Dec 17, 2020
Comment on lines +66 to +67
$this->validatorSchema = new sfValidatorSchema();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unclear from the description (why it is needed)

Copy link
Author

@terdia terdia May 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->validatorSchema was used in line 947 before it was initialized, this code $this->validatorSchema[self::$CSRFFieldName] tries to access a key in validatorSchema the usage is triggered by $this->setDefaults($defaults) which calls the function $this->isCSRFProtected() this resulted in an exception trying to access array offset on value of type null

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2021-05-18 at 10 29 56


// GET parameters
$this->getParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_GET) : $_GET;
if (version_compare(PHP_VERSION, '5.4.0-dev', '<') && get_magic_quotes_gpc())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be 7.4.0-dev since the function was deprecated in that version?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, that is for backward compatibility, from version 5.1.4 will be handled in else block.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can you explain it in a little bit more detail? The only function behavior change I see here https://www.php.net/manual/en/function.get-magic-quotes-gpc.php is that this function was declared deprecated in 7.4 (probably started always returning false in the same version).
Can you point me to information about changes in 5.4.0 and 5.1.4?

Does that let's say the PHP version is 5.6 and get_magic_quotes_gpc is enabled. Does that mean that sfToolkit::stripslashesDeep is still needed?

Comment on lines 158 to 165
if (version_compare(PHP_VERSION, '5.4.0-dev', '<') && get_magic_quotes_gpc())
{
$this->postParameters = sfToolkit::stripslashesDeep($postParameters);
}
else
{
$this->postParameters = $postParameters;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't you keep it in PSR codestyle?

        if (version_compare(PHP_VERSION, '5.4.0-dev', '<') && get_magic_quotes_gpc()) {
            $this->postParameters = sfToolkit::stripslashesDeep($postParameters);
        } else {
            $this->postParameters = $postParameters;
        }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, that lead to a lot of unrelated changes, I see symfony1 has its own code style.
Would you mind reverting it?

@obukhov
Copy link
Collaborator

obukhov commented May 18, 2021

Sorry for brining this idea a bit late, but why wouldn't we just pull original version of framework?

They seem to have introduced couple of improvements, including PHP 7.4 compatibilities and security fixes:

image

Our changes are not that big so maybe we can submit them to the upstream?
image

@terdia
Copy link
Author

terdia commented May 18, 2021

Sorry for brining this idea a bit late, but why wouldn't we just pull original version of framework?

They seem to have introduced couple of improvements, including PHP 7.4 compatibilities and security fixes:

image

Our changes are not that big so maybe we can submit them to the upstream?
image

Good idea, we can try it and maybe open a pull request for 3294631

@terdia
Copy link
Author

terdia commented May 28, 2021

closed in favor of: #4

@terdia terdia closed this May 28, 2021
@wutsch0 wutsch0 deleted the fix-deprecations branch May 6, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants