? Pending

User tests: Successful: Unsuccessful:

avatar ReLater
ReLater
29 Jul 2021

Fixes #34964

Summary of Changes

  • Add a variable that count up separator menu items to create a guaranteed unique alias for each of them.
  • I haven't established the $separatorCount variable in method installPresetItems() because it looks like presets are imported stepwise (several calls of this method that reset the counter to 0). Maybe overcautious?

Testing Instructions

  • See instructions ín issue on #34964 please.

Actual result BEFORE applying this Pull Request

  • See image in issue on #34964 please.

Expected result AFTER applying this Pull Request

  • See image below with 4 successful tests that failed before.
  • At least 87 menu items imported with preset alternate.xml.
  • it is expected that each test run will add one more menu item entry (cross-reference to already existing menus).

29-07-_2021_15-46-10

avatar ReLater ReLater - open - 29 Jul 2021
avatar ReLater ReLater - change - 29 Jul 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 29 Jul 2021
Category Administration com_menus
avatar ReLater ReLater - change - 29 Jul 2021
Title
Add separator counter for reliable alias creation
[4.0] Menu preset import. Add separator counter for reliable alias creation.
avatar ReLater ReLater - edited - 29 Jul 2021
avatar ReLater ReLater - change - 29 Jul 2021
The description was changed
Labels Added: ?
avatar ReLater ReLater - change - 29 Jul 2021
The description was changed
avatar alikon
alikon - comment - 30 Jul 2021

i'm unable to replicate

avatar richard67
richard67 - comment - 30 Jul 2021

Well, the instructions in the issue say that it might be hard to replicate.

avatar ReLater
ReLater - comment - 1 Aug 2021

Quote from the PHP manual:
microtime(bool $as_float = false): string|float

If as_float is set to true, then microtime() returns a float, which represents the current time in seconds since the Unix epoch accurate to the nearest microsecond.

Emphasis on "time in seconds"! The value is rounded to seconds. This means that it is not incomprehensible if double values come out when a loop is run through faster if we use microtime(true)

When I test with a loop like this:

$withTrue = [];
$woTrue = [];

for ($i = 0; $i < 100000; $i++)
{
	$withTrue[] = microtime(true);
	//$woTrue[] = microtime();
}

echo '$withTrue: <pre>' . print_r($withTrue, true) . '</pre>';
// echo '$woTrue: <pre>' . print_r($woTrue, true) . '</pre>';

exit;

OR use a counted output: which outputs just two values that are never equal in my test cases:

echo 'count($withTrue): <pre>' . print_r(count($withTrue), true) . '</pre>';

$filter = array_unique($withTrue);

echo 'count($filter): <pre>' . print_r(count($filter), true) . '</pre>';
exit;
  • $withTrue case: I need several thousand loops before I get the first different time value. With the last test I needed ~16.000 loops.
  • $woTrue case: Also not reliable. Several blocks with several double time values. With just 100 loops => 75 double time values.
avatar ReLater ReLater - change - 14 Sep 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-09-14 18:37:21
Closed_By ReLater
Labels Added: ?
Removed: ?
avatar ReLater ReLater - close - 14 Sep 2021

Add a Comment

Login with GitHub to post a comment