Merge pull request #2127 from TheDigitalOrchard/uri-lib-optimizations
minor tweaks and optimizations to URI library
diff --git a/application/config/autoload.php b/application/config/autoload.php
index 4a9d221..40f0a65 100644
--- a/application/config/autoload.php
+++ b/application/config/autoload.php
@@ -56,7 +56,7 @@
/*
| -------------------------------------------------------------------
-| Auto-load Packges
+| Auto-load Packages
| -------------------------------------------------------------------
| Prototype:
|
diff --git a/system/database/drivers/ibase/ibase_driver.php b/system/database/drivers/ibase/ibase_driver.php
index 87faf3d..875f148 100644
--- a/system/database/drivers/ibase/ibase_driver.php
+++ b/system/database/drivers/ibase/ibase_driver.php
@@ -421,7 +421,7 @@
.($this->qb_offset ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit);
}
- return preg_replace('`SELECT`i', 'SELECT '.$select, $sql);
+ return preg_replace('`SELECT`i', 'SELECT '.$select, $sql, 1);
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 98d553b..c6b46f0 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -237,7 +237,7 @@
// modifies the query so that it a proper number of affected rows is returned.
if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
{
- return preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/', 'DELETE FROM \\1 WHERE 1=1', $sql);
+ return trim($sql).' WHERE 1=1';
}
return $sql;
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 966a7b1..be9176e 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -214,7 +214,7 @@
// modifies the query so that it a proper number of affected rows is returned.
if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
{
- return preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/', 'DELETE FROM \\1 WHERE 1=1', $sql);
+ return trim($sql).' WHERE 1=1';
}
return $sql;
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 54a134f..6d54936 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1491,7 +1491,7 @@
{
case 1 : imagegif($resource);
break;
- case 2 : imagejpeg($resource, '', $this->quality);
+ case 2 : imagejpeg($resource, NULL, $this->quality);
break;
case 3 : imagepng($resource);
break;
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5534a1e..744150b 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -231,7 +231,7 @@
- Native PHP functions used as rules can now accept an additional parameter, other than the data itself.
- Updated method ``set_rules()`` to accept an array of rules as well as a string.
- Fields that have empty rules set no longer run through validation (and therefore are not considered erroneous).
- - Added rule **differs* to check if the value of a field differs from the value of another field.
+ - Added rule **differs** to check if the value of a field differs from the value of another field.
- Added rule **valid_url**.
- Added support for named parameters in error messages.
- :doc:`Language <libraries/language>` line keys must now be prefixed with **form_validation_**.
diff --git a/user_guide_src/source/general/ancillary_classes.rst b/user_guide_src/source/general/ancillary_classes.rst
index a4befc7..5dc058a 100644
--- a/user_guide_src/source/general/ancillary_classes.rst
+++ b/user_guide_src/source/general/ancillary_classes.rst
@@ -58,31 +58,31 @@
Example::
-class Example {
+ class Example {
- protected $CI;
+ protected $CI;
- // We'll use a constructor, as you can't directly call a function
- // from a property definition.
- public function __construct()
- {
- // Assign the CodeIgniter super-object
- $this->CI =& get_instance();
+ // We'll use a constructor, as you can't directly call a function
+ // from a property definition.
+ public function __construct()
+ {
+ // Assign the CodeIgniter super-object
+ $this->CI =& get_instance();
+ }
+
+ public function foo()
+ {
+ $this->CI->load->helper('url');
+ redirect();
+ }
+
+ public function bar()
+ {
+ $this->CI->config_item('base_url');
+ }
+
}
- public function foo()
- {
- $this->CI->load->helper('url');
- redirect();
- }
-
- public function bar()
- {
- $this->CI->config_item('base_url');
- }
-
-}
-
In the above example, both methods ``foo()`` and ``bar()`` will work
after you instantiate the Example class, without the need to call
``get_instance()`` in each of them.
\ No newline at end of file
diff --git a/user_guide_src/source/general/core_classes.rst b/user_guide_src/source/general/core_classes.rst
index ce57aee..07c0b00 100644
--- a/user_guide_src/source/general/core_classes.rst
+++ b/user_guide_src/source/general/core_classes.rst
@@ -76,15 +76,15 @@
}
.. note:: If you need to use a constructor in your class make sure you
-extend the parent constructor::
+ extend the parent constructor::
- class MY_Input extends CI_Input {
+ class MY_Input extends CI_Input {
- public function __construct()
- {
- parent::__construct();
+ public function __construct()
+ {
+ parent::__construct();
+ }
}
- }
**Tip:** Any functions in your class that are named identically to the
methods in the parent class will be used instead of the native ones
diff --git a/user_guide_src/source/general/creating_libraries.rst b/user_guide_src/source/general/creating_libraries.rst
index 8bafd45..4fc8ed7 100644
--- a/user_guide_src/source/general/creating_libraries.rst
+++ b/user_guide_src/source/general/creating_libraries.rst
@@ -148,31 +148,31 @@
be able to use the CodeIgniter super-object in all of the class
methods, you're encouraged to assign it to a property instead::
-class Example_library {
+ class Example_library {
- protected $CI;
+ protected $CI;
- // We'll use a constructor, as you can't directly call a function
- // from a property definition.
- public function __construct()
- {
- // Assign the CodeIgniter super-object
- $this->CI =& get_instance();
+ // We'll use a constructor, as you can't directly call a function
+ // from a property definition.
+ public function __construct()
+ {
+ // Assign the CodeIgniter super-object
+ $this->CI =& get_instance();
+ }
+
+ public function foo()
+ {
+ $this->CI->load->helper('url');
+ redirect();
+ }
+
+ public function bar()
+ {
+ echo $this->CI->config_item('base_url');
+ }
+
}
- public function foo()
- {
- $this->CI->load->helper('url');
- redirect();
- }
-
- public function bar()
- {
- echo $this->CI->config_item('base_url');
- }
-
-}
-
Replacing Native Libraries with Your Versions
=============================================
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index ff60186..94f6321 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -302,7 +302,7 @@
String helper random_string() types 'unique' and 'encrypt'
==========================================================
-When using the :doc:`String Helper <helpers/string_helper>` function :php:func:`random_string()`,
+When using the :doc:`String Helper <../helpers/string_helper>` function :php:func:`random_string()`,
you should no longer pass the **unique** and **encrypt** randomization types. They are only
aliases for **md5** and **sha1** respectively and are now deprecated and scheduled for removal
in CodeIgniter 3.1+.
@@ -313,7 +313,7 @@
URL helper url_title() separators 'dash' and 'underscore'
=========================================================
-When using the :doc:`URL Helper <helpers/url_helper>` function :php:func:`url_title()`, you
+When using the :doc:`URL Helper <../helpers/url_helper>` function :php:func:`url_title()`, you
should no longer pass **dash** or **underscore** as the word separator. This function will
now accept any character and you should just pass the chosen character directly, so you
should write '-' instead of 'dash' and '_' instead of 'underscore'.
@@ -327,7 +327,7 @@
Database Forge method add_column() with an AFTER clause
=======================================================
-If you have used the **third parameter** for :doc:`Database Forge <database/forge>` method
+If you have used the **third parameter** for :doc:`Database Forge <../database/forge>` method
``add_column()`` to add a field for an AFTER clause, then you should change its usage.
That third parameter has been deprecated and scheduled for removal in CodeIgniter 3.1+.
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index ce1695d..ae7859a 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -479,7 +479,7 @@
If you'd like to include a field's "human" name, or the optional
parameter some rules allow for (such as max_length), you can add the
-**{field}** and **{param}** tags to your message, respectively.
+**{field}** and **{param}** tags to your message, respectively::
$this->form_validation->set_message('min_length', '{field} must have at least {param} characters.');
@@ -491,7 +491,7 @@
use one or the other.
In the callback rule example above, the error message was set by passing
-the name of the method (without the "callback_" prefix)::
+the name of the method (without the "callback\_" prefix)::
$this->form_validation->set_message('username_check')
diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst
index 1a73fb7..9a7b10d 100644
--- a/user_guide_src/source/libraries/migration.rst
+++ b/user_guide_src/source/libraries/migration.rst
@@ -158,6 +158,6 @@
version number.
**migration_auto_latest** FALSE TRUE / FALSE Enable or disable automatically
running migrations.
-**migration_type** 'timestamp' 'timestamp' / 'sequential' The type of numeric identifier used to name
+**migration_type** 'timestamp' 'timestamp' / 'sequential' The type of numeric identifier used to name
migration files.
========================== ====================== ========================== =============================================