private function addMethod($articleId, $altMethod, $altSteps) { global $wgParser, $wgUser; $title = Title::newFromID($articleId); $result = array(); if ($title) { $isValid = MethodGuardian::checkContent($title, $altMethod, $altSteps, false); //only add it to the db if it's actually a valid method as defined //by the MethodGuardian::checkContent if ($isValid) { $dbw = wfGetDB(DB_MASTER); $dbw->insert('altmethodadder', array('ama_page' => $articleId, 'ama_method' => $altMethod, 'ama_steps' => $altSteps, 'ama_user' => $wgUser->getID(), 'ama_timestamp' => wfTimestampNow())); } $result['success'] = true; //Parse the wikiText that they gave us. //Need to add in a steps header so that mungeSteps //actually knows that it's a steps section $newMethod = $wgParser->parse("== Steps ==\n=== " . $altMethod . " ===\n" . $altSteps, $title, new ParserOptions())->getText(); $result['html'] = WikihowArticleHTML::postProcess($newMethod, array('no-ads' => true)); } else { $result['success'] = false; } return $result; }
usleep(500000); } $bad++; } $total++; } echo "{$bad} methods removed out of {$total}\n"; break; case "id": if ($argv[1] == null) { echo "You must enter an article id\n"; exit; } $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(MethodGuardian::TABLE_NAME, array("*"), array("ama_patrolled" => 0, "ama_page" => $argv[1]), __FILE__); echo $dbr->lastQuery() . "\n\n"; foreach ($res as $row) { $title = Title::newFromID($row->ama_page); if ($title) { echo "ARTICLE: " . $title->getText() . "\n"; } echo "METHOD NAME: " . $row->ama_method . "\nSTEPS: " . $row->ama_steps . "\n"; $result = MethodGuardian::checkContent($title, $row->ama_method, $row->ama_steps, true); if ($result) { echo "GOOD\n\n"; } else { echo "BAD\n\n"; } } break; }