Skip to content

Commit

Permalink
6.8.35
Browse files Browse the repository at this point in the history
  • Loading branch information
derjoachim committed Feb 19, 2024
2 parents 4422800 + 3d2421b commit 9f6fe03
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 126 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@

-- 6.8 --

19-02-2024: 6.7.68
- Core: fix $config['debug_usernames'] functionality even better!
- Tickets: Fixed scrolling in new ticket message
- Email: Larger add filter window
- Tasks/Core: Bug in copy() function where dates and other objects had reference to the source. This caused the task dates to change on recurrence.
Expand All @@ -284,6 +286,7 @@
- Email / Core : underline html editor toolbar
- Newsletters: test message didn't work with e-mail account
- Email: Sometimes tree could collapse without reason
- Email: Fixed sorting and collapsing of e-mail template groups

12-02-2024: 6.7.67
- Core: fix $config['debug_usernames'] functionality
Expand Down
77 changes: 13 additions & 64 deletions www/go/GO.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,9 @@ public static function classExists($className){

if (($module != 'base' && (!GO::modules()->isInstalled($module) || !GO::modules()->isAvailable($module))) || !class_exists($className)){
return false;
}else
{
} else {
return true;
}
//
// if(class_exists($className)){
//
// $clsParts = explode('\\',$className);
//
// if($clsParts[1] == 'Base' || GO::modules()->isInstalled(strtolower($clsParts[1])))
// return true;
// }
//
// return false;
}

/**
Expand Down Expand Up @@ -230,7 +219,7 @@ public static function getDbConnection(){
* Close the database connection. Beware that all active PDO statements must be set to null too
* in the current scope.
*
* Wierd things happen when using fsockopen. This test case leaves the conneciton open. When removing the fputs call it seems to work.
* Weird things happen when using fsockopen. This test case leaves the conneciton open. When removing the fputs call it seems to work.
*
*
\GO::session()->login('admin','admin');
Expand Down Expand Up @@ -302,7 +291,7 @@ public static function view(){
if(!isset(self::$_view)){
self::$_view = new $class();
}
return self::$_view;//isset(\GO::session()->values['view']) ? \GO::session()->values['view'] : \GO::config()->defaultView;
return self::$_view;
}

public static function setView($viewName){
Expand Down Expand Up @@ -363,20 +352,6 @@ public static function environment() {
*/
public static function modules() {
if (!isset(self::$_modules)) {
// if(\GO::user()){
//
// Caching caused more problems than benefits
//
// if(isset(\GO::session()->values['modulesObject']) && !isset($GLOBALS['GO_CONFIG'])){
// self::$_modules=\GO::session()->values['modulesObject'];
// }else{
// self::$_modules=\GO::session()->values['modulesObject']=new \GO\Base\ModuleCollection();
// }
// }else
// {
// self::$_modules=new \GO\Base\ModuleCollection();
// }

self::$_modules=new \GO\Base\ModuleCollection();
}
return self::$_modules;
Expand Down Expand Up @@ -409,9 +384,9 @@ public static function cache(){
if (!isset(self::$_cache)) {
if(!GO::isInstalled()){
self::$_cache=new \GO\Base\Cache\None();
}else{
self::$_cache = new \GO\Base\Cache\Apcu();
}
}else{
self::$_cache = new \GO\Base\Cache\Apcu();
}
}
return self::$_cache;
}
Expand All @@ -436,8 +411,6 @@ public static function config() {

if(isset($cacheKey)) {
self::$_config->cacheTime = time();

//apcu_store($cacheKey, self::$_config);
}

if(!empty(GO::session()->values['debug'])) {
Expand Down Expand Up @@ -465,20 +438,14 @@ public static function session() {
*/
public static function autoload($className) {

//for namespaces
// $className = str_replace('\\', '_', $className);

//Sometimes there's a leading \ in the $className and sometimes not.
//Might not be true for all php versions.
$className = ltrim($className, '\\');

if(isset(self::$_classes[$className])){
//don't use \GO::config()->root_path here because it might not be autoloaded yet causing an infite loop.
require(dirname(dirname(__FILE__)) . '/'.self::$_classes[$className]);
}else
{
// echo "Autoloading: ".$className."\n";

} else {
$filePath = false;

if(substr($className,0,7)=='GO\\Base'){
Expand All @@ -500,7 +467,6 @@ public static function autoload($className) {
$filePath = \GO::config()->file_storage_path.'php/'.$location;

} else {
//$orgClassName = $className;
$forGO = substr($className,0,3)=='GO\\';

if ($forGO)
Expand Down Expand Up @@ -567,12 +533,6 @@ public static function init() {
}
self::$initialized=true;

//register our custom error handler here
// set_error_handler(array('GO','errorHandler'));
// register_shutdown_function(array('GO','shutdown'));

// spl_autoload_register(array('GO', 'autoload'));

//Start session here. Important that it's called before \GO::config().
\GO::session();

Expand Down Expand Up @@ -748,8 +708,7 @@ public static function errorHandler($errno, $errstr, $errfile, $errline) {
$errorMsg .= "----------------";

\GO::debug($errorMsg);
// \GO::logError($errorMsg);


foreach(self::$_errorLogCallbacks as $callback){
call_user_func($callback, $errorMsg);
}
Expand Down Expand Up @@ -843,7 +802,7 @@ public static function debugPageLoadTime($id){
\GO::debug("Script running at [$id] for ".$time."ms");
}
/**
* Write's to a debug log.
* Writes to a debug log.
*
* @param string $text log entry
*/
Expand Down Expand Up @@ -937,12 +896,7 @@ public static function memdiff() {
* @return \GO\Base\Db\ActiveRecord
*/
public static function getModel($modelName){
//$modelName::model() does not work on php 5.2! That's why we use this function.

//backwards compat
//$modelName = str_replace('_','\\', $modelName);

if(!class_exists($modelName)){
if(!class_exists($modelName)){

$entityType = \go\core\orm\EntityType::findByName($modelName);

Expand All @@ -951,8 +905,7 @@ public static function getModel($modelName){
}

$modelName = $entityType->getClassName();
//return $modelName;
}
}



Expand All @@ -975,8 +928,6 @@ public static function getModel($modelName){
*/
public static function createExternalUrl($module, $function, $params,$toLoginDialog=false)
{
//$p = 'm='.urlencode($module).'&f='.urlencode($function).'&p='.urlencode(base64_encode(json_encode($params)));

if(\GO::config()->debug){
if(!preg_match('/[a-z]+/', $module))
throw new \Exception('$module param may only contain a-z characters.');
Expand Down Expand Up @@ -1026,8 +977,7 @@ public static function url($path='', $params=array(), $relative=true, $htmlspeci

if(empty($path)){
$amp = 'index.php?';
}else
{
}else {
$url .= 'index.php?r='.$path;

$amp = $htmlspecialchars ? '&' : '&';
Expand All @@ -1040,8 +990,7 @@ public static function url($path='', $params=array(), $relative=true, $htmlspeci

$amp = $htmlspecialchars ? '&' : '&';
}
}else
{
} else {
$url .= $amp.$params;
}
}
Expand Down
35 changes: 16 additions & 19 deletions www/go/base/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,9 @@ private function _unsetRemindLoginCookies(){
* @access public
* @return void
*/
public function logout() {

// $username = isset(self::$username) ? self::$username : 'notloggedin';
$username = \GO::user() ? \GO::user()->username : self::USERNAME_NOTLOGGEDIN;
public function logout()
{
$username = \GO::user() ? \GO::user()->username : self::USERNAME_NOTLOGGEDIN;

\GO::debug("Logout called for ".$username);

Expand Down Expand Up @@ -428,27 +427,25 @@ public function runAs($id){
* @param int/Model\User $user_id
* @param int $originalUserId Remember the original user
*/
public function setCurrentUser($user_id, $originalUserId=false) {

// if(\GO::modules()->isInstalled("log"))
// \GO\Log\Model\Log::create ("setcurrentuser", "Set user ID to $user_id");
public function setCurrentUser($user_id, $originalUserId=false)
{
if(!empty($originalUserId)){
$this->values['original_user_id'] = $originalUserId;
}

if($user_id instanceof Model\User){
$this->_user=$user_id;
$this->values['user_id']=$user_id->id;
}else
{
} else {
//remember user id in session
$this->values['user_id']=$user_id;
}



if(!\GO::user())
throw new \Exception("Could not set user with id ".$user_id." in Session::setCurrentUser()!");
if(!\GO::user()) {
throw new \Exception("Could not set user with id " . $user_id . " in Session::setCurrentUser()!");
}

date_default_timezone_set(\GO::user()->timezone);

Expand All @@ -457,13 +454,13 @@ public function setCurrentUser($user_id, $originalUserId=false) {
//for logging
\GO::session()->values['username']=\GO::user()->username;

if(isset(\GO::session()->values['accessToken'])) {
$token = \go\core\model\Token::find()->where(['accessToken' => \GO::session()->values['accessToken']])->single();
$token->userId = $user_id;
if(!$token->save()) {
throw new \Exception("Could not set token");
}
}
if(isset(\GO::session()->values['accessToken'])) {
$token = \go\core\model\Token::find()->where(['accessToken' => \GO::session()->values['accessToken']])->single();
$token->userId = $user_id;
if(!$token->save()) {
throw new \Exception("Could not set token");
}
}

if (!empty(\GO::config()->debug_usernames)) {
if (in_array(\GO::user()->username, \GO::config()->debug_usernames)){
Expand Down
32 changes: 4 additions & 28 deletions www/go/core/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,9 @@ public function __construct() {
if(!empty(go()->getConfig()['debug'])) {
$this->enable(go()->getConfig()['debug_log']);
} else if(!$this->enabled && !empty(go()->getConfig()['debug_usernames']) && is_array(go()->getConfig()['debug_usernames'])) {
if($a = go()->getAuthState()) {
if( method_exists($a, "hasToken") && !$a->hasToken()) {
return;
}
$userId = $a->getUserId();
$stmt = go()->getDbConnection()->getPDO()
->prepare('SELECT `username` FROM `core_user` WHERE `id`=:id');
$stmt->bindParam(':id', $userId);
$stmt->execute();
while ($user = $stmt->fetch(\PDO::FETCH_OBJ)) {
if(in_array($user->username, go()->getConfig()['debug_usernames'])) {
$this->enable(go()->getConfig()['debug_log']);
break;
}
}
if(go()->getAuthState() && ($user = go()->getAuthState()->getUser(['username'])) && in_array($user->username, go()->getConfig()['debug_usernames'])) {
$this->enable(go()->getConfig()['debug_log']);
}
// This will trigger an infinite loop
// if(go()->getAuthState() && ($user = go()->getAuthState()->getUser(['username'])) && in_array($user->username, go()->getConfig()['debug_usernames'])) {
// $this->enable(go()->getConfig()['debug_log']);
// }
}
}

Expand Down Expand Up @@ -162,8 +145,6 @@ public function getMicroTime() : float {
if(!$this->enabled) {
return 0;
}
// list ($usec, $sec) = explode(" ", microtime());
// return ((float) $usec + (float) $sec);
return microtime(true);
}

Expand Down Expand Up @@ -209,13 +190,9 @@ private function internalLog($mixed, string $level = self::LEVEL_LOG, $traceBack
}elseif(is_object($mixed) && method_exists($mixed, '__toString')) {
$mixed = (string) $mixed;
}
// elseif (!is_scalar($mixed)) {
// $mixed = print_r($mixed, true);
// }


$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 7 + $traceBackSteps);

// var_dump($bt);
$lastCaller = null;
$caller = array_shift($bt);
//can be called with \go\core\App::get()->debug(). We need to go one step back (no class for closure)
Expand All @@ -242,7 +219,6 @@ private function internalLog($mixed, string $level = self::LEVEL_LOG, $traceBack
$lastCaller['line'] = '[unknown line]';
}

//$entry = "[" . $this->getTimeStamp() . "][" . $caller['class'] . ":".$lastCaller['line']."] " . $mixed;
if($writeFile) {
$this->writeLog($level, $mixed, $caller['class'], $lastCaller['line']);
}
Expand Down Expand Up @@ -326,7 +302,7 @@ public function debugTiming(string $message) {
}

/**
* Get the ellapsed time since the start of the request in milliseconds
* Get the elapsed time since the start of the request in milliseconds
*
* @return float milliseconds
*/
Expand Down
2 changes: 1 addition & 1 deletion www/go/core/db/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function internalWhere($condition, $comparisonOperator, $value, $logic
{
if(is_array($condition)) {

if(go()->getDebugger()->enabled && empty($condition)) {
if(empty($condition) && go()->getDebugger()->enabled) {
throw new LogicException("You can't pass an empty array as first where() argument");
}

Expand Down
3 changes: 1 addition & 2 deletions www/go/core/jmap/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use go\core\model\Token;
use go\core\auth\State as AbstractState;
use go\core\model\User;
use PDO;
use stdClass;

class State extends AbstractState {
Expand Down Expand Up @@ -127,7 +126,7 @@ public function getToken() {

if(!$this->token) {
return false;
}
}

if($this->token->isExpired()) {
try {
Expand Down
2 changes: 0 additions & 2 deletions www/go/core/orm/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ public final function save(): bool

$this->isSaving = true;

// go()->debug(static::class.'::save()' . $this->id());
App::get()->getDbConnection()->beginTransaction();

try {
Expand Down Expand Up @@ -550,7 +549,6 @@ protected function commit(): bool
return false;
}

//$this->isDeleting = false;
$this->isSaving = false;

return true;
Expand Down
Loading

0 comments on commit 9f6fe03

Please sign in to comment.