CodeIgniter 3.1.11 -> 3.4.5 (pocketarc fork) en PHP 8.3-fixes
- system/ vervangen door CodeIgniter 3.4.5 (pocketarc/codeigniter, PHP 8.2-8.5 compatibel) - config.php, mimes.php, user_agents.php en error-views bijgewerkt naar 3.4.5 - composer.json: php-constraint "^7.4 || ^8.0" zodat composer install op 8.3 werkt - PHP 8-fatals opgelost: count()/array-functies op FALSE/null, rekenen met lege strings, delen door nul, property zetten op FALSE, curly-brace string offsets, ongedefinieerde constanten, foute curl_setopt in Phantom_model::create_img - dynamic properties gedeclareerd in libraries, optionele parameters voor verplichte opgelost - vergelijkingen waar '' == 0 in PHP 8 anders uitvalt gecast naar (int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+63
-30
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* Copyright (c) 2019 - 2022, CodeIgniter Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,6 +30,7 @@
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||
* @copyright Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
@@ -46,8 +47,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Loader
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/loader.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/loader.html
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
class CI_Loader {
|
||||
|
||||
// All these are set automatically. Don't mess with them.
|
||||
@@ -93,6 +95,13 @@ class CI_Loader {
|
||||
*/
|
||||
protected $_ci_cached_vars = array();
|
||||
|
||||
/**
|
||||
* Stack of variable arrays to provide nested _ci_load calls with all variables from parent calls
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_ci_load_vars_stack = array();
|
||||
|
||||
/**
|
||||
* List of loaded classes
|
||||
*
|
||||
@@ -348,9 +357,10 @@ class CI_Loader {
|
||||
throw new RuntimeException('Unable to locate the model you have specified: '.$model);
|
||||
}
|
||||
}
|
||||
elseif ( ! is_subclass_of($model, 'CI_Model'))
|
||||
|
||||
if ( ! is_subclass_of($model, 'CI_Model'))
|
||||
{
|
||||
throw new RuntimeException("Class ".$model." already exists and doesn't extend CI_Model");
|
||||
throw new RuntimeException("Class ".$model." doesn't extend CI_Model");
|
||||
}
|
||||
|
||||
$this->_ci_models[] = $name;
|
||||
@@ -367,19 +377,16 @@ class CI_Loader {
|
||||
*
|
||||
* @param mixed $params Database configuration options
|
||||
* @param bool $return Whether to return the database object
|
||||
* @param bool $query_builder Whether to enable Query Builder
|
||||
* (overrides the configuration setting)
|
||||
*
|
||||
* @return object|bool Database object if $return is set to TRUE,
|
||||
* FALSE on failure, CI_Loader instance in any other case
|
||||
*/
|
||||
public function database($params = '', $return = FALSE, $query_builder = NULL)
|
||||
public function database($params = '', $return = FALSE)
|
||||
{
|
||||
// Grab the super object
|
||||
$CI =& get_instance();
|
||||
|
||||
// Do we even need to load the database class?
|
||||
if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
|
||||
if ($return === FALSE && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -388,7 +395,7 @@ class CI_Loader {
|
||||
|
||||
if ($return === TRUE)
|
||||
{
|
||||
return DB($params, $query_builder);
|
||||
return DB($params);
|
||||
}
|
||||
|
||||
// Initialize the db variable. Needed to prevent
|
||||
@@ -396,7 +403,7 @@ class CI_Loader {
|
||||
$CI->db = '';
|
||||
|
||||
// Load the DB class
|
||||
$CI->db =& DB($params, $query_builder);
|
||||
$CI->db =& DB($params);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -492,7 +499,20 @@ class CI_Loader {
|
||||
*/
|
||||
public function view($view, $vars = array(), $return = FALSE)
|
||||
{
|
||||
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
|
||||
$measure = "View - $view";
|
||||
$CI =& get_instance();
|
||||
|
||||
if (property_exists($CI, "debugbar") && $CI->debugbar) {
|
||||
$CI->debugbar["time"]->startMeasure($measure);
|
||||
}
|
||||
|
||||
$result = $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
|
||||
|
||||
if (property_exists($CI, "debugbar") && $CI->debugbar && $CI->debugbar["time"]->hasStartedMeasure($measure)) {
|
||||
$CI->debugbar["time"]->stopMeasure($measure);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -933,17 +953,38 @@ class CI_Loader {
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and cache variables
|
||||
* Extract and stack variables
|
||||
*
|
||||
* You can either set variables using the dedicated $this->load->vars()
|
||||
* function or via the second parameter of this function. We'll merge
|
||||
* the two types and cache them so that views that are embedded within
|
||||
* other views can have access to these variables.
|
||||
* the two types so that loaded views and files have access to these
|
||||
* variables.
|
||||
* Additionally we want all subsequent nested _ci_load() calls embedded
|
||||
* within the current file to 'inherit' all variables that are
|
||||
* accessible to the current file. For this purpose we push the current
|
||||
* variable configuration (_ci_vars) to the stack and remove it again
|
||||
* after the file or view is completely loaded. Nested _ci_load() calls
|
||||
* within the current file extend the stack with their variable
|
||||
* configuration.
|
||||
*/
|
||||
empty($_ci_vars) OR $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
|
||||
extract($this->_ci_cached_vars);
|
||||
|
||||
/*
|
||||
is_array($_ci_vars) OR $_ci_vars = array();
|
||||
|
||||
// Include the global cached vars into the current _ci_vars if needed
|
||||
empty($this->_ci_cached_vars) OR $_ci_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
|
||||
|
||||
// Merge the last variable configuration from a parent _ci_load()
|
||||
// call into the current _ci_vars
|
||||
if ( ! empty($this->_ci_load_vars_stack))
|
||||
{
|
||||
$previous_variable_configuration = end($this->_ci_load_vars_stack);
|
||||
$_ci_vars = array_merge($previous_variable_configuration, $_ci_vars);
|
||||
}
|
||||
|
||||
array_push($this->_ci_load_vars_stack, $_ci_vars);
|
||||
extract($_ci_vars);
|
||||
|
||||
/**
|
||||
* Buffer the output
|
||||
*
|
||||
* We buffer the output for two reasons:
|
||||
@@ -956,20 +997,12 @@ class CI_Loader {
|
||||
*/
|
||||
ob_start();
|
||||
|
||||
// If the PHP installation does not support short tags we'll
|
||||
// do a little string replacement, changing the short tags
|
||||
// to standard PHP echo statements.
|
||||
if ( ! is_php('5.4') && ! ini_get('short_open_tag') && config_item('rewrite_short_tags') === TRUE)
|
||||
{
|
||||
echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
|
||||
}
|
||||
else
|
||||
{
|
||||
include($_ci_path); // include() vs include_once() allows for multiple views with the same name
|
||||
}
|
||||
|
||||
include($_ci_path); // include() vs include_once() allows for multiple views with the same name
|
||||
log_message('info', 'File loaded: '.$_ci_path);
|
||||
|
||||
// Remove current _ci_vars from stack
|
||||
array_pop($this->_ci_load_vars_stack);
|
||||
|
||||
// Return the file data if requested
|
||||
if ($_ci_return === TRUE)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user