Download & Extend

Add a way to determine the date a module was added so the modules page can use it for sort

Project:Drupal core
Version:7.x-dev
Component:base system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Issue tags:API addition, needs backport to D7, Usability

Issue Summary

Spun off from #538904: D8UX: Redesign Modules Page

Problem/Motivation

It's really hard to find modules that were recently added to my site, when viewing the module list page.

Proposed resolution

Adding a date column to the system table will enable us to add a "new" or "recently installed" section to the modules page, making the process of finding that module you *just* added easier to locate on the page.

Remaining tasks

- make this happen

User interface changes

- create a "new" or "recently added" section to the top of the modules page

API changes

- ?

Comments

#1

The module page does not use an SQL query to sort its output as far as I can tell, rather it builds an array by scanning the filesystem for .info files and then performs an alpha sort on the results.

To list the date a module was added to the filesystem (as opposed to enabled) you don't need an extra column on the system table. Since a module's .info file is opened and parsed when the module list is created, it's only a minute amount of overhead to get the last modified time for the same file as well.

This requires a call to filemtime() in core/include/common.inc:drupal_parse_info_file() and for the resulting timestamp to be added to the info array for the module filename. At that point, it'll automatically be saved in the serialized module info field in the system table.

To display recently installed modules, either the existing system_modules() form needs to be modified or a new modules form needs to be defined. Modifying the existing function is pretty straightforward, but would make it less readable.

#2

Proof of concept patch attached. Uses a separate module form for the date-ordered modules.

AttachmentSizeStatusTest resultOperations
1355526-2.patch13.57 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in core/modules/system/system.install.View details | Re-test

#3

Looks good to me, I was working on loading the date from watchdog files but this patch, indeed, is more flexible.

#4

I should probably also mention that I've had a try of adding an mtime column to the system table, but then found that the updated INSERT call actually tries to run before the update hook that adds the field. Oops! So if it is to be done, that's slightly trickier than it may appear to be at first glance.

#5

Title:Add a date column to the system table so modules can be sorted by date added» Add a way to determine the date a module was added so the modules page can use it for sort

@cafuego the page needs to do a SQL query to find out which modules are enabled, so I'm sure we could retrieve the added date from that query if we had to (not sure about the update/insert part). But, I like this approach better. :)

Now all we need is a UI for these new modules...

#6

@jenlampton Do you want to let ideas for the UI come from the research that's to come out of #538904: D8UX: Redesign Modules Page ?

The patch attached above has a very basic grouping of modules added today/yesterday/this week/earlier, that work precisely like the groupings on the normal modules page. Though it does order by date added, it doesn't display it.

#7

@cafuego yeah, I'd like a little more guidance for the UI. I personally think today/yesterday/this week/earlier is way too much. But it will be interesting to see what comes out of #538904: D8UX: Redesign Modules Page

#8

Fair enough. I added those based on my own workflow, so they're possibly not useful to everyone else ;-)

#9

Status:active» needs review

Okay, lets get this show on the road with a tiny patch.

The attached patch adds the .info file mtime to the array returned by drupal_parse_info_file(). With that extra field, it's already possible to implement a date-sorted modules admin page as a contrib module.

The patch is also small and innocuous enough that it can be ported to and perhaps allowed in D7.

AttachmentSizeStatusTest resultOperations
1355526-module-added-date-9.patch549 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 34,219 pass(es).View details | Re-test

#10

*cough* Lets try that again after some coffee and add the mtime to the correct array element :-)

AttachmentSizeStatusTest resultOperations
1355526-module-added-date-10.patch560 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 34,206 pass(es).View details | Re-test

#11

Is it possible to see, the effect of this?

#12

This patch by itself has no visible effect, all it does is add an element to an array, which is then as yet unused internally.

#13

Ok, I suggest we do not introduce the UI elements in this issue - but rather focus on enabling us to do it.

Can this get a code review?

#14

This seems harmless to me offhand. Let's add a test for it?

#15

What do you want to test? That the call to load .info files returns the mtime element?

#16

Modified comment slightly and added a test to ensure the system.info mtime field is present and contains likely looking data.

AttachmentSizeStatusTest resultOperations
1355526-16.patch2.56 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,262 pass(es).View details | Re-test

#17

Test that patch with only test and no functionality in fact fails, epically!

AttachmentSizeStatusTest resultOperations
1355526-17.patch3.38 KBIdleFAILED: [[SimpleTest]]: [MySQL] 34,269 pass(es), 2 fail(s), and 1 exception(s).View details | Re-test

#18

Status:needs review» needs work

The last submitted patch, 1355526-17.patch, failed testing.

#19

Status:needs work» needs review

...why was the the t() function wrap removed from the messages in the second patch?

#20

Status:needs review» needs work

Modified the test slightly to not throw a notice if the field we're testing for is not present. Attached patch should fail two tests and not throw exceptions.

AttachmentSizeStatusTest resultOperations
1355526-19.patch5.08 KBIdleFAILED: [[SimpleTest]]: [MySQL] 34,256 pass(es), 2 fail(s), and 0 exception(s).View details | Re-test

#21

Status:needs work» needs review

Oops, make bot test the patch.

@klonos As per the comment, because @xjm said so ;-) See: #500866: [META] remove t() from assert message.

AttachmentSizeStatusTest resultOperations
1355526-19.patch5.08 KBIdleFAILED: [[SimpleTest]]: [MySQL] 34,271 pass(es), 2 fail(s), and 0 exception(s).View details | Re-test

#22

Cool. Thanx.

#23

Status:needs review» needs work

The last submitted patch, 1355526-19.patch, failed testing.

#24

Status:needs work» needs review

Flattened patch with the code change *and* latest version of the tests. This should be the one.

AttachmentSizeStatusTest resultOperations
1355526-24.patch1.96 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,270 pass(es).View details | Re-test

#25

I was about to RTBC this, but on re-read I doubted whether we can make the assumption that core has just been modified when the test runs. And, indeed, the test fails locally on my existing D8 installation. Thoughts?

#26

I guess I can pick an arbitrary date and test that the system.info file mtime is set and is newer than that. I've redone the patch and used the D7 release date as timestamp to test against. You reckon that idea will fly?

#27

Rerolled the patch, checking whether the mtime is present, numeric and greater than 0.

AttachmentSizeStatusTest resultOperations
1355526-27.patch1.88 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,472 pass(es).View details | Re-test

#28

Status:needs review» reviewed & tested by the community

This looks great :)

#29

Adding a date column to the system table will enable us to add a "new" or "recently installed" section to the modules page, making the process of finding that module you *just* added easier to locate on the page.

Make sure you don't call it "recently installed" because what this patch does is allow you to see files "recently copied to the server". They are not installed. They are just there.

Otherwise, yeah, not really a better indicator for finding the stuff I just ftp'd up so let's go ahead with committing this.

#30

Agreed, when we add something to the UI that indicates "what's new" we should label it carefully :)

#31

This has my +1 too. At the D7UX sprint in 2009 we came up with the idea of having a "new" box on top of the modules page. It'd be great to be able to do that for D8.

#32

Assigned to:Anonymous» catch

I am going to assign this to catch for commit, its passed its RTBC waiting time.

#33

Assigned to:catch» Anonymous
Status:reviewed & tested by the community» needs review

Hmm I don't think we should put this in the drupal_parse_info_file() function, that's supposed to be a straight format parser, adding the mtime in there doesn't seem right. What about in _system_rebuild_module_data() instead?

#34

What about in _system_rebuild_module_data() instead?

That would work, but as far as I can tell that means theme .info files miss out.

Edit: Unless I also patch _system_rebuild_theme_data() :-)

#35

Updated patch as per comment 33. The .info file mtime is now added in _system_rebuild_module_data() and _system_rebuild_theme_data() instead.

Attached are a full patch (which should pass) and a test-only patch (which should fail).

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-35.patch3.1 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1355526-info-mtime-35.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test
1355526-info-mtime-35-testonly.patch1.87 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1355526-info-mtime-35-testonly.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#36

Status:needs review» needs work

#37

Status:needs work» needs review

Dear bots, please retest.

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-35.patch3.1 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,926 pass(es).View details | Re-test
1355526-info-mtime-35-testonly.patch1.87 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,921 pass(es).View details | Re-test

#38

Lets try that again with the tests on the inside of a class. *brown paper bag*

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-38.patch3.31 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,924 pass(es).View details | Re-test
1355526-info-mtime-38-testonly.patch2.08 KBIdleFAILED: [[SimpleTest]]: [MySQL] 35,922 pass(es), 4 fail(s), and 0 exception(s).View details | Re-test

#39

Status:needs review» needs work

The last submitted patch, 1355526-info-mtime-38-testonly.patch, failed testing.

#40

Status:needs work» needs review

Just changed once instance of 'system' to 'bartik' in a test comment compared to the patch on #38. Should all work now and be ready for a possible RTBC again.

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-40.patch3.31 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1355526-info-mtime-40.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#41

#40: 1355526-info-mtime-40.patch queued for re-testing.

#42

Status:needs review» needs work

The last submitted patch, 1355526-info-mtime-40.patch, failed testing.

#43

Status:needs work» needs review

Rerolled patches for new modules.test file location.

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-43.patch3.3 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,363 pass(es).View details | Re-test
1355526-info-mtime-43-testonly.patch2.07 KBIdleFAILED: [[SimpleTest]]: [MySQL] 35,364 pass(es), 4 fail(s), and 0 exception(s).View details | Re-test

#44

Status:needs review» needs work

The last submitted patch, 1355526-info-mtime-43-testonly.patch, failed testing.

#45

Status:needs work» needs review

Re-attaching the full patch only, so the bot doesn't change the issue status back.

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-43.patch3.3 KBIdlePASSED: [[SimpleTest]]: [MySQL] 35,380 pass(es).View details | Re-test

#46

Status:needs review» reviewed & tested by the community

From #12 and #13, this patch has no visual effect, just setting the stage for making use of this in the UI. Testbot is happy, looks like a good addition to me.

#48

Agreed on the RTBC (note that "testbot is happy" isn't the only requirement). :) I've reviewed #45, and both the feature and the test for it look complete to me.

#49

Status:reviewed & tested by the community» fixed

Yep, looks good now. Committed/pushed to 8.x.

#50

Version:8.x-dev» 7.x-dev
Status:fixed» needs review

Lovely, thanks catch.

Because it's immediately usable by contrib, doesn't break anything and webchick allows minor changes to D7, I've backported it. The changes to system.module are identical as the 8.x patch. The tests live in a slightly different location in system.test. Patches attached, bombs away!

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-50-testonly.patch1.95 KBIdleFAILED: [[SimpleTest]]: [MySQL] 39,023 pass(es), 4 fail(s), and 0 exception(s).View details | Re-test
1355526-info-mtime-50.patch3.16 KBIdleFAILED: [[SimpleTest]]: [MySQL] 39,019 pass(es), 0 fail(s), and 225 exception(s).View details | Re-test

#51

Status:needs review» needs work

The last submitted patch, 1355526-info-mtime-50.patch, failed testing.

#53

Status:needs work» needs review

I see what you did there...

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-51-testonly.patch1.95 KBIdleFAILED: [[SimpleTest]]: [MySQL] 39,024 pass(es), 4 fail(s), and 0 exception(s).View details | Re-test
1355526-info-mtime-51.patch3.04 KBIdlePASSED: [[SimpleTest]]: [MySQL] 39,140 pass(es).View details | Re-test

#54

Modifying the tags.

#55

#56

Status:needs review» reviewed & tested by the community
Issue tags:+API addition

Yep, looks backportable to me too.

#57

#53: 1355526-info-mtime-51.patch queued for re-testing.

#58

Patch looks reasonable, but we're not under thresholds currently, so I'm not committing it to D7 yet. Hopefully soon... sooner if you help with the major/criticial queue :)

However, while I was looking at the patch, I found the comments a little confusing:

+    // Add the info file modification time, so the modules page can be sorted
+    // by the date modules were added or updated.

To me, that makes it sound like Drupal is actually sorting the modules page that way, but rather we're just adding the data here and that's one possible way the data could be (theoretically) used.

Might be useful to clarify that somehow.

#59

Status:reviewed & tested by the community» needs work

That sounds like a needs work.

Additionally, David has requested help on resolving release blockers, so I don't feel comfortable committing 7.x feature patches until that happens.

#60

How about this instead?

// Add the info file modification time, so it becomes available for
// contributed modules to use for ordering module and theme lists.

#61

Version:7.x-dev» 8.x-dev

Something like that sounds good to me.

So I guess if we're going to change the code comment, we should probably get that into Drupal 8 first and then backport the whole thing at once?

#62

Status:needs work» needs review

Wow, I'd totally lost track of this patch! Attached is a patch for D8 that changes the code comment as per comment #60.

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-62.patch809 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 40,569 pass(es).View details | Re-test

#63

D'oh, forgot the comment in _system_rebuild_theme_data(). Updated patch attached.

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-63.patch1.35 KBIdlePASSED: [[SimpleTest]]: [MySQL] 40,570 pass(es).View details | Re-test

#64

Status:needs review» reviewed & tested by the community

Back to RTBC

#65

Status:reviewed & tested by the community» patch (to be ported)

Committed/pushed the follow-up to 8.x, moving back to 7.x again.

#66

Version:8.x-dev» 7.x-dev

#67

Status:patch (to be ported)» needs review

Full D7 patch with functionality, tests and updated comments attached, as well as a test-only patch that should fail.

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-67.patch3.05 KBIdlePASSED: [[SimpleTest]]: [MySQL] 39,381 pass(es).View details | Re-test
1355526-info-mtime-67-testonly-mustfail.patch1.95 KBIdleFAILED: [[SimpleTest]]: [MySQL] 39,358 pass(es), 4 fail(s), and 0 exception(s).View details | Re-test

#68

Status:needs review» needs work

The last submitted patch, 1355526-info-mtime-67-testonly-mustfail.patch, failed testing.

#69

Status:needs work» reviewed & tested by the community

Re uploading test-passing patch (with no changes), and changing status back to RTBC!

AttachmentSizeStatusTest resultOperations
1355526-info-mtime-69.patch3.05 KBIdlePASSED: [[SimpleTest]]: [MySQL] 39,417 pass(es).View details | Re-test

#70

Status:reviewed & tested by the community» needs review

Or maybe I need to do that in two steps, got a little too excited :/

nobody click here