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

[Scrutinizer] Fix issues in mod/ (_well_known to contactgroup) #4171

Merged
merged 10 commits into from
Jan 5, 2018

Conversation

MrPetovan
Copy link
Collaborator

@MrPetovan MrPetovan commented Jan 5, 2018

Part of #4176
Follow-up to #4166

Hypolite Petovan added 3 commits January 4, 2018 19:42
- Remove unused variables and parameter
- Updated function documentation
- Fix formatting
- Add back uninitialized variables
- Simplify nested conditions
Copy link
Collaborator

@annando annando left a comment

Choose a reason for hiding this comment

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

Please have a look at the change in functionality that I described.

if (($dow == $f) && (! $started)) {
$started = true;
}
$started = (($dow == $f) && (!$started));
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 difference in functionality. The original code would never set $started back to "false". This code is able to do so. Is it intended?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, good catch, I went too fast on my formatting spree.

mod/admin.php Outdated
@@ -720,7 +709,7 @@ function admin_page_summary(App $a)
if (Config::get('system', 'check_new_version_url', 'none') != 'none') {
$gitversion = Config::get('system', 'git_friendica_version');
if (version_compare(FRIENDICA_VERSION, $gitversion) < 0) {
$warningtext[] = sprintf(t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s'), $FRIENDICA_VERSION, $gitversion);
$warningtext[] = sprintf(t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s'), FRIENDICA_VERSION, $gitversion);
Copy link
Collaborator

Choose a reason for hiding this comment

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

t() includes sprintf() doesn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, I'll simplify the call. I'm not concentrating on it because it isn't a code error per se.

uninstall_theme($th['name']);
install_theme($th['name']);
}
foreach ($themes as $th) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't checked: Can we be sure that $themes is always an array?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Defined as such on line 1963, populated on line 1982.

$remote_contact = true;
}
}
if(! $remote_contact) {
if(local_user()) {
$contact_id = $_SESSION['cid'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this variable unused?

Copy link
Collaborator Author

@MrPetovan MrPetovan Jan 5, 2018

Choose a reason for hiding this comment

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

After line 129, no. If you think this call should be moved up let me know. However $remote_contact will always be false so I don't think it's warranted.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant the assignment of the variable with the content of $_SESSION['cid']; which now doesn't happen in the code any more if I see it right.

Hypolite Petovan added 4 commits January 4, 2018 22:51
- Replaced sizeof by count
- Used DBM::is_result()
- Use defaults for request parameters
Copy link
Collaborator

@annando annando left a comment

Choose a reason for hiding this comment

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

I don't understand the reason for one change.

mod/admin.php Outdated
@@ -1266,7 +1266,7 @@ function admin_page_site(App $a)
'$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$shortcut_icon' => array('shortcut_icon', t("Shortcut icon"), Config::get('system','shortcut_icon'), t("Link to an icon that will be used for browsers.")),
'$touch_icon' => array('touch_icon', t("Touch icon"), Config::get('system','touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")),
'$info' => array('info', t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/servers.'), get_server())),
'$info' => array('info', t('Additional Info'), $info, t('For public servers: you can add additional information here that will be listed at %s/servers.', System::baseUrl()), get_server()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why had you added System::baseUrl()) here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you look at the translation string, there is a %s but no interpolation variable was provided. I just filled in the blank.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The %s belongs to get_server().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😅

mod/admin.php Outdated
@@ -2121,7 +2123,7 @@ function admin_page_themes(App $a)
'$function' => 'themes',
'$plugins' => $plugins,
'$pcount' => count($themes),
'$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
'$noplugshint' => t('No themes found on the system. They should be paced in %1$s', '<code>/view/themes</code>'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

placed

$nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
$nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
$nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
$pending = defaults($_POST, 'pending' , array());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a style question: Wouldn't it be preferable to set the comma directly after the parameter and not with much space before?

Copy link
Collaborator Author

@MrPetovan MrPetovan Jan 5, 2018

Choose a reason for hiding this comment

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

To align with the followingdefaults() calls default values.

@annando annando merged commit 045a0b2 into friendica:develop Jan 5, 2018
/// @todo : Initialize $profile_uid
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@annando Any idea how to properly initialize $profile_uid here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this the local_user() in most cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe, but this is the module showing the common friends between two users/contacts, so there are many possibilities.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Common friends is done differently. But for a deeper look I'm too tired now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's okay, it's been broken like this for a while, it can wait a little longer.

@MrPetovan MrPetovan added this to the 3.6 milestone Mar 9, 2018
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.

None yet

2 participants