Skip to content

Bugfix/main/minor fixes #9033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jonasraoni
Copy link
Contributor

No description provided.

@jonasraoni jonasraoni force-pushed the bugfix/main/minor-fixes branch from 60de5b2 to 58f7582 Compare May 31, 2023 07:39
@asmecher
Copy link
Member

asmecher commented Jun 2, 2023

@jonasraoni, I've started going through this but I'm still finding it hard to review as it mixes small-but-important changes in with uncontroversial changes (e.g. spelling corrections). I'd suggest two next steps:

  • For the very uncontroversial changes, please just go ahead and cherry-pick them into main. I've gone ahead and done this already with a few of them. But please just keep it the trivial ones.
  • For issues that may cause problems if left unresolved in 3.4.0 (e.g. 96b8b8e), please merge them directly if they are trivial and did not exist in 3.3.0, and break them out separately into their own issues if they introduce any risk or were present in 3.3.0 already.
  • Leave the rest in the open PRs and we can consider them post-3.4.0.

@jonasraoni
Copy link
Contributor Author

@asmecher I still didn't review these PRs, I've just shared to let you take a first-look 😁
I'll take a look after I clear the migration issue.

@jonasraoni
Copy link
Contributor Author

After the latest type hints, I think the code must be almost ready to run with the [general].strict = On, at least on the build. But I remember some parts still need to be fixed (e.g. non-namespaced class names inside strings).

@asmecher
Copy link
Member

asmecher commented Jun 2, 2023

I'd like to set aside a bit of time after 3.4.0 is released to work through some of the strict mode warnings/errors, but I'm pretty sure strict mode is going to be broken until after the next LTS release (looking like 3.5.0 at this point), when we can formally remove some of the backwards compatibility stuff that was introduced with this cycle.

@jonasraoni jonasraoni force-pushed the bugfix/main/minor-fixes branch 3 times, most recently from 65a99d2 to 7f21cf1 Compare June 4, 2023 15:20
@@ -330,7 +330,7 @@ public function convertFromDB($value, $type, $nullable = false)
return (float) $value;
case 'object':
case 'array':
$decodedValue = json_decode($value, true);
$decodedValue = json_decode($value ?? ($type === 'array' ? '[]' : '{}'), true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAICR I got this from a warning in a user log.

A not null field is attempting to convert a null value. I thought it's better to return an empty array/object than false.

@jonasraoni
Copy link
Contributor Author

@asmecher Done! I've created some new issues. From this PR the only item that might be worth to review is the one below, the rest + things that I didn't push, I'll leave for post-3.4:
https://github.com/pkp/pkp-lib/pull/9033/files#diff-baca326285c1780182c7a44aae2ef03a56e8dc332efbf90fe66acfa8bc11b636R333

As a reminder, the other issues that I've met before must be unsolved yet, see: #8845 (as I wrote in the description, the PRs on the issue are not covering anything that I wrote in the issue description).

@jonasraoni jonasraoni force-pushed the bugfix/main/minor-fixes branch 2 times, most recently from 9d20241 to d788e76 Compare June 6, 2023 08:27
// FIXME: pkp/pkp-lib#6250 Remove after 3.3.x upgrade code is removed (see also pkp/pkp-lib#5772)
if (!is_null($decodedValue)) {
return $decodedValue;
return $type === 'array' ? array_values((array) $decodedValue) : (object) $decodedValue;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For here and below, the database might be holding a valid JSON, with an unexpected value.
For example, if we encode the array [1 => 0] using the $type array, it will be stored as a JSON object.

There are already some known cases out in the wild.

@jonasraoni jonasraoni force-pushed the bugfix/main/minor-fixes branch from d788e76 to 2c01bea Compare June 6, 2023 10:55
@@ -80,6 +80,8 @@ class DAO extends EntityDAO

/**
* Construct a new User object.
*
* @return User
Copy link
Member

Choose a reason for hiding this comment

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

Since I think this PR is most suitable for main, I'd rather we just started adding first-class type hints.

Copy link
Member

@asmecher asmecher left a comment

Choose a reason for hiding this comment

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

Just a small tweak, and if you're satisfied that this is ready to go, you can merge to main. I don't think this needs to be brought into stable-3_4_0.

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.

4 participants