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

Add the 'mtime' index to module and theme info arrays in the system table. mtime will contain the timestamp when the module/theme's .info was last saved.

Remaining tasks

- backport to D7

User interface changes

There will be no UI changes in core. Adding mtime will allow contrib modules to do things like sort the modules page by most recently-added modules.

API changes

- ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cafuego’s picture

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.

cafuego’s picture

FileSize
13.57 KB

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

theborg’s picture

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

cafuego’s picture

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.

jenlampton’s picture

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...

cafuego’s picture

@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.

jenlampton’s picture

@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

cafuego’s picture

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

cafuego’s picture

Status: Active » Needs review
FileSize
549 bytes

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.

cafuego’s picture

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

Bojhan’s picture

Is it possible to see, the effect of this?

cafuego’s picture

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.

Bojhan’s picture

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?

xjm’s picture

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

cafuego’s picture

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

cafuego’s picture

FileSize
2.56 KB

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

cafuego’s picture

FileSize
3.38 KB

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

Status: Needs review » Needs work

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

klonos’s picture

Status: Needs work » Needs review

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

cafuego’s picture

Status: Needs review » Needs work
FileSize
5.08 KB

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.

cafuego’s picture

Status: Needs work » Needs review
FileSize
5.08 KB

Oops, make bot test the patch.

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

klonos’s picture

Cool. Thanx.

Status: Needs review » Needs work

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

cafuego’s picture

Status: Needs work » Needs review
FileSize
1.96 KB

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

xjm’s picture

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?

cafuego’s picture

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?

cafuego’s picture

FileSize
1.88 KB

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

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

This looks great :)

chx’s picture

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.

jenlampton’s picture

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

yoroy’s picture

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.

Bojhan’s picture

Assigned: Unassigned » catch

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

catch’s picture

Assigned: catch » Unassigned
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?

cafuego’s picture

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() :-)

cafuego’s picture

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).

cafuego’s picture

Status: Needs review » Needs work
cafuego’s picture

Status: Needs work » Needs review
FileSize
1.87 KB
3.1 KB

Dear bots, please retest.

cafuego’s picture

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

Status: Needs review » Needs work

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

cafuego’s picture

Status: Needs work » Needs review
FileSize
3.31 KB

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.

kscheirer’s picture

Issue tags: -Usability, -d8ux

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

Status: Needs review » Needs work
Issue tags: +Usability, +d8ux

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

cafuego’s picture

Status: Needs work » Needs review
FileSize
2.07 KB
3.3 KB

Rerolled patches for new modules.test file location.

Status: Needs review » Needs work

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

cafuego’s picture

Status: Needs work » Needs review
FileSize
3.3 KB

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

kscheirer’s picture

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.

xjm’s picture

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.

catch’s picture

Status: Reviewed & tested by the community » Fixed

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

cafuego’s picture

Version: 8.x-dev » 7.x-dev
Status: Fixed » Needs review
FileSize
3.16 KB
1.95 KB

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!

Status: Needs review » Needs work

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

cafuego’s picture

Status: Needs work » Needs review
FileSize
3.04 KB
1.95 KB

I see what you did there...

cafuego’s picture

Modifying the tags.

Bojhan’s picture

Issue tags: -D7UX usability +Usability
xjm’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +API addition

Yep, looks backportable to me too.

David_Rothstein’s picture

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

David_Rothstein’s picture

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.

webchick’s picture

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.

cafuego’s picture

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.

David_Rothstein’s picture

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?

cafuego’s picture

Status: Needs work » Needs review
FileSize
809 bytes

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

cafuego’s picture

FileSize
1.35 KB

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

Bojhan’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

catch’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

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

Tor Arne Thune’s picture

Version: 8.x-dev » 7.x-dev
cafuego’s picture

Status: Patch (to be ported) » Needs review
FileSize
1.95 KB
3.05 KB

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

Status: Needs review » Needs work

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

jenlampton’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
3.05 KB

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

jenlampton’s picture

Status: Reviewed & tested by the community » Needs review

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

cafuego’s picture

69: 1355526-info-mtime-69.patch queued for re-testing.

Status: Needs review » Needs work

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

cafuego’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.95 KB
3.05 KB

The patch no longer applies to HEAD, rejigging it.

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

mgifford’s picture

73: 1355526-info-mtime-73.patch queued for re-testing.

mgifford’s picture

Was the UI change ever implemented? I was expecting to see a date column here /admin/modules or at least some screenshots.

I assume that this just adds a date column to the system table. Just making sure I know what to test for.

cafuego’s picture

There is no associated UI change, it's up to contrib to do something with this data.

mgifford’s picture

Issue summary: View changes

Ok, so it can be marked RTBC with a code review & when there's a confirmation that the system table now includes a date column.

dcam’s picture

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

The code review looks good.

There will not be a new column added to the system table. See #12. The Proposed Resolution section of the issue summary was incorrect. I've updated it. Instead of adding a new column, the date is put into the 'mtime' index of the serialized array in the info column.

I applied the patch and now I have 'mtime' in my module/theme info data. RTBC.

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review

dcam queued 73: 1355526-info-mtime-73.patch for re-testing.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

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

dcam’s picture

Status: Needs work » Reviewed & tested by the community

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

dcam queued 73: 1355526-info-mtime-73.patch for re-testing.

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review

dcam queued 73: 1355526-info-mtime-73.patch for re-testing.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review

Status: Needs review » Needs work

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

Status: Needs work » Needs review

dcam queued 73: 1355526-info-mtime-73.patch for re-testing.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review

dcam queued 73: 1355526-info-mtime-73.patch for re-testing.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review

dcam queued 73: 1355526-info-mtime-73.patch for re-testing.

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review
dcam’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

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

Status: Needs work » Needs review

dcam queued 73: 1355526-info-mtime-73.patch for re-testing.

dcam’s picture

Status: Needs review » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +7.33 release notes

Committed to 7.x - thanks!

  • David_Rothstein committed c990cd6 on 7.x
    Issue #1355526 by cafuego, jenlampton: Added a way to determine the date...

Status: Fixed » Closed (fixed)

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