mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-23 22:39:00 +01:00
* Filemanager/API: automatically decrement and store subquery depth limit, to work around different limits in different MySQL versions and configurations causing SQL error
This commit is contained in:
parent
43ff60d8a4
commit
8196ee6594
@ -1050,6 +1050,12 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
|||||||
*/
|
*/
|
||||||
static function url_stat ( $url, $flags, $eacl_access=null )
|
static function url_stat ( $url, $flags, $eacl_access=null )
|
||||||
{
|
{
|
||||||
|
static $max_subquery_depth;
|
||||||
|
if (is_null($max_subquery_depth))
|
||||||
|
{
|
||||||
|
$max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth'];
|
||||||
|
if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set
|
||||||
|
}
|
||||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)");
|
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)");
|
||||||
|
|
||||||
$path = parse_url($url,PHP_URL_PATH);
|
$path = parse_url($url,PHP_URL_PATH);
|
||||||
@ -1084,6 +1090,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
|||||||
$eacl_access = self::check_extended_acl($path,egw_vfs::READABLE); // should be static::check_extended_acl, but no lsb!
|
$eacl_access = self::check_extended_acl($path,egw_vfs::READABLE); // should be static::check_extended_acl, but no lsb!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
foreach($parts as $n => $name)
|
foreach($parts as $n => $name)
|
||||||
{
|
{
|
||||||
if ($n == 0)
|
if ($n == 0)
|
||||||
@ -1095,8 +1102,8 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
|||||||
// MySQL 5.0 has a nesting limit for subqueries
|
// MySQL 5.0 has a nesting limit for subqueries
|
||||||
// --> we replace the so far cumulated subqueries with their result
|
// --> we replace the so far cumulated subqueries with their result
|
||||||
// no idea about the other DBMS, but this does NOT hurt ...
|
// no idea about the other DBMS, but this does NOT hurt ...
|
||||||
// setting the value to 7, after reports on the user list, thought MySQL 5.0.51 with MyISAM engine works up to 10
|
// --> depth limit of subqueries is now dynamicly decremented in catch
|
||||||
if ($n > 1 && !(($n-1) % 7) && !($query = self::$pdo->query($query)->fetchColumn()))
|
if ($n > 1 && !(($n-1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn()))
|
||||||
{
|
{
|
||||||
if (self::LOG_LEVEL > 1)
|
if (self::LOG_LEVEL > 1)
|
||||||
{
|
{
|
||||||
@ -1139,6 +1146,19 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
|||||||
// we also store negatives (all methods creating new files/dirs have to unset the stat-cache!)
|
// we also store negatives (all methods creating new files/dirs have to unset the stat-cache!)
|
||||||
return self::$stat_cache[$path] = false;
|
return self::$stat_cache[$path] = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (PDOException $e) {
|
||||||
|
// decrement subquery limit by 1 and try again, if not already smaller then 3
|
||||||
|
if ($max_subquery_depth < 3)
|
||||||
|
{
|
||||||
|
throw new egw_exception_db($e->getMessage());
|
||||||
|
}
|
||||||
|
$GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth;
|
||||||
|
error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth");
|
||||||
|
config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi');
|
||||||
|
if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache();
|
||||||
|
return self::url_stat($url, $flags, $eacl_access);
|
||||||
|
}
|
||||||
self::$stat_cache[$path] = $info;
|
self::$stat_cache[$path] = $info;
|
||||||
|
|
||||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags)=".array2string($info));
|
if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags)=".array2string($info));
|
||||||
|
Loading…
Reference in New Issue
Block a user