fixed endless loop in entry overview; fixed PHP warning

This commit is contained in:
azett 2022-10-11 13:43:19 +02:00
parent 227b4d30d8
commit 80abe0a55d
3 changed files with 31 additions and 64 deletions

View File

@ -7,14 +7,11 @@
<div id="admin-drafts"> <div id="admin-drafts">
<p>Your drafts:</p> <p>Your drafts:</p>
<ul> <ul>
{foreach from=$draft_list key=draftid item=draft}
{draft} <li>
<li> <a href="admin.php?p=entry&amp;entry={$draftid}&amp;action=write">{$draft|truncate:50}</a>
<a href="admin.php?p=entry&amp;entry={$id}&amp;action=write">{$subject|truncate:70}</a> </li>
{/foreach}
</li>
{/draft}
</ul> </ul>
</div> </div>

View File

@ -168,36 +168,6 @@ function smarty_block_draftlist($params, $content, &$smarty, &$repeat) {
} }
} }
function smarty_block_draft($params, $content, &$smarty, &$repeat) {
$smarty->assign(array(
'subject' => '',
'content' => '',
'date' => '',
'author' => '',
'version' => '',
'id' => ''
));
$arr = $smarty->getTemplateVars('draft_list');
$id = $subject = null;
if ($arr) {
$firstElement = utils_array_kshift($arr);
$id = array_keys($firstElement);
$id = $id [0];
$subject = $firstElement [$id];
}
if ($id) {
$smarty->assign('subject', $subject);
$smarty->assign('id', $id);
}
$repeat = (bool) $id;
return $content;
}
$smarty->registerPlugin('block', 'draft_block', 'smarty_block_draftlist'); $smarty->registerPlugin('block', 'draft_block', 'smarty_block_draftlist');
$smarty->registerPlugin('block', 'draft', 'smarty_block_draft');
?> ?>

View File

@ -170,7 +170,7 @@ class FPDB_Query {
$this->single = true; $this->single = true;
} }
$GLOBALS ['current_query'] = & $this; $GLOBALS ['current_query'] = &$this;
} }
function prepare() { function prepare() {
@ -178,8 +178,8 @@ class FPDB_Query {
$fpdb->init(); $fpdb->init();
$this->main_idx = & $fpdb->get_index($this->params->category); $this->main_idx = &$fpdb->get_index($this->params->category);
$entry_index = & $this->main_idx; $entry_index = &$this->main_idx;
$this->counter++; $this->counter++;
@ -199,9 +199,9 @@ class FPDB_Query {
$this->_prepare_list($entry_index); $this->_prepare_list($entry_index);
if ($this->params->exclude) { if ($this->params->exclude) {
$o = & $fpdb->get_index($this->params->exclude); $o = &$fpdb->get_index($this->params->exclude);
if ($o !== false) if ($o !== false)
$this->secondary_idx = & $o; $this->secondary_idx = &$o;
} }
} }
@ -217,7 +217,7 @@ class FPDB_Query {
if (!$this->params->id) if (!$this->params->id)
trigger_error("FPDB: no ID found for query {$this->ID}", E_USER_ERROR); trigger_error("FPDB: no ID found for query {$this->ID}", E_USER_ERROR);
$qp = & $this->params; $qp = &$this->params;
$time = entry_idtotime($qp->id); $time = entry_idtotime($qp->id);
@ -240,7 +240,7 @@ class FPDB_Query {
// i.e. includes the first key $newkey such as $newkey <= $prevkey // i.e. includes the first key $newkey such as $newkey <= $prevkey
// also, if $prevkey != $newkey then $prevkey := $newkey // also, if $prevkey != $newkey then $prevkey := $newkey
$this->walker = & $entry_index->walker($prevkey, 2, null, null); $this->walker = &$entry_index->walker($prevkey, 2, null, null);
// since we're searching for $prevkey, i.e. a key preceding the target $id // since we're searching for $prevkey, i.e. a key preceding the target $id
// in the sequence, if $prevkey becomes equal to $key then it means // in the sequence, if $prevkey becomes equal to $key then it means
@ -269,7 +269,7 @@ class FPDB_Query {
} }
function _prepare_list(&$entry_index) { function _prepare_list(&$entry_index) {
$qp = & $this->params; $qp = &$this->params;
$entry_num = 0; $entry_num = 0;
@ -280,7 +280,7 @@ class FPDB_Query {
$firstid = null; $firstid = null;
$index_count = $entry_index->length(); $index_count = $entry_index->length();
$this->walker = & $entry_index->walker($firstid); $this->walker = &$entry_index->walker($firstid);
} else { } else {
// notice this won't work with cats (for now) // notice this won't work with cats (for now)
@ -311,7 +311,7 @@ class FPDB_Query {
// not so great implementation... doesn't work well // not so great implementation... doesn't work well
function _get_random_id(&$entry_index) { function _get_random_id(&$entry_index) {
$qp = & $this->params; $qp = &$this->params;
$now = time(); $now = time();
$first = '999999999999'; $first = '999999999999';
@ -332,7 +332,7 @@ class FPDB_Query {
/* reading functions */ /* reading functions */
function hasMore() { function hasMore() {
$GLOBALS ['current_query'] = & $this; $GLOBALS ['current_query'] = &$this;
// if system init has not been done (filling pointer variable etc.) // if system init has not been done (filling pointer variable etc.)
// call prepare() // call prepare()
@ -348,7 +348,7 @@ class FPDB_Query {
function &peekEntry() { function &peekEntry() {
global $post; global $post;
$qp = & $this->params; $qp = &$this->params;
$return = array( $return = array(
false, false,
false false
@ -475,7 +475,7 @@ class FPDB_Query {
if (!$this->hasMore()) if (!$this->hasMore())
return false; return false;
$var = & $this->peekEntry(); $var = &$this->peekEntry();
$this->lastentry = $var; $this->lastentry = $var;
$this->walker->next(); $this->walker->next();
@ -543,7 +543,7 @@ class FPDB_Query {
if ($this->params->page) { if ($this->params->page) {
// if ($this->_getOffsetId(0, ($this->params->start + $this->params->count))) // if ($this->_getOffsetId(0, ($this->params->start + $this->params->count)))
if ($this->walker->valid) if ($this->walker && $this->walker->valid)
return array( return array(
$GLOBALS ['lang'] ['main'] ['nextpage'], $GLOBALS ['lang'] ['main'] ['nextpage'],
$this->params->page + 1 $this->params->page + 1
@ -648,7 +648,7 @@ class FPDB {
function &get_index($cat_id = 0) { function &get_index($cat_id = 0) {
if (!isset($this->_indexer [$cat_id])) { if (!isset($this->_indexer [$cat_id])) {
$this->_indexer [$cat_id] = & entry_cached_index($cat_id); $this->_indexer [$cat_id] = &entry_cached_index($cat_id);
} }
return $this->_indexer [$cat_id]; return $this->_indexer [$cat_id];
} }
@ -720,7 +720,7 @@ class FPDB {
function doquery($queryId = 0) { function doquery($queryId = 0) {
if (isset($this->queries [$queryId])) { if (isset($this->queries [$queryId])) {
$q = & $this->queries [$queryId]; $q = &$this->queries [$queryId];
} else { } else {
return false; return false;
trigger_error("FPDB: no such query ID ($queryId)", E_USER_WARNING); trigger_error("FPDB: no such query ID ($queryId)", E_USER_WARNING);
@ -742,7 +742,7 @@ class FPDB {
function &getQuery($queryId = 0) { function &getQuery($queryId = 0) {
$o = null; $o = null;
if (isset($this->queries [$queryId])) if (isset($this->queries [$queryId]))
$o = & $this->queries [$queryId]; $o = &$this->queries [$queryId];
return $o; return $o;
} }
@ -824,14 +824,14 @@ function smarty_block_entry($params, $content, &$smarty, &$repeat) {
return $content; return $content;
} }
$q = & $fpdb->getQuery(); $q = &$fpdb->getQuery();
if ($repeat = $q->hasMore()) { if ($repeat = $q->hasMore()) {
$couplet = & $q->getEntry(); $couplet = &$q->getEntry();
$id = & $couplet [0]; $id = &$couplet [0];
$entry = & $couplet [1]; $entry = &$couplet [1];
if (THEME_LEGACY_MODE) { if (THEME_LEGACY_MODE) {
$entry = theme_entry_filters($entry, $id); $entry = theme_entry_filters($entry, $id);
@ -869,14 +869,14 @@ function smarty_block_comment($params, $content, &$smarty, &$repeat) {
'loggedin' => '' 'loggedin' => ''
)); ));
$q = & $fpdb->getQuery(); $q = &$fpdb->getQuery();
if ($repeat = $q->comments->hasMore()) { if ($repeat = $q->comments->hasMore()) {
$couplet = & $q->comments->getComment(); $couplet = &$q->comments->getComment();
$id = & $couplet [0]; $id = &$couplet [0];
$comment = & $couplet [1]; $comment = &$couplet [1];
foreach ($comment as $k => $v) { foreach ($comment as $k => $v) {
$kk = str_replace('-', '_', $k); $kk = str_replace('-', '_', $k);
@ -896,7 +896,7 @@ function smarty_block_comment($params, $content, &$smarty, &$repeat) {
function smarty_block_comments($params, $content, &$smarty, &$repeat) { function smarty_block_comments($params, $content, &$smarty, &$repeat) {
global $fpdb; global $fpdb;
$q = & $fpdb->getQuery(); $q = &$fpdb->getQuery();
$show = $q->comments->getCount(); $show = $q->comments->getCount();
$smarty->assign('entryid', $q->comments->entryid); $smarty->assign('entryid', $q->comments->entryid);