Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1203615
D544.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 3, 4:21 PM
Size
5 KB
Mime Type
text/x-diff
Expires
Tue, Nov 4, 4:21 PM (16 h, 19 m)
Engine
blob
Format
Raw Data
Handle
784899
Attached To
D544: INP-1928 - Automatic Scheduled Task creation protection
D544.diff
View Options
Index: core/units/scheduled_tasks/scheduled_task_eh.php
===================================================================
--- core/units/scheduled_tasks/scheduled_task_eh.php
+++ core/units/scheduled_tasks/scheduled_task_eh.php
@@ -72,8 +72,9 @@
{
$scheduled_tasks_from_cache = $this->Application->EventManager->getScheduledTasks(true);
- /** @var kDBItem $object */
- $object = $event->getObject( Array ('skip_autoload' => true) );
+ /** @var ScheduledTaskItem $object */
+ $object = $event->getObject(array('skip_autoload' => true));
+ $object->removeAbsentDatabaseColumns();
$processed_ids = Array ();
$scheduled_tasks_from_db = $this->Conn->Query($object->GetSelectSQL(), 'Name');
Index: core/units/scheduled_tasks/scheduled_task_item.php
===================================================================
--- /dev/null
+++ core/units/scheduled_tasks/scheduled_task_item.php
@@ -0,0 +1,21 @@
+<?php
+/**
+* @version $Id$
+* @package In-Portal
+* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
+* @license GNU/GPL
+* In-Portal is Open Source software.
+* This means that this software may have been modified pursuant
+* the GNU General Public License, and as distributed it includes
+* or is derivative of works licensed under the GNU General Public License
+* or other free or open source software licenses.
+* See http://www.in-portal.org/license for copyright notices and details.
+*/
+
+defined('FULL_PATH') or die('restricted access!');
+
+
+class ScheduledTaskItem extends kDBItem
+{
+ use TDatabaseTableValidatorItemFeature;
+}
Index: core/units/scheduled_tasks/scheduled_tasks_config.php
===================================================================
--- core/units/scheduled_tasks/scheduled_tasks_config.php
+++ core/units/scheduled_tasks/scheduled_tasks_config.php
@@ -16,7 +16,7 @@
$config = Array (
'Prefix' => 'scheduled-task',
- 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ItemClass' => Array ('class' => 'ScheduledTaskItem', 'file' => 'scheduled_task_item.php', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'ScheduledTaskEventHandler', 'file' => 'scheduled_task_eh.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
Index: core/units/traits/TDatabaseTableValidatorItemFeature.php
===================================================================
--- /dev/null
+++ core/units/traits/TDatabaseTableValidatorItemFeature.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * @version $Id$
+ * @package In-Portal
+ * @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
+ * @license GNU/GPL
+ * In-Portal is Open Source software.
+ * This means that this software may have been modified pursuant
+ * the GNU General Public License, and as distributed it includes
+ * or is derivative of works licensed under the GNU General Public License
+ * or other free or open source software licenses.
+ * See http://www.in-portal.org/license for copyright notices and details.
+ */
+
+/**
+ * Allows to remove absent database columns from an already constructed object.
+ *
+ * @mixin kDBItem
+ */
+trait TDatabaseTableValidatorItemFeature
+{
+
+ /**
+ * Removes absent database columns from the object.
+ *
+ * @return void
+ */
+ public function removeAbsentDatabaseColumns()
+ {
+ $sql = 'DESCRIBE ' . $this->TableName;
+ $actual_db_fields = $this->Conn->Query($sql, 'Field');
+ $declared_db_fields = array_diff_key($this->getFields(), $this->getVirtualFields());
+
+ $absent_db_fields = array_keys(array_diff_key($declared_db_fields, $actual_db_fields));
+
+ if ( !$absent_db_fields ) {
+ return;
+ }
+
+ $fields = $this->getFields();
+
+ foreach ( $absent_db_fields as $field ) {
+ unset($fields[$field]);
+ }
+
+ $this->setFields($fields);
+ }
+
+}
Index: core/units/traits/traits_config.php
===================================================================
--- /dev/null
+++ core/units/traits/traits_config.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * @version $Id$
+ * @package In-Portal
+ * @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
+ * @license GNU/GPL
+ * In-Portal is Open Source software.
+ * This means that this software may have been modified pursuant
+ * the GNU General Public License, and as distributed it includes
+ * or is derivative of works licensed under the GNU General Public License
+ * or other free or open source software licenses.
+ * See http://www.in-portal.org/license for copyright notices and details.
+ */
+
+defined('FULL_PATH') or die('restricted access!');
+
+$config = array(
+ 'Prefix' => 'core-traits',
+ 'EventHandlerClass' => array('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => array('class' => 'kTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+
+ 'RegisterClasses' => array(
+ array('pseudo' => 'TDatabaseTableValidatorItemFeature', 'class' => 'TDatabaseTableValidatorItemFeature', 'file' => 'TDatabaseTableValidatorItemFeature.php', 'build_event' => ''),
+ ),
+);
Event Timeline
Log In to Comment