mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Adding double-quotes to table and field references
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@66417 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a93a0c3c95
commit
f067bd1304
@ -360,13 +360,13 @@ JS;
|
||||
$treeClass = $this->stat('tree_class');
|
||||
|
||||
if($id && is_numeric($id)) {
|
||||
$record = DataObject::get_one( $treeClass, "\"$treeClass\".ID = $id");
|
||||
$record = DataObject::get_one( $treeClass, "\"$treeClass\".\"ID\" = $id");
|
||||
|
||||
if(!$record) {
|
||||
// $record = Versioned::get_one_by_stage($treeClass, "Live", "\"$treeClass\".ID = $id");
|
||||
// $record = Versioned::get_one_by_stage($treeClass, "Live", "\"$treeClass\".\"ID\" = $id");
|
||||
Versioned::reading_stage('Live');
|
||||
singleton($treeClass)->flushCache();
|
||||
$record = DataObject::get_one( $treeClass, "\"$treeClass\".ID = $id");
|
||||
$record = DataObject::get_one( $treeClass, "\"$treeClass\".\"ID\" = $id");
|
||||
if($record) {
|
||||
$record->DeletedFromStage = true;
|
||||
} else {
|
||||
@ -400,7 +400,7 @@ JS;
|
||||
$idField->setValue($id);
|
||||
|
||||
if($record->ID && is_numeric( $record->ID ) ) {
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".ID = $record->ID");
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $record->ID");
|
||||
if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink());
|
||||
}
|
||||
|
||||
@ -596,7 +596,7 @@ JS;
|
||||
*/
|
||||
public function delete($urlParams, $form) {
|
||||
$id = $_REQUEST['ID'];
|
||||
$record = DataObject::get_one("SiteTree", "SiteTree.ID = $id");
|
||||
$record = DataObject::get_one("SiteTree", "SiteTree.\"ID\" = $id");
|
||||
if($record && !$record->canDelete()) return Security::permissionFailure();
|
||||
|
||||
$recordID = $record->ID;
|
||||
@ -797,7 +797,7 @@ HTML;
|
||||
$JS_title = Convert::raw2js($page->TreeTitle());
|
||||
|
||||
$JS_stageURL = $page->DeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".ID = $page->ID");
|
||||
$liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $page->ID");
|
||||
$JS_liveURL = $liveRecord ? Convert::raw2js($liveRecord->AbsoluteLink()) : '';
|
||||
|
||||
FormResponse::add($this->getActionUpdateJS($page));
|
||||
@ -1240,8 +1240,8 @@ HTML;
|
||||
if($id = $this->urlParams['ID']) {
|
||||
$restoredPage = Versioned::get_latest_version("SiteTree", $id);
|
||||
$restoredPage->ID = $restoredPage->RecordID;
|
||||
if(!DB::query("SELECT ID FROM SiteTree WHERE ID = $restoredPage->ID")->value()) {
|
||||
DB::query("INSERT INTO SiteTree SET ID = $restoredPage->ID");
|
||||
if(!DB::query("SELECT \"ID\" FROM \"SiteTree\" WHERE \"ID\" = $restoredPage->ID")->value()) {
|
||||
DB::query("INSERT INTO \"SiteTree\" SET \"ID\" = $restoredPage->ID");
|
||||
}
|
||||
$restoredPage->forceChange();
|
||||
$restoredPage->writeWithoutVersion();
|
||||
|
@ -433,7 +433,7 @@ JS;
|
||||
|
||||
$SQL_id = Convert::raw2sql($_REQUEST['ID']);
|
||||
if(substr($SQL_id,0,3) != 'new') {
|
||||
$record = DataObject::get_one($className, "\"$className\".ID = {$SQL_id}");
|
||||
$record = DataObject::get_one($className, "\"$className\".\"ID\" = {$SQL_id}");
|
||||
if($record && !$record->canEdit()) return Security::permissionFailure($this);
|
||||
} else {
|
||||
if(!singleton($this->stat('tree_class'))->canCreate()) return Security::permissionFailure($this);
|
||||
|
@ -142,15 +142,13 @@ class PageCommentInterface extends RequestHandler {
|
||||
|
||||
function Comments() {
|
||||
// Comment limits
|
||||
if(isset($_GET['commentStart'])) {
|
||||
$limit = (int)$_GET['commentStart'].",".PageComment::$comments_per_page;
|
||||
} else {
|
||||
$limit = "0,".PageComment::$comments_per_page;
|
||||
}
|
||||
$limit = array();
|
||||
$limit['start'] = isset($_GET['commentStart']) ? (int)$_GET['commentStart'] : 0;
|
||||
$limit['limit'] = PageComment::$comments_per_page;
|
||||
|
||||
$spamfilter = isset($_GET['showspam']) ? '' : 'AND IsSpam=0';
|
||||
$unmoderatedfilter = Permission::check('ADMIN') ? '' : 'AND NeedsModeration = 0';
|
||||
$comments = DataObject::get("PageComment", "ParentID = '" . Convert::raw2sql($this->page->ID) . "' $spamfilter $unmoderatedfilter", "Created DESC", "", $limit);
|
||||
$spamfilter = isset($_GET['showspam']) ? '' : 'AND NOT "IsSpam"';
|
||||
$unmoderatedfilter = Permission::check('ADMIN') ? '' : 'AND NOT "NeedsModeration"';
|
||||
$comments = DataObject::get("PageComment", "\"ParentID\" = '" . Convert::raw2sql($this->page->ID) . "' $spamfilter $unmoderatedfilter", '"Created" DESC', "", $limit);
|
||||
|
||||
if(is_null($comments)) {
|
||||
return;
|
||||
|
@ -51,10 +51,10 @@ class CMSMainTest extends SapphireTest {
|
||||
$page->Title = "Test $class page";
|
||||
|
||||
$page->write();
|
||||
$this->assertEquals("Test $class page", DB::query("SELECT Title FROM SiteTree WHERE ID = $page->ID")->value());
|
||||
$this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree\" WHERE \"ID\" = $page->ID")->value());
|
||||
|
||||
$page->doPublish();
|
||||
$this->assertEquals("Test $class page", DB::query("SELECT Title FROM SiteTree_Live WHERE ID = $page->ID")->value());
|
||||
$this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = $page->ID")->value());
|
||||
|
||||
// Check that you can visit the page
|
||||
Director::test($page->Link());
|
||||
|
Loading…
x
Reference in New Issue
Block a user