| Conditions | 11 |
| Paths | 9 |
| Total Lines | 58 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 48 | public function run($request) |
||
| 49 | { |
||
| 50 | Environment::increaseTimeLimitTo(); |
||
| 51 | Environment::increaseMemoryLimitTo(); |
||
| 52 | Config::modify()->set(DataObject::class, 'validation_enabled', false); |
||
| 53 | if ($request->requestVar('confirm') || Director::is_cli() || $this->allowed) { |
||
| 54 | // Protect against CSRF on destructive action |
||
| 55 | if (Director::is_cli() || SecurityToken::inst()->checkRequest($request)) { |
||
| 56 | $start = 0; |
||
| 57 | $pages = SiteTree::get()->limit($this->step, $start); |
||
| 58 | FlushNowImplementor: |
||
| 59 | FlushNowImplementor::do_flush('<ol>'); |
||
| 60 | $count = 0; |
||
| 61 | while ($pages->exists()) { |
||
| 62 | foreach ($pages as $page) { |
||
| 63 | $isPublished = $page->IsPublished() && !$page->isModifiedOnDraft(); |
||
| 64 | FlushNowImplementor::do_flush('publishing: ' . $page->Title, 'created'); |
||
| 65 | $page->writeToStage(Versioned::DRAFT, true); |
||
| 66 | if ($isPublished) { |
||
| 67 | $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); |
||
| 68 | $page->publishRecursive(); |
||
| 69 | } |
||
| 70 | $page->destroy(); |
||
| 71 | unset($page); |
||
| 72 | ++$count; |
||
| 73 | } |
||
| 74 | $start += $this->step; |
||
| 75 | $pages = SiteTree::get()->limit($this->step, $start); |
||
| 76 | } |
||
| 77 | FlushNowImplementor::do_flush('</ol>'); |
||
| 78 | FlushNowImplementor::do_flush('<h2>--- PUBLISHED ' . $count . ' Pages ---</h2>'); |
||
| 79 | } else { |
||
| 80 | Controller::curr()->httpError(400); |
||
| 81 | |||
| 82 | return; |
||
| 83 | } |
||
| 84 | } else { |
||
| 85 | $response = ''; |
||
| 86 | $token = SecurityToken::inst(); |
||
| 87 | $fields = FieldList::create(); |
||
| 88 | $token->updateFieldSet($fields); |
||
| 89 | $tokenField = $fields->first(); |
||
| 90 | $tokenHtml = ($tokenField) ? $tokenField->FieldHolder() : ''; |
||
| 91 | $publishAllDescription = _t( |
||
| 92 | __CLASS__ . '.PUBALLFUN2', |
||
| 93 | 'Pressing this button will do the equivalent of going to every page and pressing "publish". ' |
||
| 94 | . "It's intended to be used after there have been massive edits of the content, such as when " |
||
| 95 | . 'the site was first built.' |
||
| 96 | ); |
||
| 97 | $response .= |
||
| 98 | '<h1>' . _t(__CLASS__ . '.PUBALLFUN', 'Publish All functionality') . '</h1> |
||
| 99 | <p>' . $publishAllDescription . '</p> |
||
| 100 | <form method="get" action=""> |
||
| 101 | <input type="submit" name="confirm" value="' |
||
| 102 | . _t(__CLASS__ . '.PUBALLCONFIRM', 'Please publish every page in the site', 'Confirmation button') . '" />' |
||
| 103 | . $tokenHtml . |
||
| 104 | '</form>'; |
||
| 105 | FlushNowImplementor::do_flush($response); |
||
| 106 | } |
||
| 109 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths