Is there a good reason HISTORY_READ_LIMIT is exactly 30 days ago? Shouldn't site administrators be able to configure this interval? I'm currently building a site where members are expected to visit less frequently than monthly, but need to see new content and comments where "new" is since their last log in, or say, in the last 100 days.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Nice idea

kscheirer’s picture

Assigned: Unassigned » kscheirer

We need to get rid of that define() anyway.

kscheirer’s picture

Assigned: kscheirer » Unassigned
Status: Active » Needs review
FileSize
3.73 KB

Status: Needs review » Needs work

The last submitted patch, history-configurable_read_limit-2006632-3.patch, failed testing.

andypost’s picture

  1. @@ -0,0 +1,5 @@
    +history_mark_read: '2592000'
    

    this should have schema for introduced config https://drupal.org/node/1905070 and #1910624: [META] Introduce and complete configuration schemas in all of core

  2. @@ -71,8 +63,9 @@ function history_write($nid, $account = NULL) {
    +  $history_read_limit = REQUEST_TIME - config('history.settings')->get('history_mark_read');
    
    @@ -79,18 +79,21 @@ public function render(ResultRow $values) {
    +      $history_read_limit = REQUEST_TIME - config('history.settings')->get('history_mark_read');
    
    @@ -67,7 +67,7 @@ public function query() {
    +    $limit = REQUEST_TIME - config('history.settings')->get('history_mark_read');
    

    s/config/Drupal::config, see #1957142: Replace config() with Drupal::config()

kscheirer’s picture

Status: Needs work » Needs review
FileSize
6.17 KB

Talked with Crell, Drupal::config is not ok when we're in a namespace. Switched over in the .module file, trying to use the dependency injection for the views plugins.

However, this patch fails locally with "Declaration of Drupal\history\Plugin\views\field\HistoryUserTimestamp::create() must be compatible with that of Drupal\Core\Plugin\ContainerFactoryPluginInterface::create()". Not sure how it's incompatible though, they look pretty identical to me.

Hopefully someone else can run with it or let me know what's wrong. Still need to provide a schema for the config settings as well.

Status: Needs review » Needs work

The last submitted patch, history-configurable-read-limit-2006632-6.patch, failed testing.

mstrelan’s picture

Can we fix the English of this comment at the same time?

     // Hey, Drupal kills old history, so nodes that haven't been updated
     // since HISTORY_READ_LIMIT are bzzzzzzzt outta here!

See https://drupal.org/coding-standards/docs#drupal

All documentation and comments should form proper sentences, use proper grammar and punctuation, and generally follow the same style guidelines as Drupal.org content: http://drupal.org/style-guide/content

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

DanieleN’s picture

I disabled currently only the cron job, because we want not to delete the information when user has read the node.
Patch works on 8.5.x

We should it make configurable via GUI in admin/config/content/history or similar.
If is that a need, it make sense to "redesign" the module so that the above can be configured.

DanieleN’s picture

Status: Needs work » Active
kscheirer’s picture

Status: Active » Needs review

If there's a patch to review, status should be "Needs review".

DanieleN’s picture

The patch is only a fix for those which doesn't want delete the history after 30day. "Make HISTORY_READ_LIMIT configurable" is not solved with that patch above

kscheirer’s picture

Status: Needs review » Needs work

Ah, I understand, thanks. Should still be "needs work" then.

andypost’s picture

for patch #6

YurkinPark’s picture

Status: Needs work » Needs review
FileSize
14.38 KB

Rerolled for 8.6.x, also, i've checked other modules and services, changed there as well

Status: Needs review » Needs work

The last submitted patch, 21: history_configurable_read_limit_2006632_21.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

YurkinPark’s picture

YurkinPark’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: history_configurable_read_limit_2006632_23.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

andypost’s picture

Version: 8.6.x-dev » 8.7.x-dev
andypost’s picture

  1. +++ b/core/modules/comment/src/CommentManager.php
    @@ -82,6 +89,7 @@ public function __construct(EntityManagerInterface $entity_manager, ConfigFactor
    +    $this->historyMarkRead = $config_factory->get('history.settings')->get('history_mark_read');
    
    +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
    @@ -46,18 +54,21 @@ public function usesGroupBy() {
    +    $this->historyReadLimit = REQUEST_TIME - $configFactory->get('history.settings')->get('history_mark_read');
    

    Do not cache config inside service

  2. +++ b/core/modules/comment/src/CommentManager.php
    @@ -198,7 +206,8 @@ public function getCountNewComments(EntityInterface $entity, $field_name = NULL,
    +      $history_read_limit = REQUEST_TIME - $this->historyMarkRead;
    
    +++ b/core/modules/history/history.module
    @@ -125,8 +117,9 @@ function history_write($nid, $account = NULL) {
    +  $history_read_limit = REQUEST_TIME - \Drupal::config('history.settings')->get('history_mark_read');
    
    +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php
    @@ -18,7 +20,43 @@
    +      REQUEST_TIME - $container->get('config.factory')->get('history.settings')->get('history_mark_read')
    
    +++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
    @@ -16,10 +18,44 @@
    +      REQUEST_TIME - $container->get('config.factory')->get('history.settings')->get('history_mark_read')
    
    +++ b/core/modules/node/node.module
    @@ -246,6 +246,7 @@ function node_title_list(StatementInterface $result, $title = NULL) {
    +  $history_read_limit = REQUEST_TIME - \Drupal::config('history.settings')->get('history_mark_read');
    

    REQUEST_TIME is deprecated

YurkinPark’s picture

Errors and notes are fixed, also, i've provided post update to set config for existing instances.

YurkinPark’s picture

Status: Needs work » Needs review
savkaviktor16@gmail.com’s picture

Issue tags: -Needs reroll
andypost’s picture

Status: Needs review » Needs work
Issue tags: +ContributionWeekend2019
+++ b/core/modules/comment/src/CommentManager.php
@@ -77,19 +85,22 @@
+    $this->historyConfig = $config_factory->get('history.settings');

this is wrong - never store config object in protected properties

  1. +++ b/core/modules/comment/src/CommentManager.php
    @@ -57,6 +58,20 @@ class CommentManager implements CommentManagerInterface {
    +  protected $historyConfig;
    
    @@ -70,13 +85,17 @@ class CommentManager implements CommentManagerInterface {
    +    $this->historyConfig = $config_factory->get('history.settings');
    
    @@ -193,7 +212,8 @@ public function getCountNewComments(EntityInterface $entity, $field_name = NULL,
    +      $history_read_limit = $this->time->getRequestTime() - $this->historyConfig->get('history_mark_read');
    
    +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
    @@ -35,6 +37,20 @@ public function usesGroupBy() {
    +   * @var \Drupal\Core\Config\Config|\Drupal\Core\Config\ImmutableConfig
    ...
    +  protected $historyConfig;
    
    @@ -46,18 +62,24 @@ public function usesGroupBy() {
    +    $this->historyConfig = $configFactory->get('history.settings');
    
    @@ -127,14 +149,15 @@ public function preRender(&$values) {
    +      $history_read_limit = $this->time->getRequestTime() - $this->historyConfig->get('history_mark_read');
    

    Do not store config object in protected properties

  2. +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php
    @@ -18,7 +20,43 @@
    +  protected $historyReadLimit;
    
    +++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
    @@ -16,10 +18,44 @@
    +  protected $historyReadLimit;
    

    No reason to store value in protected property

  3. +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php
    @@ -18,7 +20,43 @@
    +      REQUEST_TIME - $container->get('config.factory')->get('history.settings')->get('history_mark_read')
    

    REQUEST_TIME is deprecated

  4. +++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
    @@ -16,10 +18,44 @@
    +
    +  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    

    missing doc block

YurkinPark’s picture

Rerolled and notes are fixed

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

vladbo’s picture

Reroll for 8.8.x

Status: Needs review » Needs work

The last submitted patch, 34: 2006632_34.patch, failed testing. View results

vladbo’s picture

Status: Needs work » Needs review
FileSize
36.85 KB

Fixed tests

Status: Needs review » Needs work

The last submitted patch, 36: 2006632_36.patch, failed testing. View results

vladbo’s picture

Added needed .yml files from #32 and removed irrelevant core update strings from #36.

vladbo’s picture

Status: Needs work » Needs review
joachim’s picture

Status: Needs review » Needs work

Mostly nitpicks:

  1. +++ b/core/modules/comment/src/CommentManager.php
    @@ -116,6 +133,13 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Con
    +    if (!$time) {
    +      @trigger_error('Invoking the CommentManager constructor without the time service parameter is deprecated in drupal:8.8.0 and will no longer be supported in drupal:9.0.0. The time service parameter is now required in the CommentManager constructor. See https://www.drupal.org/node/2785211', E_USER_DEPRECATED);
    +      $time = \Drupal::service('datetime.time');
    +    }
    +    $this->time = $time;
    

    I like this pattern! Is this documented anywhere as a way of adding injected services to something that might be used or subclassed elsewhere? I've create #3062100: document techniques for changing dependency injection in a backwardsly-compatible way to start a discussion about it.

  2. +++ b/core/modules/comment/src/CommentManager.php
    @@ -232,7 +256,10 @@ public function getCountNewComments(EntityInterface $entity, $field_name = NULL,
    +      $historyConfig = $this->configFactory->get('history.settings');
    

    Method vars should be snake case.

  3. +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php
    @@ -163,14 +195,15 @@ public function preRender(&$values) {
    +      $history_read_limit = $this->time->getRequestTime() - $this->configFactory->get('history.settings')->get('history_mark_read');
    

    I feel this line would be more readable if the expressions on the right were assigned to variables.

  4. +++ b/core/modules/history/history.module
    @@ -15,14 +15,6 @@
    -define('HISTORY_READ_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
    

    We need to leave this constant in for BC, as custom code may be making use of it.

    (Though I don't think there's a way to trigger a deprecation warning for a global constant?)

  5. +++ b/core/modules/history/history.post_update.php
    @@ -0,0 +1,13 @@
    + ¶
    

    Whitespace.

  6. +++ b/core/modules/history/src/Plugin/views/field/HistoryUserTimestamp.php
    @@ -92,13 +143,14 @@ public function render(ResultRow $values) {
    +      $history_read_limit = $this->time->getRequestTime() - $this->configFactory->get('history.settings')->get('history_mark_read');
    

    Same here.
    Though on second thoughts, this calculation is repeated at least twice. Could it be moved to a helper method getHistoryReadLimist() on a service somewhere?

andypost’s picture

Fix nits, btw it needs upgrade path tests (config could change in future so this upgrade should add only "read-mark" one)

Mean time it sounds like great candidate to foundation of history.repository service #2081585: [META] Modernize the History module

andypost’s picture

FileSize
7.59 KB
23.78 KB

No reason to prefix config property as it already namespaced

Also it exposed issues in node and comment modules integration (no dependency on history one)

So it needs proper integration a-la
- is service history.repository exists and fall back to old default
- if exists call its method

PS: I think there's no reason to provide UI for this setting so it could be container parameter instead of config, so in rare cases when it needs override it will be overridable with settings.php or services.yml

vladbo’s picture

Seems like good idea. So if I got it right, we need to postpone current issue, re-roll #2081585: [META] Modernize the History module and then move HISTORY_READ_LIMIT to history.repository as container parameter.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

daffie’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/history/config/install/history.settings.yml
    @@ -0,0 +1,5 @@
    +mark_read: 2592000
    
    +++ b/core/modules/history/history.module
    @@ -15,14 +15,6 @@
    -define('HISTORY_READ_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
    

    The new config "mark_read" is in a lot of places directly swapped with the constant HISTORY_READ_LIMIT, only they are not the same.

  2. +++ b/core/modules/history/history.module
    @@ -15,14 +15,6 @@
    -/**
    - * Entities changed before this time are always shown as read.
    - *
    - * Entities changed within this time may be marked as new, updated, or read,
    - * depending on their state for the current user. Defaults to 30 days ago.
    - */
    -define('HISTORY_READ_LIMIT', REQUEST_TIME - 30 * 24 * 60 * 60);
    

    We cannot just remove this constant. It need to be properly deprecated first.

  3. Update test for the new config setting "mark_read"

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.