|
Revision 2, 1.3 kB
(checked in by nperriault, 10 months ago)
|
First commit of the extracted code from production, I hope no passwd has been forgotten :-)
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
error_reporting(E_ALL); |
|---|
| 3 |
$app = 'main'; |
|---|
| 4 |
$sf_root = dirname(__FILE__).'/..'; |
|---|
| 5 |
include($sf_root.'/test/bootstrap/functional.php'); |
|---|
| 6 |
include($sf_root.'/lib/symfony/vendor/pake/pakeFunction.php'); |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
$databaseManager = new sfDatabaseManager(); |
|---|
| 10 |
$databaseManager->initialize(); |
|---|
| 11 |
$con = Propel::getConnection(); |
|---|
| 12 |
|
|---|
| 13 |
$tags = TagPeer::doSelect(new Criteria); |
|---|
| 14 |
|
|---|
| 15 |
foreach ($tags as $tag) |
|---|
| 16 |
{ |
|---|
| 17 |
$is_orphan = false; |
|---|
| 18 |
$c = new Criteria; |
|---|
| 19 |
$c->add(TaggingPeer::TAG_ID, $tag->getId()); |
|---|
| 20 |
$taggings = TaggingPeer::doSelect($c); |
|---|
| 21 |
if (count($taggings) == 0) |
|---|
| 22 |
{ |
|---|
| 23 |
$is_orphan = true; |
|---|
| 24 |
} |
|---|
| 25 |
foreach ($taggings as $tagging) |
|---|
| 26 |
{ |
|---|
| 27 |
$peer = $tagging->getTaggableModel().'Peer'; |
|---|
| 28 |
if (!class_exists($peer)) |
|---|
| 29 |
{ |
|---|
| 30 |
pake_echo_action('unexistant model', $tagging->getTaggableModel()); |
|---|
| 31 |
$is_orphan = true; |
|---|
| 32 |
} |
|---|
| 33 |
$object = call_user_func(array($tagging->getTaggableModel().'Peer', |
|---|
| 34 |
'retrieveByPK'), |
|---|
| 35 |
$tagging->getTaggableId()); |
|---|
| 36 |
if (!$object) |
|---|
| 37 |
{ |
|---|
| 38 |
pake_echo_action('delete orphan tagging', $tag->getName().' for '.$tagging->getTaggableModel().'/'.$tagging->getTaggableId()); |
|---|
| 39 |
$tagging->delete(); |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
if ($is_orphan) |
|---|
| 43 |
{ |
|---|
| 44 |
pake_echo_action('delete orphan tag', $tag->getName()); |
|---|
| 45 |
$tag->delete(); |
|---|
| 46 |
} |
|---|
| 47 |
} |
|---|