merge -r 2094 from branch-1_7 to trunk
- fix: quick search error if the query term contained " or ' - optimized sql query in sync_users (called every time on admin page) - a lot faster when #user_cache_categories is big - added function Template->delete_block_vars (opposite of assign_block_vars) git-svn-id: http://piwigo.org/svn/trunk@2095 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
b2c5c04c6a
commit
131cf74ba4
4 changed files with 42 additions and 5 deletions
|
|
@ -1159,7 +1159,7 @@ SELECT user_id
|
|||
foreach ($tables as $table)
|
||||
{
|
||||
$query = '
|
||||
SELECT user_id
|
||||
SELECT DISTINCT user_id
|
||||
FROM '.$table.'
|
||||
;';
|
||||
$to_delete = array_diff(
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ if (count($categories) > 0)
|
|||
}
|
||||
|
||||
$template->assign_var_from_handle('CATEGORIES', 'thumbnails');
|
||||
unset( $template->_tpldata['thumbnails.'] );//maybe write a func for that
|
||||
$template->delete_block_vars('thumbnails', true); // category_default reuse them
|
||||
}
|
||||
trigger_action('loc_end_index_category_thumbnails', $categories);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,6 +295,43 @@ class Template {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Block-level variable deletion. Deletes the last block iteration.
|
||||
* if all is true - all blocks are removed
|
||||
* return true if a deletion occured
|
||||
*/
|
||||
function delete_block_vars($blockname, $all=false)
|
||||
{
|
||||
$blocks = explode('.', $blockname);
|
||||
$blockcount = count($blocks);
|
||||
$str = '$this->_tpldata';
|
||||
for ($i = 0; $i < $blockcount; $i++)
|
||||
{
|
||||
$str .= '[\'' . $blocks[$i] . '.\']';
|
||||
eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:-1;');
|
||||
if ($lastiteration==-1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ($i==$blockcount-1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
$str .= '[' . $lastiteration . ']';
|
||||
}
|
||||
|
||||
if ($all==true or $lastiteration==0)
|
||||
{
|
||||
$str ='unset('.$str.');';
|
||||
}
|
||||
else
|
||||
{
|
||||
$str ='unset('.$str.'['.$lastiteration.']);';
|
||||
}
|
||||
eval($str);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Root-level variable assignment. Adds to current assignments, overriding
|
||||
* any existing variable assignment with the same name.
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ $query ='
|
|||
INSERT INTO '.SEARCH_TABLE.'
|
||||
(rules, last_seen)
|
||||
VALUES
|
||||
(\''.serialize($search).'\', NOW() )
|
||||
(\''.addslashes(serialize($search)).'\', NOW() )
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue