Index: branches/5.3.x/core/kernel/globals.php
===================================================================
diff -u -N -r16519 -r16545
--- branches/5.3.x/core/kernel/globals.php (.../globals.php) (revision 16519)
+++ branches/5.3.x/core/kernel/globals.php (.../globals.php) (revision 16545)
@@ -1,6 +1,6 @@
isDebugMode() ) {
+ return;
+ }
+
+ $msg = '%1$s is deprecated since version %2$s';
+
+ if ( !is_null($replacement) ) {
+ @trigger_error(sprintf($msg . '! Use %3$s instead.', $method, $version, $replacement), E_USER_DEPRECATED);
+ }
+ else {
+ @trigger_error(sprintf($msg . ' with no alternative available.', $method, $version), E_USER_DEPRECATED);
+ }
+ }
+
+ /**
+ * Mark a method argument as deprecated and inform when it has been used.
+ *
+ * This method is to be used whenever a deprecated method argument is used.
+ * Before this method is called, the argument must be checked for whether it was
+ * used by comparing it to its default value or evaluating whether it is empty.
+ * For example:
+ *
+ * if ( !$deprecated ) {
+ * kUtil::deprecatedArgument(__METHOD__, '5.2.2');
+ * }
+ *
+ * The current behavior is to trigger a user deprecation notice in Debug Mode.
+ *
+ * @param string $method The method that was called.
+ * @param string $version The version that deprecated the argument used.
+ * @param string|null $message A message regarding the change.
+ *
+ * @return void
+ */
+ public static function deprecatedArgument($method, $version, $message = null)
+ {
+ $application =& kApplication::Instance();
+
+ if ( !$application->isDebugMode() ) {
+ return;
+ }
+
+ $msg = '%1$s was called with an argument that is deprecated since version %2$s';
+
+ if ( !is_null($message) ) {
+ @trigger_error(sprintf($msg . '! %3$s', $method, $version, $message), E_USER_DEPRECATED);
+ }
+ else {
+ @trigger_error(sprintf($msg . ' with no alternative available.', $method, $version), E_USER_DEPRECATED);
+ }
+ }
+
}
/**
Index: branches/5.3.x/core/kernel/utility/logger.php
===================================================================
diff -u -N -r16519 -r16545
--- branches/5.3.x/core/kernel/utility/logger.php (.../logger.php) (revision 16519)
+++ branches/5.3.x/core/kernel/utility/logger.php (.../logger.php) (revision 16545)
@@ -1,6 +1,6 @@
_logRecord || $this->_logRecord['LogLevel'] > $this->_maxLogLevel || $this->_state == self::STATE_DISABLED ) {
- // nothing to save OR less detailed logging requested OR disabled
+ if ( $check_origin && isset($this->_logRecord['LogSourceFilename']) ) {
+ $origin_allowed = self::isErrorOriginAllowed($this->_logRecord['LogSourceFilename']);
+ }
+ else {
+ $origin_allowed = true;
+ }
+
+ if ( !$this->_logRecord
+ || $this->_logRecord['LogLevel'] > $this->_maxLogLevel
+ || !$origin_allowed
+ || $this->_state == self::STATE_DISABLED
+ ) {
+ // Nothing to save OR less detailed logging requested OR origin not allowed OR disabled.
+ $this->_logRecord = array();
+
return false;
}
@@ -1057,6 +1071,49 @@
}
/**
+ * Determines if error should be logged based on it's origin.
+ *
+ * @param string $file File.
+ *
+ * @return boolean
+ */
+ public static function isErrorOriginAllowed($file)
+ {
+ static $error_origin_regexp;
+
+ // Lazy detect error origins, because they're not available at construction time.
+ if ( !$error_origin_regexp ) {
+ $error_origins = array();
+ $application = kApplication::Instance();
+
+ foreach ( $application->ModuleInfo as $module_info ) {
+ $error_origins[] = preg_quote(rtrim($module_info['Path'], '/'), '/');
+ }
+
+ $error_origins = array_unique($error_origins);
+ $error_origin_regexp = '/^' . preg_quote(FULL_PATH, '/') . '\/(' . implode('|', $error_origins) . ')\//';
+ }
+
+ // Allow dynamically generated code.
+ if ( strpos($file, 'eval()\'d code') !== false ) {
+ return true;
+ }
+
+ // Allow known modules.
+ if ( preg_match('/^' . preg_quote(MODULES_PATH, '/') . '\//', $file) ) {
+ return preg_match($error_origin_regexp, $file) == 1;
+ }
+
+ // Don't allow Vendors.
+ if ( preg_match('/^' . preg_quote(FULL_PATH, '/') . '\/vendor\//', $file) ) {
+ return false;
+ }
+
+ // Allow everything else within main folder.
+ return preg_match('/^' . preg_quote(FULL_PATH, '/') . '\//', $file) == 1;
+ }
+
+ /**
* Parses database error message into error number, error message and sql that caused that error
*
* @static
@@ -1165,6 +1222,13 @@
$this->_handlers[] = $handler;
}
+ /**
+ * Returns `true`, when no other error handlers should process this error.
+ *
+ * @param integer $errno Error code.
+ *
+ * @return boolean
+ */
protected function _handleFatalError($errno)
{
$debug_mode = defined('DEBUG_MODE') && DEBUG_MODE;
@@ -1182,7 +1246,7 @@
}
}
- return null;
+ return false;
}
/**
@@ -1304,12 +1368,12 @@
$log = $this->_logger->prepare()->addError($errno, $errstr, $errfile, $errline);
if ( $this->_handleFatalError($errno) ) {
- $log->write();
+ $log->write(kLogger::LS_AUTOMATIC, !$this->_isFatalError($errno));
return true;
}
- $log->write();
+ $log->write(kLogger::LS_AUTOMATIC, !$this->_isFatalError($errno));
$res = false;
Index: branches/5.3.x/core/kernel/utility/debugger.php
===================================================================
diff -u -N -r16519 -r16545
--- branches/5.3.x/core/kernel/utility/debugger.php (.../debugger.php) (revision 16519)
+++ branches/5.3.x/core/kernel/utility/debugger.php (.../debugger.php) (revision 16545)
@@ -1,6 +1,6 @@
self::ROW_TYPE_ERROR,
'Warning' => self::ROW_TYPE_WARNING,
'Notice' => self::ROW_TYPE_NOTICE,
+ 'Deprecation Notice' => self::ROW_TYPE_NOTICE,
);
return $error_map[$this->getErrorNameByCode($data['no'])];
@@ -1462,9 +1463,8 @@
);
if ( defined('E_DEPRECATED') ) {
- // since PHP 5.3
- $error_map['Notice'][] = E_DEPRECATED;
- $error_map['Notice'][] = E_USER_DEPRECATED;
+ // Since PHP 5.3.
+ $error_map['Deprecation Notice'] = array(E_DEPRECATED, E_USER_DEPRECATED);
}
foreach ($error_map as $error_name => $error_codes) {
@@ -1879,6 +1879,9 @@
$this->_fatalErrorHash = $this->_getErrorHash($errfile, $errline);
$this->appendTrace(4);
}
+ elseif ( !kLogger::isErrorOriginAllowed($errfile) ) {
+ return;
+ }
$this->expandError($errstr, $errfile, $errline);
Index: branches/5.3.x/core/install/upgrades.sql
===================================================================
diff -u -N -r16531 -r16545
--- branches/5.3.x/core/install/upgrades.sql (.../upgrades.sql) (revision 16531)
+++ branches/5.3.x/core/install/upgrades.sql (.../upgrades.sql) (revision 16545)
@@ -2936,6 +2936,11 @@
UPDATE SystemSettings SET VariableValue = 1 WHERE VariableName = 'CSVExportEncoding';
ALTER TABLE Semaphores ADD MainIDs INT NULL DEFAULT NULL AFTER MainPrefix;
+# ===== v 5.2.2-B2 =====
+UPDATE Modules
+SET ClassNamespace = 'InPortal\\Core'
+WHERE `Name` IN ('Core', 'In-Portal');
+
# ===== v 5.3.0-B1 =====
ALTER TABLE ScheduledTasks ADD Settings TEXT NULL;
ALTER TABLE Themes ADD ImageResizeRules TEXT NULL;
@@ -3033,9 +3038,10 @@
CHANGE SSLUrlUsesRegExp SSLDomainNameUsesRegExp TINYINT(4) NOT NULL DEFAULT '0';
DELETE FROM UserPersistentSessionData WHERE VariableName = 'site-domain[Default]columns_.';
-UPDATE Modules
-SET ClassNamespace = 'InPortal\\Core'
-WHERE `Name` IN ('Core', 'In-Portal');
+# Backported in http://jira.in-portal.org/browse/INP-1690.
+# UPDATE Modules
+# SET ClassNamespace = 'InPortal\\Core'
+# WHERE `Name` IN ('Core', 'In-Portal');
UPDATE EmailTemplates
SET