? Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
10 Nov 2019

Pull Request for Issue #26017 (comment).

Summary of Changes

Corrects PHP syntax error coming from merge conflicts between PR #26017 and #26407 .

Testing Instructions

  1. Make a new installation with current 4.0-dev. Don't use any recent alpla release or nightly build, those will not contain the error.
  2. Go to "Users -> Privacy -> Requests" and click the "New" button to create a new request.
    Result: See section "Actual result" below.
  3. Go back to the control panel.
  4. Apply the changes in this PR.
  5. Go to "Users -> Privacy -> Requests" and click the "New" button to create a new request.
    Result: See section "Expected result" below.

This PR fixes the same error at 2 other places, too:

  • Exporting privacy requests to CSV,
  • Removing privacy requests.

These fixes can be tested in the same way, but code review should be sufficient.

Expected result

privacy-request-ok-1

Actual result

privacy-request-error-1

Documentation Changes Required

None.

avatar richard67 richard67 - open - 10 Nov 2019
avatar richard67 richard67 - change - 10 Nov 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 Nov 2019
Category Administration
avatar richard67 richard67 - change - 10 Nov 2019
The description was changed
avatar richard67 richard67 - edited - 10 Nov 2019
avatar richard67 richard67 - change - 10 Nov 2019
Title
[4.0] [WiP] Fix com_privacy prepared statements
[4.0] Fix com_privacy prepared statements
avatar richard67 richard67 - edited - 10 Nov 2019
avatar richard67
richard67 - comment - 10 Nov 2019

This PR here fixes it keeping the usage of ->setLimit(1) so it looks as follows:

$userId = (int) $db->setQuery(
	$db->getQuery(true)
		->select($db->quoteName('id'))
		->from($db->quoteName('#__users'))
		->where($db->quoteName('email') . ' = :email')
		->bind(':email', $table->email)
		->setLimit(1)
)->loadResult();

Another solution would be:

$userId = (int) $db->setQuery(
	$db->getQuery(true)
		->select($db->quoteName('id'))
		->from($db->quoteName('#__users'))
		->where($db->quoteName('email') . ' = :email')
		->bind(':email', $table->email),
	0,
	1
)->loadResult();

Question: What is better? @alikon @wilsonge any idea?

Update: Question answered by PR #26407 : 1st way is better,

The error fixed by this PR looks to me like coming from a merge conflict solved in #26017 in a bad way after I had tested it .

avatar richard67
richard67 - comment - 10 Nov 2019

@SharkyKZ @Quy Do you have any idea which of the 2 ways shown in my previous comment is the better way? In existing code at other plcaes I can find both variants being used.

avatar richard67
richard67 - comment - 10 Nov 2019

Ahhh I just see PR #26407 ... so all questions answered. SetLimit is the right thing, so this PR here is ok as it is.

avatar richard67 richard67 - change - 10 Nov 2019
The description was changed
avatar richard67 richard67 - edited - 10 Nov 2019
avatar richard67 richard67 - change - 10 Nov 2019
The description was changed
avatar richard67 richard67 - edited - 10 Nov 2019
avatar wilsonge wilsonge - change - 10 Nov 2019
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2019-11-10 13:38:06
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 10 Nov 2019
avatar wilsonge wilsonge - merge - 10 Nov 2019
avatar wilsonge
wilsonge - comment - 10 Nov 2019

Thanks!

Add a Comment

Login with GitHub to post a comment