欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

The content access permissions have not been properly rebuilt 内容访问权限没有正确地重建。重构权限 终于解决重构权限的问题了 有大用 有大用 有大用

shiping1 的头像

重构权限路径  重建内容访问权限。
最好 先 清空缓存 然后 cron 一下(应该是最好不要cron)


实不不行的话 用 view own 模块吧 view own 模块 也可以设置任何内容类型的 view own 内容类型view any 内容类型 我怎么搞了不起作用

RESOLVED: "Rebuilding content access permissions" hangs 错误 error drupal 6 rebuild permissions an http error 0 occurred


奇怪 第一天重构失败 第二天重构就好了 难道不能开 vpn?

看到了 好像是网络超时 (开了vpn更会网络超时)就是某个 ajax 请求的时间太长,网络断开,所以无法重建

还是通过  
 drush php-eval 'node_access_rebuild();' 来执行重构权限 重建权限

如果这里使用 drush 还超时的话( PHP Fatal error:  Maximum execution time of 240 seconds exceeded in /var/wwwroot/aaaaa/public_html/includes/database.mysqli.inc on line 155

Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Maximum execution time of 240 seconds exceeded in
/var/wwwroot/aaaaa//public_html/includes/database.mysqli.inc,
line 155  )


就到本页的最下面 看看解决的办法

 

admin/content/node-settings

重构权限的路径是 admin/content/node-settings/rebuild

做到以下四步 重构权限好了

1) 清空所有缓存 但是不 cron

2)setting.php  中 只留下 $db_url['default'] ;;其余的连数数据库的 $db_url删掉

3)
setting.php 中  $cookie_domain = 'example.com';  的注释去掉 改成 $cookie_domain = '.kfqddd.com';

4)在夜里弄.因为没有人访问页面

5)phpmyadmin中修复表

原因排查 
发现是 执行的 batch?id=62&op=finished 失败
在  node.module的2412行左右发现报  
 drupal_set_message(t('The content access permissions have not been properly rebuilt.'), 'error');

在数据据中 找 batch 表 
在 system.module 的 约 513行   'page callback' => 'system_batch_page',
找到system.admin.inc 约 1827行  function system_batch_page() {
约 1829行  $output = _batch_page();
在 includes/batch.inc 的 11 行 function _batch_page() {
43行 $output = _batch_finished();
最重要的 302行 $batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations']);

$batch_set['success'] 为 false 时,说明重构失败 
$batch_set['success'] 为 true 时,说明重构成功
但是  
$batch_set['success'] 的值 是如何获取 在哪里设置的呢?


Drupal 解决不能重建权限问题(Rebuilding content access permissions)

如题,打开
/modules/node/node.module
找到:

function node_access_rebuild($batch_mode = FALSE) {
........
-if ($batch_mode) {
+if(FALSE){
........
}
其中+表示增加一行,-表示删除一行。Drupal 解决不能重新生成权限问题(Rebuilding content access permissions)

我的情况下,点击重建权限,一直显示在33%的位置不动了。上面这个方法是我在drupal论坛中看到了,特此转载一下。

来自 http://www.lamp99.com/drupal-can-not-rebuilding-content-access-permissions.html






通过drush 执行的另一种方法 本质上还是执行

 
 drush php-eval 'node_access_rebuild();'
但是解决了
执行时间超时的问题

下面是drupal6的版本


rebuild-perms.php


<?php
/**
* @file
* Rebuild the node access database with no php time limits.
*/

/**
* Rebuilds the node access database (for use with drush php-script).
*
* This is code borrowed from Drupal core and slightly modified to run with
* drush.
*
* @see node_access_rebuild()
*/
function node_access_rebuild_drush($batch_mode = FALSE) {
  db_query("DELETE FROM {node_access}");
  // Only recalculate if the site is using a node_access module.
  if (count(module_implements('node_grants'))) {

    if ($batch_mode) {
//    if(FALSE) {
      $batch = array(
          'title' => t('Rebuilding content access permissions'),
          'operations' => array(
              array('_node_access_rebuild_batch_operation', array()),
          ),
          'finished' => '_node_access_rebuild_batch_finished'
      );
      batch_set($batch);
    }
    else {
      // Try to allocate enough time to rebuild node grants
      if (function_exists('set_time_limit')) {
        @set_time_limit(0);//其实是修改的这一行
      }
      $result = db_query("SELECT nid FROM {node}");
      while ($node = db_fetch_object($result)) {
        $loaded_node = node_load($node->nid, NULL, TRUE);
        // To preserve database integrity, only aquire grants if the node
        // loads successfully.
        if (!empty($loaded_node)) {
          node_access_acquire_grants($loaded_node);
        }
      }
    }
  }
  else {
    // Not using any node_access modules. Add the default grant.
    db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)");
  }

  if (!isset($batch)) {
    drupal_set_message(t('Content permissions have been rebuilt.'));
    node_access_needs_rebuild(FALSE);
    cache_clear_all();
  }
}

// Start node access rebuild process.
node_access_rebuild_drush();

?>


执行 time drush php-script rebuild-perms.php  这个drush命令






下面是 drupal7 的版本

Instantly share code, notes, and snippets.
Rebuild permissions for running via Drush (no batch process)
 <?php
  
 /**
 * @file
 * Rebuild the node access database with no php time limits.
 */
  
 /**
 * Rebuilds the node access database (for use with drush php-script).
 *
 * This is code borrowed from Drupal core and slightly modified to run with
 * drush.
 *
 * @see node_access_rebuild()
 */
 function node_access_rebuild_drush() {
 db_delete('node_access')->execute();
 // Only recalculate if the site is using a node_access module.
 if (count(module_implements('node_grants'))) {
 // Try to allocate enough time to rebuild node grants.
 drupal_set_time_limit(0);//应该是修改的这一行
  
 $nids = db_query("SELECT nid FROM {node}")->fetchCol();
 foreach ($nids as $nid) {
 $node = node_load($nid, NULL, TRUE);
 // To preserve database integrity, only acquire grants if the node
 // loads successfully.
 if (!empty($node)) {
 node_access_acquire_grants($node);
 }
 }
 }
 else {
 // Not using any node_access modules. Add the default grant.
 db_insert('node_access')
 ->fields(array(
 'nid' => 0,
 'realm' => 'all',
 'gid' => 0,
 'grant_view' => 1,
 'grant_update' => 0,
 'grant_delete' => 0,
 ))
 ->execute();
 }
  
 drupal_set_message(t('Content permissions have been rebuilt.'));
 node_access_needs_rebuild(FALSE);
 cache_clear_all();
 }
  
 // Start node access rebuild process.
 node_access_rebuild_drush();
@deekayen
 

shrop said to run it like this:

time drush php-script rebuild-perms.php



来自 https://gist.github.com/shrop/67720ffece47c18575ef


普通分类: