22 Commits

Author SHA1 Message Date
42ade08306 Pagination fix 2024-08-21 06:12:54 -04:00
464201cf17 Merge remote-tracking branch 'origin/update_PHP_deps_20240820103119' 2024-08-20 06:31:54 -04:00
983f6ed624 Update PHP dependencies [20240820103119] 2024-08-20 10:31:21 +00:00
8cd7a6ebbc bugfixes + moving customException to canary 2024-08-20 06:25:36 -04:00
ef4818356c Pagination bugfix 2024-08-13 02:35:11 -04:00
85ed1def88 session bugfixes 2024-08-13 02:25:11 -04:00
7228e530b8 bugfix for pagination 2024-08-13 01:16:12 -04:00
92c057ad26 Merge remote-tracking branch 'origin/update_PHP_deps_20240813035025' 2024-08-12 23:53:07 -04:00
feea409ac7 Update PHP dependencies [20240813035025] 2024-08-13 03:50:27 +00:00
7518461cb9 prevent runaway 2024-08-12 23:39:43 -04:00
233565dcd2 Merge remote-tracking branch 'origin/update_PHP_deps_20240813033415' 2024-08-12 23:39:32 -04:00
bfd23ecfe1 Update PHP dependencies [20240813033415] 2024-08-13 03:34:17 +00:00
67f5dabfa6 prevent runaway dependency branching 2024-08-12 23:31:15 -04:00
1f720693d1 Merge remote-tracking branch 'origin/update_PHP_deps_20240813024539' 2024-08-12 22:46:17 -04:00
77988e612e Update PHP dependencies [20240813024539] 2024-08-13 02:45:40 +00:00
3691c60590 Merge remote-tracking branch 'origin/update_PHP_deps_20240813024120' 2024-08-12 22:45:31 -04:00
d6a8f56f7d Update PHP dependencies [20240813024120] 2024-08-13 02:41:21 +00:00
bbde55881e Merge remote-tracking branch 'origin/update_PHP_deps_20240813023702' 2024-08-12 22:41:14 -04:00
c2d7755ab7 Update PHP dependencies [20240813023702] 2024-08-13 02:37:04 +00:00
ce77bdd1ac add gitlab pipeline 2024-08-12 22:36:55 -04:00
5cc61666fe bugfixes 2024-08-12 22:32:44 -04:00
79f21773c6 canary and houdini updates 2024-08-09 17:18:24 -04:00
7 changed files with 101 additions and 129 deletions

49
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,49 @@
stages:
- update
variables:
TIMEZONE: "America/New_York" # For the system in general
DATE_TIMEZONE: ${TIMEZONE} # For PHP
GIT_DEPTH: 1
GITLAB_API_URL: ${CI_API_V4_URL}
TARGET_BRANCH: ${CI_COMMIT_REF_NAME} # This is the branch chosen in the `Pipeline Schedule`
TARGET_REMOTE: "https://${GITLAB_USERNAME}:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git"
# These could/should be overridden in an extending job:
UPDATE_BRANCH_PREFIX: "update_PHP_deps_" # Used for the update branch name, it will be followed by the datetime
GIT_USER: "DependBot" # Used for the update commit
GIT_EMAIL: "webmaster@thetempusproject.com" # Used for the update commit
GITLAB_USERNAME: "root" # Used for pushing the new branch and opening the MR
GITLAB_ACCESS_TOKEN: "glpat-PKEmivGtBfbz4DVPdhzk" # Used for pushing the new branch and opening the MR
MERGE_IF_SUCCESSFUL: "true" # Set to true, to merge automatically if the pipeline succeeds
SECONDS_BETWEEN_POOLING: 10 # Nbr of seconds between checking if the MR pipeline is successful, so then it will merge
JOB_GIT_FLAGS: ""
JOB_CURL_FLAGS: ""
JOB_COMPOSER_FLAGS: ""
composer_update:
stage: update
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
image: composer:latest
interruptible: true # allows to stop the job if a newer pipeline starts, saving resources and allowing new jobs to start because job concurrency is limited
script:
- git ${JOB_GIT_FLAGS} fetch origin ${TARGET_BRANCH}
- git ${JOB_GIT_FLAGS} checkout ${TARGET_BRANCH}
- git reset --hard origin/main
- export DATE_TIME="$(date '+%Y%m%d%H%M%S')"
- export MR_BRANCH="${UPDATE_BRANCH_PREFIX}${DATE_TIME}"
- git ${JOB_GIT_FLAGS} checkout -b "${MR_BRANCH}"
- composer update ${JOB_COMPOSER_FLAGS}
- if [ "$(git diff)" == "" ]; then echo "No updates needed!"; exit 0; fi
- export TITLE="Update PHP dependencies [${DATE_TIME}]"
- git ${JOB_GIT_FLAGS} commit -a -m "${TITLE}"
- git ${JOB_GIT_FLAGS} push "${TARGET_REMOTE}" "${MR_BRANCH}"
artifacts:
paths:
- vendor/
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/

View File

@ -17,36 +17,29 @@ if ( ! defined('BEDROCK_ROOT_DIRECTORY' ) ) {
define('BEDROCK_ROOT_DIRECTORY', dirname(__DIR__) . DIRECTORY_SEPARATOR);
}
if ( ! defined('BEDROCK_CONFIG_DIRECTORY' ) ) {
define('BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
define('BEDROCK_CONFIG_DIRECTORY', BEDROCK_ROOT_DIRECTORY . 'Config' . DIRECTORY_SEPARATOR);
}
if ( ! defined('BEDROCK_CONSTANTS_LOADED' ) ) {
require_once BEDROCK_CONFIG_DIRECTORY . 'constants.php';
}
if ( ! class_exists( 'TheTempusProject\Bedrock\Classes\Autoloader' ) ) {
if ( file_exists( BEDROCK_CLASSES_DIRECTORY . 'autoloader.php' ) ) {
require_once BEDROCK_CLASSES_DIRECTORY . 'autoloader.php';
}
}
if ( ! class_exists( 'TheTempusProject\Bedrock\App' ) ) {
if ( file_exists( BEDROCK_ROOT_DIRECTORY . 'app.php' ) ) {
require_once BEDROCK_ROOT_DIRECTORY . 'app.php';
}
if ( class_exists( 'TheTempusProject\Hermes\Classes\Autoloader' ) ) {
$autoloader = new Autoloader;
$autoloader->setRootFolder( BEDROCK_ROOT_DIRECTORY );
$autoloader->addNamespace(
'TheTempusProject\Bedrock',
'Bin'
);
$autoloader->addNamespace(
'TheTempusProject\Bedrock\Classes',
'Classes'
);
$autoloader->addNamespace(
'TheTempusProject\Bedrock\Functions',
'Functions'
);
$autoloader->register();
}
$autoloader = new Autoloader;
$autoloader->setRootFolder( BEDROCK_ROOT_DIRECTORY );
$autoloader->addNamespace(
'TheTempusProject\Bedrock',
'bin'
);
$autoloader->addNamespace(
'TheTempusProject\Bedrock\Classes',
'classes'
);
$autoloader->addNamespace(
'TheTempusProject\Bedrock\Functions',
'functions'
);
$autoloader->register();
require_once 'Bedrock.php';
define( 'BEDROCK_AUTOLOADED', true );

View File

@ -1,78 +0,0 @@
<?php
/**
* classes/custom_exception.php
*
* This class is used exclusively when throwing predefined exceptions.
* It will intercept framework thrown exceptions and deal with them however
* you choose; in most cases by logging them and taking appropriate responses
* such as redirecting to error pages.
*
* @version 3.0
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/Core
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Classes;
use Exception;
use TheTempusProject\Hermes\Functions\Redirect;
use TheTempusProject\Canary\Bin\Canary as Debug;
class CustomException extends Exception {
private $originFunction = null;
private $exceptionName = null;
private $originClass = null;
private $data = null;
/**
* This function allows the application to deal with errors
* in a dynamic way by letting you customize the response
*
* @param string $type - The type of the exception being called/thrown.
* @param string $data - Any additional data being passed with the exception.
*
* @example - throw new CustomException('model'); - Calls the model-missing exception
*/
public function __construct( $type, $data = null ) {
$this->originFunction = debug_backtrace()[1]['function'];
$this->originClass = debug_backtrace()[1]['class'];
$this->exceptionName = $type;
$this->data = $data;
switch ( $type ) {
case 'model':
Debug::error( 'Model not found: ' . $data );
break;
case 'dbConnection':
Debug::error( 'Error Connecting to the database: ' . $data );
break;
case 'DB':
Debug::error( 'Unspecified database error: ' . $data );
break;
case 'view':
Debug::error( 'View not found: ' . $data );
break;
case 'controller':
Debug::error( 'Controller not found: ' . $data );
Redirect::to( 404 );
break;
case 'defaultController':
Debug::error( 'DEFAULT Controller not found: ' . $data );
Redirect::to( 404 );
break;
case 'method':
Debug::error( 'Method not found: ' . $data );
Redirect::to( 404 );
break;
case 'simpleView':
Debug::error( 'View not found: ' . $data );
break;
case 'defaultMethod':
Debug::error( 'DEFAULT Method not found: ' . $data );
Redirect::to( 404 );
break;
default:
Debug::error( 'Default exception: ' . $data );
break;
}
}
}

View File

@ -15,8 +15,8 @@ namespace TheTempusProject\Bedrock\Classes;
use PDO;
use PDOException;
use TheTempusProject\Houdini\Classes\Pagination;
use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Canary\Classes\CustomException;
class Database {
public static $instance = null;

View File

@ -17,6 +17,8 @@ use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Bedrock\Classes\Config;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Houdini\Classes\Views;
class Pagination extends Template {
//The settings that will not change
@ -154,7 +156,7 @@ class Pagination extends Template {
$pageData = (object) $pageData;
if ( self::totalPages() <= 1 ) {
Components::set( 'PAGINATION', 'no pagination' );
Components::set( 'PAGINATION', '' );
} else {
Components::set( 'PAGINATION', Views::simpleView( 'nav.pagination', $pageData ) );
}

View File

@ -21,14 +21,17 @@ class Session {
* @return {bool}
*/
public static function exists( $name ) {
if ( !Check::sessionName( $name ) ) {
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if ( ! Check::sessionName( $name ) ) {
return false;
}
$sessionName = DEFAULT_SESSION_PREFIX . $name;
if ( isset( $_SESSION[$sessionName] ) ) {
if ( isset( $_SESSION[ $sessionName ] ) ) {
return true;
}
Debug::info("Session::exists - Session not found: $sessionName");
Debug::info( "Session::exists - Session not found: $sessionName" );
return false;
}
@ -39,14 +42,14 @@ class Session {
* @return {string|bool} - Returns the data from the session or false if nothing is found..
*/
public static function get( $name ) {
if ( !Check::sessionName( $name ) ) {
if ( ! Check::sessionName( $name ) ) {
return false;
}
$sessionName = DEFAULT_SESSION_PREFIX . $name;
if ( self::exists( $name ) ) {
$sessionName = DEFAULT_SESSION_PREFIX . $name;
return $_SESSION[$sessionName];
return $_SESSION[ $sessionName ];
}
Debug::info("Session::get - Session not found: $name");
Debug::info( "Session::get - Session not found: $sessionName" );
return false;
}
@ -58,12 +61,15 @@ class Session {
* @return {bool}
*/
public static function put( $name, $data ) {
if ( !Check::sessionName( $name ) ) {
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if ( ! Check::sessionName( $name ) ) {
return false;
}
$sessionName = DEFAULT_SESSION_PREFIX . $name;
$_SESSION[$sessionName] = $data;
Debug::info("Session: Created: $sessionName");
$_SESSION[ $sessionName ] = $data;
Debug::info( "Session::get - Created/Updated: $sessionName" );
return true;
}
@ -74,16 +80,16 @@ class Session {
* @return {bool}
*/
public static function delete( $name ) {
if ( !Check::sessionName( $name ) ) {
if ( ! Check::sessionName( $name ) ) {
return false;
}
$sessionName = DEFAULT_SESSION_PREFIX . $name;
if ( self::exists( $name ) ) {
$sessionName = DEFAULT_SESSION_PREFIX . $name;
unset( $_SESSION[$sessionName] );
Debug::info("Session::deleted: $sessionName");
Debug::info( "Session::delete - Deleted $sessionName" );
return true;
}
Debug::error("Session::delete - Session not found.");
Debug::error( "Session::delete - Session not found." );
return false;
}
@ -97,7 +103,7 @@ class Session {
* @return bool|string - Returns bool if creating, and a string if the check is successful.
*/
public static function checkFlash( $name ) {
if ( !Check::sessionName( $name ) ) {
if ( ! Check::sessionName( $name ) ) {
return false;
}
if ( self::exists( $name ) ) {
@ -110,10 +116,10 @@ class Session {
}
public static function flash( $name, $data = null ) {
if ( !Check::sessionName( $name ) ) {
if ( ! Check::sessionName( $name ) ) {
return false;
}
if ( !empty( $data ) ) {
if ( ! empty( $data ) ) {
self::put( $name, $data );
Debug::info("Session::flash - Session created.");
return true;

14
composer.lock generated
View File

@ -12,7 +12,7 @@
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/canary",
"reference": "8dff31b4eefa3efeb9f81d2e6b6ef3e9f8c9f27b"
"reference": "35415fbf3c5888ccdb8a8695989176a120026c7f"
},
"require": {
"php": ">=8.1.0"
@ -48,7 +48,7 @@
"thetempusproject",
"tools"
],
"time": "2024-08-09T06:18:45+00:00"
"time": "2024-08-20T10:26:09+00:00"
},
{
"name": "thetempusproject/hermes",
@ -56,7 +56,7 @@
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/hermes",
"reference": "9d6a79d80be98d0e598ce08c47a98d37814d1105"
"reference": "31c51c1a5bad2871df800c89f27ace0a49848583"
},
"require": {
"php": ">=8.1.0"
@ -92,7 +92,7 @@
"thetempusproject",
"tools"
],
"time": "2024-08-08T05:24:32+00:00"
"time": "2024-08-20T10:26:47+00:00"
},
{
"name": "thetempusproject/houdini",
@ -100,7 +100,7 @@
"source": {
"type": "git",
"url": "https://git.thetempusproject.com/the-tempus-project/houdini",
"reference": "34babdb2dc508450d14a0764bf81b032a6861a58"
"reference": "d9e61d3f8f5d10f3fa7ba31907a4b3c1edc76614"
},
"require": {
"php": ">=8.1.0",
@ -137,7 +137,7 @@
"thetempusproject",
"tools"
],
"time": "2024-08-09T06:20:26+00:00"
"time": "2024-08-20T10:30:48+00:00"
}
],
"packages-dev": [],
@ -150,5 +150,5 @@
"php": ">=8.1.0"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.6.0"
}