Convert this page callback to a new-style Controller, using the instructions on http://drupal.org/node/1800686

CommentFileSizeAuthor
#84 interdiff.txt21.65 KBxano
#83 drupal8.dblog-module.1982954-83.patch11.36 KBsidharthap
#76 error.png7.28 KBdawehner
#75 drupal8.dblog-module.1982954-75.patch11.26 KBdisasm
#72 dblog-1982954-72.patch13.78 KBgoogletorp
#72 interdiff.txt2.37 KBgoogletorp
#69 dblog-1982954-69.patch13.41 KBgoogletorp
#69 interdiff.txt2.52 KBgoogletorp
#67 dblog-1982954-67.patch10.89 KBgoogletorp
#63 interdiff.txt1.05 KBandypost
#63 dblog-1982954-62.patch11.67 KBandypost
#57 dblog-1982954-57.patch11.65 KBdawehner
#57 interdiff.txt1.04 KBdawehner
#56 interdiff.txt5.57 KBandypost
#56 1982954-dblog-top-56.patch11.53 KBandypost
#49 drupal8.dblog-module.1982954-49.patch13.49 KBdisasm
#49 interdiff.txt921 bytesdisasm
#48 after.png18.11 KBalexpott
#48 before.png26.85 KBalexpott
#45 drupal8.dblog-module.1982954-45.patch13.55 KBdisasm
#45 interdiff.txt2.65 KBdisasm
#43 drupal8.dblog_top.1982954-43.patch13.57 KBdisasm
#43 interdiff.txt2.15 KBdisasm
#39 dblog-title-update-1982954-39.patch12.38 KBrainbowarray
#39 interdiff.txt402 bytesrainbowarray
#35 dblog-title-update-1982954-35.patch12.42 KBrainbowarray
#35 interdiff.txt6.73 KBrainbowarray
#33 dblog-title-update-1982954-33.patch8.36 KBrainbowarray
#33 interdiff.txt4.42 KBrainbowarray
#32 interdiff.txt1.25 KBrainbowarray
#31 dblog-title-update-1982954-31.patch10.82 KBrainbowarray
#30 dblog-1982954-30.patch10.88 KBrainbowarray
#26 drupal-1982954-26.patch8.36 KBdawehner
#26 interdiff.txt2.28 KBdawehner
#24 drupal-1982954-24.patch6.08 KBdawehner
#17 convert-dblog_top-to-a-controller-1982954-17.do-not-test.patch8.68 KBcb
#17 convert-dblog_top-to-a-controller-1982954-17.patch18.67 KBcb
#13 convert-dblog_top-to-a-controller-1982954-13.patch18.65 KBcb
#13 convert-dblog_top-to-a-controller-1982954-13.do-not-test.patch8.66 KBcb
#10 convert-dblog_top-to-a-controller-1982954-10.patch18.58 KBcb
#10 convert-dblog_top-to-a-controller-1982954-10.do-not-test.patch8.59 KBcb
#5 convert-dblog_top-to-a-controller-1982954.5.patch18.58 KBcb
#2 convert-dblog_top-to-a-controller-1982954.patch18.58 KBcb
#2 convert-dblog_top-to-a-controller-1982954.do-not-test.patch8.07 KBcb

Comments

cb’s picture

Issue tags: +WSCCI-conversion

Tagging

cb’s picture

Ok, two patches here.

One is the diff against origin/8.x and one is against a branch created using the patch at #1977254: Convert dblog_overview() to a Controller (do not test.)

Hopefully this is ok.

larowlan’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, convert-dblog_top-to-a-controller-1982954.patch, failed testing.

cb’s picture

Rerolled against 8.x.

cb’s picture

Status: Needs work » Needs review
dawehner’s picture

That's really good so far

+++ b/core/modules/dblog/dblog.moduleundefined
@@ -71,16 +63,12 @@ function dblog_menu() {
-  if (module_exists('search')) {
...
+  $items['admin/reports/search'] = array(
+    'title' => 'Top search phrases',
+    'description' => 'View most popular search phrases.',
+    'route_name' => 'dblog_top',

Don't we still need the search module for this functionality? The problem with that is, that it will appear in the menu, but you will get a 404 at the end.

+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.phpundefined
@@ -0,0 +1,312 @@
+   * Database Service.

Something like "The database connection" is more descriptive.

+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.phpundefined
@@ -0,0 +1,312 @@
+   * Constructs a DBLogController object.
...
+  public function __construct(Connection $database, ModuleHandlerInterface $module_handler) {

The constructor needs some documentation.

+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.phpundefined
@@ -0,0 +1,312 @@
+  public function overview() {

Missing @return

+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.phpundefined
@@ -0,0 +1,312 @@
+   * Page callback: Shows the most frequent log messages of a given event type.

That's not really a page callback anymore :)

+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DBLogController.phpundefined
@@ -0,0 +1,312 @@
+   * @see dblog_menu()

This @see doesn't seem to be really helpful anymore. What do you thin?

+++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.phpundefined
@@ -575,17 +576,7 @@ protected function getTypeCount(array $types) {
+    $map = array_flip(DBLogController::getLogLevelClassMap());

Nice!

Status: Needs review » Needs work

The last submitted patch, convert-dblog_top-to-a-controller-1982954.5.patch, failed testing.

cb’s picture

Status: Needs work » Needs review

Some of the things picked up are from #1977254: Convert dblog_overview() to a Controller which makes up the majority of this patch.

I've been speaking with larowlan about how to roll these patches when other dependent patches have not yet been committed, I'm not sure I'm doing it right... :|

Will base new patches off both 8.x and that other issue tomorrow.

cb’s picture

Ok, new patches attached.

The 'do-not-test' patch is a diff against #1977254: Convert dblog_overview() to a Controller which is not yet in 8.x but is a requirement for this issue.
The other patch includes the changes in #1977254: Convert dblog_overview() to a Controller and is against 8.x.

Please, when reviewing my work, review only the changes in 'do-not-test' as the rest of the changes are handled in #1977254: Convert dblog_overview() to a Controller.

Hopefully that makes sense.

Status: Needs review » Needs work

The last submitted patch, convert-dblog_top-to-a-controller-1982954-10.patch, failed testing.

cb’s picture

Status: Needs work » Needs review

Interestingly, this is falling over with events like this;

DBLog event was recorded: [content added]

Which is odd as none of that functionality was touched and the patch at #1977254: Convert dblog_overview() to a Controller which contains most of the code is green.

I'll have to dig into it later.

cb’s picture

Ok, so it seems I killed the /dblog route with my routing. So, rather than add three routes for these three reports, I added regex to match the reports negating /dblog. Works well.

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, convert-dblog_top-to-a-controller-1982954-13.patch, failed testing.

cb’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, convert-dblog_top-to-a-controller-1982954-13.patch, failed testing.

cb’s picture

Ok, so, my 'block /dblog path' was a silly idea. I changed my regex to match the required paths, rather than block other paths.

cb’s picture

Status: Needs work » Needs review
ParisLiakos’s picture

Status: Needs review » Postponed
cb’s picture

Now that #1977254: Convert dblog_overview() to a Controller is done, I'll roll this against the updated core code.

ParisLiakos’s picture

Status: Postponed » Needs work
dawehner’s picture

Status: Needs work » Needs review
Issue tags: -WSCCI-conversion

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, convert-dblog_top-to-a-controller-1982954-17.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new6.08 KB

Rerolled against the dblog overview push.

ParisLiakos’s picture

+++ b/core/modules/dblog/dblog.routing.ymlundefined
@@ -4,3 +4,11 @@ dblog_overview:
+    type: (access-denied|search|page-not-found).*

this is so cool!

i cant see though dblog_top's removal, is it used anywhere?

dawehner’s picture

StatusFileSize
new2.28 KB
new8.36 KB

You are totally right.

ParisLiakos’s picture

Status: Needs review » Needs work

i am not sure why...but after applying this patch, admin/reports misses all those 3 links:( just tested on simplytest.me:/

dawehner’s picture

That's more tricky to solve.

The requirements checking via a regex on parameters is not based on the access manager but on some symfony related regex bits.

star-szr’s picture

Assigned: cb » Unassigned
Issue tags: +Needs reroll

Seems like we can reroll at least.

rainbowarray’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new10.88 KB

Here's a reroll of the patch in #26.

rainbowarray’s picture

StatusFileSize
new10.82 KB

Here is an updated patch with the reroll as well as changing drupal_set_title to $build['#title'] . Hope I understood this correctly.

rainbowarray’s picture

StatusFileSize
new1.25 KB

Here's an interdiff for the patch in #31.

rainbowarray’s picture

StatusFileSize
new4.42 KB
new8.36 KB

Fixed a couple bugs in the reroll in #30 and the title fix in #31.

disasm’s picture

Status: Needs review » Needs work

Great job on the reroll mdrummond! Here's some minor coding style modifications that need done.

  1. +++ b/core/modules/dblog/dblog.routing.yml
    @@ -4,10 +4,17 @@ dblog_overview:
    -
    

    add this blank line back.

  2. +++ b/core/modules/dblog/dblog.routing.yml
    @@ -4,10 +4,17 @@ dblog_overview:
         _permission: 'access site reports'
    +dblog_top:
    

    add blank line between these also.

  3. +++ b/core/modules/dblog/dblog.routing.yml
    @@ -4,10 +4,17 @@ dblog_overview:
    \ No newline at end of file
    

    needs new line at end of file

  4. +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
    @@ -319,4 +320,99 @@ protected function buildFilterQuery() {
    +        $build['#title'] = "Top 'page not found' errors";        ¶
    

    extraneous spaces at end of this line

  5. +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
    @@ -319,4 +320,99 @@ protected function buildFilterQuery() {
    +      array('data' => t('Count'), 'field' => 'count', 'sort' => 'desc'),
    +      array('data' => t('Message'), 'field' => 'message'),
    ...
    +          $message = t($dblog->message, unserialize($dblog->variables));
    ...
    +      '#empty' => t('No log messages available.'),
    

    Change t( to $this->t(

rainbowarray’s picture

StatusFileSize
new6.73 KB
new12.42 KB

I made the above changes.

I changed all the t functions to $this->t functions. If that was too aggressive, my apologies.

rainbowarray’s picture

Status: Needs work » Needs review
disasm’s picture

+++ b/core/modules/dblog/dblog.routing.yml
@@ -17,4 +19,5 @@ dblog_top:
+    ¶

Newline character still isn't correct. Get rid of the spaces. Note that when you have missing newline character at end of file, or extra spaces at ends of lines, git diff should show it in bright red background text.

$this->t() and other changes are perfect.

Status: Needs review » Needs work

The last submitted patch, dblog-title-update-1982954-35.patch, failed testing.

rainbowarray’s picture

StatusFileSize
new402 bytes
new12.38 KB

Got rid of the spaces this time.

disasm’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, dblog-title-update-1982954-39.patch, failed testing.

dawehner’s picture

Now that the views integration is in it seems resonable to just use views to provide this top listing: #2015149: Replace dblog recent log entries with a view

disasm’s picture

Component: routing system » dblog.module
Status: Needs work » Needs review
StatusFileSize
new2.15 KB
new13.57 KB

Patch fixes remaining test failures. As for #42 I have no problems with switching this to a view, but I think that would make more sense to do in a follow-up issue and get this committed before we change our strategy on these conversions.

dawehner’s picture

  1. +++ w/core/modules/dblog/dblog.module
    @@ -49,34 +49,24 @@ function dblog_menu() {
     
    -  if (module_exists('search')) {
    -    $items['admin/reports/search'] = array(
    -      'title' => 'Top search phrases',
    -      'description' => 'View most popular search phrases.',
    -      'page callback' => 'dblog_top',
    -      'page arguments' => array('search'),
    -      'access arguments' => array('access site reports'),
    -      'file' => 'dblog.admin.inc',
    -    );
    -  }
    +  $items['admin/reports/search'] = array(
    +    'title' => 'Top search phrases',
    +    'description' => 'View most popular search phrases.',
    +    'route_name' => 'dblog_top',
    +  );
    +
     
       return $items;
    

    mhh, why did you removed the module('search') bit? Doesn't that mean that the link might still appear?

  2. +++ w/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
    @@ -319,4 +320,99 @@ protected function buildFilterQuery() {
    +   * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
    +   *
    

    Maybe we could write something like: Thrown when watchdog listing for search got accessed but search is not enabled.

disasm’s picture

StatusFileSize
new2.65 KB
new13.55 KB

addressed comments in #44.
Removed title from hook_menu

disasm’s picture

Also, renamed top() method to topLogMessages()

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Perfect, thank you!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new26.85 KB
new18.11 KB

Without the titles in the hook_menu implementation the menu items disappear.

Before patch

before.png

After patch

after.png

disasm’s picture

Status: Needs work » Needs review
StatusFileSize
new921 bytes
new13.49 KB

ok, adding titles back in to hook_menu.

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, drupal8.dblog-module.1982954-49.patch, failed testing.

disasm’s picture

Status: Needs work » Needs review
Issue tags: +WSCCI-conversion
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Great!

jibran’s picture

Issue tags: -WSCCI-conversion

Status: Reviewed & tested by the community » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, drupal8.dblog-module.1982954-49.patch, failed testing.

dawehner’s picture

Yes, it would make sense to use a view for that, but the other issue is on needs work and we need to get rid of the old router items: #2015149: Replace dblog recent log entries with a view

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new11.53 KB
new5.57 KB

Here's a fixed patch.

1) Page title inherited from menu
2) Reverted unused changes
3) no reason to have {type} - straight conversion so here's 3 routes

I don't think we need to implement route subscriber to add search route depending on module existence, just hidding of menu item is enough

dawehner’s picture

StatusFileSize
new1.04 KB
new11.65 KB

At least let's not drop the title from the route definition, this is wrong.

Status: Needs review » Needs work

The last submitted patch, dblog-1982954-57.patch, failed testing.

disasm’s picture

Status: Needs work » Needs review

It's either commit #56 or fix the test to use a normal quote and not an html escaped quote. When _title is used, the quote isn't converted to &#039, hence why I fixed the test.

andypost’s picture

I see no reason in title for this routes because we always have menus for them.
And this is a conversion of callback to controller so let's leave menu and titles as they are

dawehner’s picture

I see no reason in title for this routes because we always have menus for them.

That is not true. For things like building the breadcrumb we should better use the title on the route definition.
I guess I mixed up the single quote syntax of yaml, ... feel free to fix it.

jibran’s picture

andypost’s picture

StatusFileSize
new11.67 KB
new1.05 KB

Seems '_title' in yml is not passed check_plain()

disasm’s picture

Your syntax is correct, just the way the title is rendered in hook_menu and in _title is different.

googletorp’s picture

Issue tags: -WSCCI-conversion

#63: dblog-1982954-62.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, dblog-1982954-62.patch, failed testing.

googletorp’s picture

Status: Needs work » Needs review
StatusFileSize
new10.89 KB

Rerolled the patch since #2089635: Convert non-test non-form page callbacks to routes and controllers ruined the patch that was created.

I kept the naming of the routes that was already created in #2089635: Convert non-test non-form page callbacks to routes and controllers since they seemed to be more consistent with rest of core (dblog.search vs dblog_top_search)

Status: Needs review » Needs work

The last submitted patch, dblog-1982954-67.patch, failed testing.

googletorp’s picture

Status: Needs work » Needs review
StatusFileSize
new2.52 KB
new13.41 KB

Fixed the above issue, which meant removing the dblog.search as an dynamic route and use the static type which was introduced in the original patch.

Status: Needs review » Needs work

The last submitted patch, dblog-1982954-69.patch, failed testing.

jibran’s picture

+++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php
@@ -320,27 +320,69 @@ protected function buildFilterQuery() {
+      ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
+      ->extend('Drupal\Core\Database\Query\TableSortExtender');

It is \Drupal now.

googletorp’s picture

Status: Needs work » Needs review
StatusFileSize
new2.37 KB
new13.78 KB

I did what #72 said and fixed the issue from the test.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

I found no nitpicks

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Patch no longer applies.

disasm’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new11.26 KB

straight reroll. If this is green back to RTBC.

dawehner’s picture

StatusFileSize
new7.28 KB

Straight RTBC though I realized that we could improve somehow the information available on on the 403/404 pages. Message is not really the proper table header
as this is always just the path where the error happened.
error.png

cosmicdreams’s picture

Daniel can you explain in a follow up issue?

dawehner’s picture

googletorp’s picture

+1 This is RTBC.

xano’s picture

oriol_e9g’s picture

Issue tags: -Needs reroll

untag

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The with this patch applied the dblog.routing.yml file has a duplicate entry for dblog.search. They need to be combined :)

dblog.search:
  path: '/admin/reports/search'
  defaults:
    _title: "Top search phrases"
    _content: '\Drupal\dblog\Controller\DbLogController::topLogMessages'
    type: 'search'
  requirements:
    _permission: 'access site reports'

dblog.search:
  path: '/admin/reports/search'
  defaults:
    _content: '\Drupal\dblog\Controller\DbLogController::search'
    _title: 'Top search phrases'
  requirements:
    _module_dependencies: 'search'
    _permission: 'access site reports'
sidharthap’s picture

StatusFileSize
new11.36 KB

Thank you
corrected #82

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new21.65 KB

Here's the interdiff.

alexpott’s picture

#84 the interdiff is twice the size of the patch :) - not so helpful!!!

kim.pepper’s picture

andypost’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Patch still appplies, and this is just great clean-up

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.