Permalink
Browse files

Improvements on stack tracing in exceptions, caching and downloader.

  • Loading branch information...
1 parent 86b4461 commit 10e852e952dbd5adc86097cf6e416bcebba76837 @Artazor Artazor committed May 11, 2012
@@ -10,6 +10,7 @@
public abstract function storeAll($key, $array);
public abstract function serialize($key, $value);
public abstract function deserialize($key);
+ public abstract function age($key);
public function offsetGet($key){
return $this->load($key);
@@ -18,16 +18,24 @@ public function __complete() {
}
}
+ public function age($key) {
+ $path = $this->getPath($key);
+ return file_exists($path)
+ ? time() - filemtime($path)
+ : 0x7FFFFFFF
+ ;
+ }
+
public function getPath($key) {
$hash = md5($key);
- $path = $this->temp_path
- . DIRECTORY_SEPARATOR
+ $path = $this->temp_path
+ . DIRECTORY_SEPARATOR
. Oxygen_Utils_Text::format(self::FILE_TEMPLATE,$hash)
;
return $path;
}
- // Loads given key. In case of nonexistent key
+ // Loads given key. In case of nonexistent key
// throws an exception unless optional second parameter is given
// (which is returned instead)
public function load($key) {
@@ -41,8 +49,8 @@ public function load($key) {
}
return file_get_contents($path);
}
-
- // Deserializes given key. In case of nonexistent key
+
+ // Deserializes given key. In case of nonexistent key
// throws an exception unless optional second parameter is given
// (which is returned instead)
public function deserialize($key) {
@@ -56,7 +64,7 @@ public function deserialize($key) {
}
return unserialize(file_get_contents($path));
}
-
+
public function serialize($key, $value) {
$this->store($key,serialize($value));
}
@@ -77,7 +85,7 @@ public function storeAll($key,$array) {
throw $ex;
}
}
-
+
public function echoValue($key) {
readfile($this->getPath($key));
}
@@ -102,7 +110,7 @@ public function exists($offset) {
}
public function remove($offset) {
- unlink($offset);
+ unlink($this->getPath($offset));
}
}
@@ -134,7 +134,8 @@ img.controller-icon {
}
.trans(@seconds: 0.3s) {
- -moz-transition: @seconds;
+ -webkit-transition: @seconds;
+ -moz-transition: @seconds;
}
a.oxygen-tile {
@@ -251,7 +252,7 @@ div.oxy-content {
width: 85%;
float:left;
background-color: white;
- box-shadow:inset 0px 0px 2px #666;
+ box-shadow:inset 0px 0px 2px #666;
line-height: 1.4em;
}
@@ -260,7 +261,7 @@ a:active {
}
-div.oxy-header {
+div.oxy-header {
ul.bread-crumbs {
float:left;
@@ -306,7 +307,7 @@ div.oxy-header {
background-repeat: no-repeat;
background-position: center;
float:left;
- }
+ }
h1 {
color: white;
font-size: 17px;
@@ -28,7 +28,7 @@ public function get($url,$params = array()) {
if (preg_match("/\?/",$url)) {
$url .= '&';
} else {
- $url .= '?';
+ $url .= '?';
}
$url .= http_build_query($params);
@@ -43,6 +43,16 @@ public function get($url,$params = array()) {
return $result;
}
+ public function getSimpleXML($url, $params = array()) {
+ $result = trim($this->get($url, $params));
+ $result = new SimpleXMLElement($result);
+ $this->__assert(
+ $result !== false,
+ 'INVALID XML'
+ );
+ return $result;
+ }
+
public function getJSON($url, $params = array()) {
$result = trim($this->get($url, $params));
$result = json_decode($result);
@@ -1,5 +1,14 @@
<table class="trace">
-<?foreach($this->getWrapTrace() as $t):?><?$t=(object)$t?>
+<?$trace=$this->getWrapTrace()?>
+<?if($trace[6]['function'] ==='__assert' && !$trace[6]['args'][0]):?>
+<?$countdown=8?>
+<?endif?>
+<?foreach($trace as $n=>$t):?><?$t=(object)$t?>
+<?if(--$countdown>0)continue?>
+<?if(preg_match("/^(get|put|throw|new)_$/", $t->function) && $trace[$n+1]['function']=='__call'):?>
+<?continue?>
+<?endif?>
+<?if($t->function=='__call')continue?>
<tr>
<td><?if(isset($t->class)):?><?=$t->class?><?=$t->type?><?=$t->function?>()<?else:?><?=$t->function?>()<?endif?></td>
<td><?if(isset($t->file)):?> in <?=$t->file?><?else:?>no-file<?endif?>
View
@@ -7,7 +7,6 @@
font-family:Verdana;
font-size:0.6em;
- background-image: virtual(url(a/test.png/test));
.details {
color:#800000;
@@ -25,7 +24,7 @@
tr {
cursor: default;
&:hover {
- background-color:#FFFCF0;
+ background-color:#FFFCF0;
}
}
td {
@@ -38,7 +37,7 @@
color: #C00000;
}
}
- }
+ }
ul.arguments {
list-style: none;
li.complex-argument {
View
@@ -12,7 +12,6 @@
define('OXYGEN_XML_RESPONSE',4);
define('OXYGEN_REDIRECT_RESPONSE',5);
-
function jsonResponse($data, $headers = array()) {
return array(
'header' => 'Content-Type: application/json; Charset=UTF-8',
@@ -84,7 +83,7 @@ function handleHttpRequest($scope, $root, $model = false, $debug = true) {
$userScope = $scope->Scope();
$root = $userScope->$root($model);
$scope->httpStatus = 200;
- $scope->httpHeaders = array();
+ $scope->httpHeaders = array();
$root->setPath($scope->OXYGEN_ROOT_URI);
$last = $root[$scope->OXYGEN_PATH_INFO];
$result = $last->handleRequest();
@@ -117,10 +116,10 @@ function handleHttpRequest($scope, $root, $model = false, $debug = true) {
}
}
}
-
+
return Oxygen_Scope::newRoot(dirname(dirname(__FILE__)));
-
+
?>
@@ -20,6 +20,9 @@ class Oxygen_Object {
private $stack = array();
public function __call($method, $args) {
+ if($method=='download'){
+ echo 'HERE';
+ }
$this->__assert(
preg_match(self::CALL_REGEXP, $method, $match),
self::UNKNOWN_METHOD,
@@ -28,6 +31,9 @@ public function __call($method, $args) {
);
$class = get_class($this);
if ($match[1] !== '') $class = get_parent_class($this);
+ if(!is_string($match[2])){
+ echo 'HERE';
+ }
return $this->{$match[2]}($match[3],$args);
}
@@ -127,7 +127,7 @@ public function __call($name, $args) {
// Wraps given $exception into Oxygen_Exception_Wrapper
// unless $exception is instance of Oxygen_Excpeion itself
public function __wrapException($exception) {
- if ($exception instanceof Oxygen_Excpeion) {
+ if ($exception instanceof Oxygen_Exception) {
return $exception;
} else {
return $this->ExceptionWrapper($exception);

0 comments on commit 10e852e

Please sign in to comment.