Skip to content
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

Type safe comparison in plugins - second iteration #13272

Merged
merged 9 commits into from
May 31, 2017
Merged

Type safe comparison in plugins - second iteration #13272

merged 9 commits into from
May 31, 2017

Conversation

frankmayer
Copy link
Contributor

@frankmayer frankmayer commented Dec 18, 2016

Summary of Changes

Type safe comparison in plugins - second iteration

  • some more string comparisons
  • some bool
  • some int

This PR is part of a set to try to separate some of the changes done in one of my previous batch PR's for the plugins directory, which is still on hold (#12228).
Once the new set is merged completely, it will hopefully reduce the changes in that PR, so it can be reviewed easier and finally be merged.

The changes in this PR should be also be fairly easy to review. In hope that this will get merged quickly. ;)

Note: Don't bother if some possible changes are missing or could be differently written. They are probably in the batch PR , that this one references. As soon as this set of sub PR's is merged, the batch PR will have its conflicts resolved and should be a lot easier to review and finally get merged.

Testing Instructions

None, should not change behavior

Documentation Changes Required

None.

- some more string comparisons
- some bool
- some int
@wilsonge
Copy link
Contributor

Conflicts with the other PR :)

@andrepereiradasilva
Copy link
Contributor

# Conflicts:
#	plugins/content/vote/vote.php
#	plugins/system/languagefilter/languagefilter.php
@frankmayer
Copy link
Contributor Author

frankmayer commented Dec 19, 2016

@andrepereiradasilva Thanks missed the one you mentioned and also reverted another case that has multiple comparisons. In that second case though, there might be some cleaning up to do in future (false/null is used if no language is given, though maybe it could just be a '')

@frankmayer frankmayer changed the title Type safe string comparison of strings in plugins - second iteration Type safe comparison in plugins - second iteration Dec 19, 2016
@frankmayer
Copy link
Contributor Author

It would be great, if this sub-PR could be reviewed / tested and merged, so that the associated Batch PR can also be easier reviewed / tested and merged.

BTW, 👍 to all for putting in the extra work to support my efforts for all these PR with lots and lots of changes.

@@ -128,7 +128,7 @@ private function displayVotingData($context, &$row, &$params, $page)
include $path;
$html = ob_get_clean();

if ($this->app->input->getString('view', '') === 'article' && $row->state == 1)
if ($this->app->input->getString('view', '') === 'article' && $row->state === 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

doubt: is row state (and access in changes below) an int for sure in all cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you check this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, sorry, it got under. I checked it just now. You were right! Unfortunately it is not guaranteed that it is an int.
So, either we cast it to an int or we revert the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, I don't know if this has come up in the past, but if we want to do strict(er) typing, as we should, then I guess the db driver classes should make sure the right types are returned, also.

Copy link
Contributor

Choose a reason for hiding this comment

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

i agree, but a change like that IMHO should be in 4.0 branch
@wilsonge what do you think?

@andrepereiradasilva
Copy link
Contributor

BTW, 👍 to all for putting in the extra work to support my efforts for all these PR with lots and lots of changes.

no, thank you for doing this!

{
$asset = $extension;
}

if ($user->authorise('core.edit', $asset)
|| $user->authorise('core.create', $asset)
|| (count($user->getAuthorisedCategories($asset, 'core.create')) > 0)
|| ($user->authorise('core.edit.own', $asset) && $author == $user->id)
|| ($user->authorise('core.edit.own', $asset) && $author === $user->id)
|| (count($user->getAuthorisedCategories($extension, 'core.edit')) > 0)
|| (count($user->getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author == $user->id))
Copy link
Contributor

Choose a reason for hiding this comment

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

and what about line 53 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, missed that one... Thanks!!

@frankmayer frankmayer mentioned this pull request Dec 27, 2016
5 tasks
@andrepereiradasilva
Copy link
Contributor

andrepereiradasilva commented Dec 28, 2016

@frankmayer the one i pointed and you corrected is not the only case in this PR. (example: access)
Please review the PR changes according to that. IMO is important to make sure this (and the others) PR don't break anything by making incorrect assumptions reggarding the variable types.

@frankmayer
Copy link
Contributor Author

@andrepereiradasilva Yes, I was already checking those out, too...
Commit will follow soon.

@andrepereiradasilva
Copy link
Contributor

ok sorry, tought you missed them. ignore the comment them

@frankmayer
Copy link
Contributor Author

No, no, my fault. I shouldn't have pushed the commit, before completing my checks. I was multitasking with other things... 😸

@frankmayer
Copy link
Contributor Author

The rest should be OK now.

@frankmayer
Copy link
Contributor Author

It would be great, if this sub-PR could be reviewed / tested and merged, so that the referenced Batch PR #12228 can also be easier reviewed / tested and merged.

# Conflicts:
#	plugins/editors-xtd/image/image.php
@frankmayer
Copy link
Contributor Author

Conflicts resolved...

@frankmayer
Copy link
Contributor Author

Pls check and merge.

# Conflicts:
#	plugins/user/joomla/joomla.php
@andrepereiradasilva
Copy link
Contributor

I have tested this item ✅ successfully on 572572c

on code review


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13272.

@frankmayer
Copy link
Contributor Author

Thanks, one more tester to get this RTC?

@wilsonge wilsonge merged commit 9ba22b7 into joomla:staging May 31, 2017
@wilsonge wilsonge added this to the Joomla 3.7.3 milestone May 31, 2017
@frankmayer frankmayer deleted the type-safety-in-plugins-2 branch May 31, 2017 20:34
@@ -53,7 +53,7 @@ class JReCaptcha
*/
public function __construct($secret)
{
if ($secret == null || $secret == '')
if ($secret == null || $secret === '')
Copy link
Contributor

Choose a reason for hiding this comment

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

@frankmayer Should this be === null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think It could, and I also think I have done this in another PR.

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.

6 participants