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

Work on com_finder (both admin and site) #12254

Merged
merged 40 commits into from
Jul 19, 2017
Merged

Work on com_finder (both admin and site) #12254

merged 40 commits into from
Jul 19, 2017

Conversation

frankmayer
Copy link
Contributor

@frankmayer frankmayer commented Oct 2, 2016

Summary of Changes

Best practices, some optimization and cleaning up.

Testing Instructions

This should need only code review

$canCreate = $user->authorise('core.create', 'com_finder');
$canEdit = $user->authorise('core.edit', 'com_finder');

foreach ($this->items as $i => $item) :
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_finder') && $canCheckin;
?>
Copy link
Contributor

Choose a reason for hiding this comment

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

you could also move $user->authorise('core.manage', 'com_checkin') and $user->authorise('core.edit.state', 'com_finder') to outside the for since the $user does not change inside the for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I can't, because the second depends on the first, which may have different results because of the $item of the loop. Or am I getting this wrong?

But I could move the user->get outside the loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't mean all of it i mean just the

$user->authorise('core.manage', 'com_checkin')

And the

$user->authorise('core.edit.state', 'com_finder')

can be outside the cycle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, missed that. Yes, that is a nice idea. Let's try that.

*/
protected $state;

/**
* The total number of items
*
* @var object
* @var int
Copy link
Contributor

Choose a reason for hiding this comment

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

integer

*/
protected $state;

/**
* The total indexed items
*
* @var int
Copy link
Contributor

Choose a reason for hiding this comment

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

integer

*/
protected $state;

/**
* The total number of items
*
* @var object
* @var int
Copy link
Contributor

Choose a reason for hiding this comment

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

integer

@andrepereiradasilva
Copy link
Contributor

@frankmayer when you change tabs identation is more hard for testers to make a code review.

I normally append ?w=1 (ignore whitespaces changes) to the "Files changed" tab URL (Ex: https://github.com/joomla/joomla-cms/pull/12254/files?w=1) in those cases to be more easy to spot the differences, but i think not all people know this "trick".

So my sugestion is don't chnange code identation in this PRs

@frankmayer
Copy link
Contributor Author

@andrepereiradasilva As far as I can tell changed indentation on purpose was in one file only.
The other changes of indentation was the removal of nested ifs, resulting in the code of that group being moved to the left.
btw. nice parameter hint

# Conflicts:
#	components/com_finder/models/search.php
@@ -20,31 +20,48 @@ class FinderViewFilter extends JViewLegacy
* The filter object
*
* @var FinderTableFilter
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

*
* @since 2.5
*/
protected $total;
Copy link
Contributor

Choose a reason for hiding this comment

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

__DEPLOY_VERSION__

</tr>
$canCheckIn = $userAuthoriseCoreManage || $item->checked_out == $userId || $item->checked_out == 0;
$canChange = $userAuthoriseCoreEditState && $canCheckIn;
$escapedTitle = $this->escape($item->title);
Copy link
Contributor

Choose a reason for hiding this comment

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

cs: please ident the equal signs

@@ -20,34 +20,44 @@ class FinderViewFilters extends JViewLegacy
* An array of items
*
* @var array
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

this (and below) was actually added in 3.6.1 see 20c1846

@@ -22,41 +22,53 @@ class FinderViewIndex extends JViewLegacy
* An array of items
*
* @var array
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

this (and below) was actually added in 3.6.1 see 20c1846

@@ -22,34 +22,44 @@ class FinderViewMaps extends JViewLegacy
* An array of items
*
* @var array
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

this (and below) was actually added in 3.6.1 see 20c1846

@@ -20,6 +20,8 @@ class FinderViewStatistics extends JViewLegacy
* The index statistics
*
* @var JObject
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

this was actually added in 3.6.1 see 20c1846


protected $total;

protected $pagination;
Copy link
Contributor

Choose a reason for hiding this comment

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

please add doc blocks

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 removed one protected property, as it seemed not be used.

*/
protected $filter;

/**
* The JForm object
*
* @var JForm
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

3.6.2

* @var object
* @var JObject|boolean
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

3.6.2

* @var object
* @var mixed
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

3.6.2

*/
protected $items;

/**
* The pagination object
*
* @var JPagination
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

3.6.1

*/
protected $pagination;

/**
* The state of core Smart Search plugins
*
* @var array
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

3.6.1

*/
protected $sidebar;

/**
* The model state
*
* @var object
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

3.6.1

*/
protected $state;

/**
* The total number of items
*
* @var object
*
* @since 2.5
Copy link
Contributor

Choose a reason for hiding this comment

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

3.6.1

*
* @var integer
*
* @since 3.6.1
Copy link
Contributor

Choose a reason for hiding this comment

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

__DEPLOY_VERSION__

*
* @var array
*
* @since 3.6.1
Copy link
Contributor

Choose a reason for hiding this comment

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

__DEPLOY_VERSION__

protected $state;

protected $user;
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this removed? is B/C to remove a protected property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it could be. I was overeagerly cleaning up and noticed, it wasn't used in the context of this file or related tmpl. Will revert.

@@ -345,16 +345,13 @@ public function publish(&$pks, $value = 1)
{
$table->reset();

if ($table->load($pk))
if ($table->load($pk) && !$this->canEditState($table))
Copy link
Contributor

Choose a reason for hiding this comment

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

Dedent block below.

@@ -168,12 +168,12 @@ public function publish($pks = null, $state = 1, $userId = 0)
}

// If checkin is supported and all rows were adjusted, check them in.
if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
if ($checkin && (count($pks) === $this->_db->getAffectedRows()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove outside parentheses (count($pks) === $this->_db->getAffectedRows())

@@ -118,7 +118,7 @@
<?php echo JHtml::_('date', $item->indexdate, JText::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="center hidden-phone hidden-tablet">
<?php if (intval($item->publish_start_date) or intval($item->publish_end_date) or intval($item->start_date) or intval($item->end_date)) : ?>
<?php if ((int) $item->publish_start_date or (int) $item->publish_end_date or (int) $item->start_date or (int) $item->end_date) : ?>
Copy link
Contributor

@Quy Quy Jun 10, 2017

Choose a reason for hiding this comment

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

Change or to ||

@@ -34,7 +34,7 @@
<?php
$lang_key = 'PLG_FINDER_STATISTICS_' . str_replace(' ', '_', $type->type_title);
$lang_string = JText::_($lang_key);
echo ($lang_string == $lang_key) ? $type->type_title : $lang_string;
echo ($lang_string === $lang_key) ? $type->type_title : $lang_string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove parentheses.

@frankmayer
Copy link
Contributor Author

Thanks for reviewing @Quy

@ghost
Copy link

ghost commented Jun 10, 2017

@frankmayer is this PR to be tested by Code review?

@@ -425,7 +425,7 @@ protected function getResultsTotal()
$temp = $this->_db->loadObjectList();

// Set the more flag to true if any of the sets equal the limit.
$more = (count($temp) === $limit) ? true : false;
$more = (count($temp) === $limit);
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry found more. Remove parentheses. Do the same 3 more times below.

@Quy
Copy link
Contributor

Quy commented Jun 10, 2017

@franz-wohlkoenig yes code review.

@ghost
Copy link

ghost commented Jun 10, 2017

@Quy thanks for Info. @frankmayer can you please wrote Test Instructions "Code review" in first Comment for willing Tester?

@frankmayer
Copy link
Contributor Author

@Quy, @franz-wohlkoenig : Done and Done. Thanks

# Conflicts:
#	administrator/components/com_finder/views/filters/tmpl/default.php
@frankmayer
Copy link
Contributor Author

Conflicts resolved. Please test
Code review only should do.

Copy link
Contributor

@andrepereiradasilva andrepereiradasilva left a comment

Choose a reason for hiding this comment

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

just some minor comments
rest seems fine on code review


return $total;
return $db->loadResult();
Copy link
Contributor

Choose a reason for hiding this comment

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

small improv: you could use return $db->setQuery($query)->loadResult(); and remove the above line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally missed your comments here. Commit coming up.

@@ -9,22 +9,65 @@

defined('_JEXEC') or die;


Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this empty line

@andrepereiradasilva
Copy link
Contributor

I have tested this item ✅ successfully on 222ab4c

code review


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

@Quy
Copy link
Contributor

Quy commented Jun 29, 2017

I have tested this item ✅ successfully on 222ab4c

Code review


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

@ghost
Copy link

ghost commented Jun 29, 2017

RTC after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jun 29, 2017
@rdeutz rdeutz added this to the Joomla 3.8.0 milestone Jul 6, 2017
@mbabker mbabker changed the base branch from staging to 3.8-dev July 19, 2017 12:25
@mbabker mbabker merged commit ac7f0d5 into joomla:3.8-dev Jul 19, 2017
@joomla-cms-bot joomla-cms-bot added PR-3.8-dev and removed RTC This Pull Request is Ready To Commit labels Jul 19, 2017
@frankmayer frankmayer deleted the com_finder branch August 23, 2017 19:07
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

6 participants