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

Removes default action name for flattened action urls #12669

Merged
merged 8 commits into from May 3, 2018
Merged

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Mar 28, 2018

When flattening url action reports the default_action_name (default: index) is still contained in the labels.
This changes will remove that.

fixes #12651

@sgiehl sgiehl added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Mar 28, 2018
@sgiehl sgiehl added this to the 3.4.1 milestone Mar 28, 2018
Copy link
Member

@diosmosis diosmosis left a comment

Choose a reason for hiding this comment

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

Left a couple questions.

Also @mattab, @sgiehl's question on the original issue is unanswered. Can you give a 👍 if removing the index from all flattened reports is ok?

$label = substr($label, 0, -strlen($defaultActionName));
if (substr($label, -1) == '/') {
$label = rtrim($label, '/') . '/';
}
Copy link
Member

Choose a reason for hiding this comment

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

I think you can just have $label = rtrim($label, '/') . '/'; here instead of the if(), right? It should have the same effect even if the string doesn't end w/ '/'.

Copy link
Member

Choose a reason for hiding this comment

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

Also does this code need to take into account the [General] action_url_category_delimiter option? I don't know what the use case would be for it not to be /, but you never know I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

using the config should make sense

// remove the default action name 'index' in the end of flattened urls
if (Common::getRequestVar('flat', 0)) {
$label = $row->getColumn('label');
if (substr($label, -strlen($defaultActionName)) == $defaultActionName) {
Copy link
Member

Choose a reason for hiding this comment

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

If a row has a label like /path/to/filenamewithindex, will this still work?

Copy link
Member Author

Choose a reason for hiding this comment

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

hm... will change it so that won't match

@diosmosis
Copy link
Member

Also, I think there's probably test coverage for flattened actions reports, but if not, would be good to cover this change in a test.

Copy link
Member

@mattab mattab left a comment

Choose a reason for hiding this comment

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

Currently in global.ini.php we have action_default_name = index

So maybe the solution could be to make action_default_name = in global.ini.php so that this setting still does what it used to ?

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<result>
<row>
<label>index</label>
<label></label>
Copy link
Member

Choose a reason for hiding this comment

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

here it's expected to be / ie. the root URL

Copy link
Member Author

Choose a reason for hiding this comment

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

In flattened url reports currently all leading slashes are removed. Should all other labels have leading slashes as well? Otherwise it would be inconsistent

Copy link
Member

Choose a reason for hiding this comment

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

👍 sounds good that all pages have leading slashes

@sgiehl
Copy link
Member Author

sgiehl commented Mar 29, 2018

The default action name will still be displayed for non flattened reports. Changing it also won't change any old reports...

@sgiehl sgiehl force-pushed the flattenactions branch 2 times, most recently from 67d1a0d to 6c50548 Compare April 1, 2018 16:39
@sgiehl sgiehl force-pushed the flattenactions branch 3 times, most recently from c4561c5 to ccf0124 Compare April 23, 2018 16:28
@mattab
Copy link
Member

mattab commented Apr 24, 2018

@sgiehl fyi tests result show some possible regression

@sgiehl
Copy link
Member Author

sgiehl commented Apr 24, 2018

I have seen that. I'm not yet sure how to solve that best without regressions... Need to investigate that further...

@sgiehl sgiehl self-assigned this Apr 24, 2018
@sgiehl sgiehl added Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. and removed Needs Review PRs that need a code review labels Apr 24, 2018
@sgiehl sgiehl force-pushed the flattenactions branch 4 times, most recently from d79717b to edd92cb Compare April 27, 2018 15:47
@sgiehl
Copy link
Member Author

sgiehl commented Apr 27, 2018

@mattab guess I now found a way how to always have a leading slash. But one thing needs to be clear here: Changing that might break some custom alerts defined by users. CustomAlerts plugin uses flatten reports for comparing actions. As the returned actions changes (leading slash and removed default action name) this might change results of defined alerts...

@sgiehl sgiehl force-pushed the flattenactions branch 3 times, most recently from e6fcbc2 to 9bcbb5e Compare April 27, 2018 19:57
@sgiehl sgiehl added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Apr 27, 2018
@sgiehl sgiehl removed their assignment Apr 28, 2018
@mattab
Copy link
Member

mattab commented Apr 30, 2018

@sgiehl the tests results look good now 👍

Feedback:

  • Since this is an API change, and possibly API break for some edge case like custom alerts, could you please add a mention in the CHANGELOG.md ?

@mattab
Copy link
Member

mattab commented Apr 30, 2018

@sgiehl i was expecting that the PR includes the change in global.ini.php: action_default_name = or action_default_name = / , why not?

@sgiehl
Copy link
Member Author

sgiehl commented Apr 30, 2018

@mattab As the title says it currently only changes flattened reports.
Changing action_default_name would change all reports. And it would only affect new data, all already tracked data and generated reports wouldn't change.

@mattab
Copy link
Member

mattab commented Apr 30, 2018

@sgiehl Makes sense. And what do you think about the idea of changing the setting to / or empty string, in a separate PR, to make it consistent with the flattened reports? Would there be any issue with this approach maybe?

@sgiehl
Copy link
Member Author

sgiehl commented Apr 30, 2018

We maybe should only do that for new installs as otherwise we might create inconsistency between old and new tracked data & reports.
Also setting it to / might be logically incorrect. We never store a leading slash for any action. So an empty string might be more correct...

@mattab
Copy link
Member

mattab commented May 2, 2018

@sgiehl noticed there's an integration test failing in CustomAlerts, could you update the submodule so the test passes?

@sgiehl
Copy link
Member Author

sgiehl commented May 2, 2018

Sure. Would do that directly before merging. Is everything else here good to merge?

@mattab
Copy link
Member

mattab commented May 2, 2018

@sgiehl LGTM. I reckon we should completely remove the action_default_name feature since it's not useful IMO, but let's do it later and keep this PR this PR as is.

Created another issue: Remove the feature to set a custom action name "action_default_name" #12809

sgiehl added a commit to matomo-org/plugin-CustomAlerts that referenced this pull request May 3, 2018
@sgiehl sgiehl merged commit 83ae917 into 3.x-dev May 3, 2018
@sgiehl sgiehl deleted the flattenactions branch May 3, 2018 21:14
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
* remove default action name for flattened action urls

* improve code

* update system tests

* always prepend action delimiter to flattened action urls

* update ui files

* update test files

* updates CHANGELOG

* submodule update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In Email reports, Page URLs report append directory root pages with /index
3 participants